def _complete_quest(self, quest: Quest): item_reward = quest.give_item_rewards() xp_reward = quest.give_reward() if isinstance(quest, FetchQuest): # if we just completed a fetch quest, we need to remove the required items for the quest self._remove_fetch_quest_required_items(quest) print( f'Quest {quest.name} is completed! XP awarded: {quest.xp_reward}!') if isinstance(item_reward, Item): print( f'{self.name} is awarded {item_reward.name} from the quest {quest.name}!' ) self.award_item(item_reward) elif isinstance(item_reward, list): for item in item_reward: print( f'{self.name} is awarded {item.name} from the quest {quest.name}!' ) self.award_item(item) del self.quest_log[quest.ID] # remove from quest log self.completed_quests.add(quest.ID) self._award_experience(xp_reward)
def add_quest(self, quest: Quest): if quest.ID in self.quest_log: raise Exception(f'{quest.name} is already in your quest log!') self.quest_log[quest.ID] = quest # there are some cases where the quest can be completed on accept, i.e having the required items quest.check_if_complete(self) self._check_if_quest_completed(quest)
def test_get_hint_if_not_started(self, questions_provider): questions_list = self.generate_questions_list() questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = False quest.current_question_number = 2 messages_list = quest.get_hint() self.assertEqual(len(messages_list), 1) self.assertEqual(messages_list[0].text, quest.messages['quest_not_started']) self.assertEqual(messages_list[0].as_reply, False)
def __init__(self, vision, controller, window): self.vision = vision self.controller = controller self.window = window self.current_resource = 2 self.train_troops = 0 self.state = State(vision, controller, window) self.gather = Gather(vision, self.state, controller) self.building = Building(vision, self.state, controller, window) self.quest = Quest(vision, controller) self.last_inf_check = 0 self.last_shelter_check = 0
def __init__(self): logger.logger() logger.log("Initialization...") str_const.set_fracs_list() vk_session = vk_api.VkApi(token=vk_token.token) self.vk = vk_session.get_api() self.longpoll = VkLongPoll(vk_session, wait=const.wait) self.is_running = True #self.counter = 0 self.player = PlayerManager() self.database = LiteDB() self.quest = Quest() logger.log("Initialization complete!")
def test_assess_answer_if_not_started_incorrect_answer(self, questions_provider): questions_list = self.generate_questions_list() q2 = questions_list[1] q2.assess_answer.return_value = (False, q2.fail_message) questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = False quest.current_question_number = 1 messages_list = quest.assess_answer(questions_list[1].answer + 'abc') self.assertEqual(len(messages_list), 1) self.assertEqual(messages_list[0].text, quest.messages['quest_not_started']) self.assertEqual(messages_list[0].as_reply, True)
def test_start_quest_if_not_started(self, questions_provider): questions_list = self.generate_questions_list() questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) messages_list = quest.start_quest() self.assertEqual(quest.is_started, True) self.assertEqual(len(messages_list), 3) self.assertEqual(quest.get_current_question(), questions_provider.get_questions()[0]) self.assertEqual(quest.current_question_number, 0) self.assertEqual(messages_list[0].text, quest.messages['welcome']) self.assertEqual(messages_list[0].as_reply, False) self.assertEqual(messages_list[1].text, 'Question 1 of 3') self.assertEqual(messages_list[1].as_reply, False) self.assertEqual(messages_list[2].text, questions_provider.get_questions()[0].get_question()) self.assertEqual(messages_list[2].as_reply, False)
def generate_quests(source, items, rooms): try: read = open(source,"r") while True: lines = read.readline() if not lines.strip() and len(lines)>0: continue elif len(lines)>0: questList = lines.strip("\n").split("|") else: break reward = questList[0].strip() action = questList[1].strip() desc = questList[2].strip() before = questList[3].strip() after = questList[4].strip() req = questList[5].strip() fail_msg = questList[6].strip() pass_msg = questList[7].strip() room = questList[8].strip() if len(questList) >0: quest = Quest(reward, action, desc, before, after, req, fail_msg, pass_msg, room) quests.append(quest) read.close() return quests except: return
def test_assess_answer_if_started_correct_answer_last_question(self, questions_provider): questions_list = self.generate_questions_list() q3 = questions_list[2] q3.assess_answer.return_value = (True, q3.success_message) questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = True quest.current_question_number = 2 messages_list = quest.assess_answer(questions_list[2].answer) self.assertEqual(len(messages_list), 3) self.assertEqual(messages_list[0].text, questions_list[2].success_message) self.assertEqual(messages_list[0].as_reply, True) self.assertEqual(messages_list[1].text, quest.messages['correct_answer']) self.assertEqual(messages_list[1].as_reply, True) self.assertEqual(messages_list[2].text, quest.messages['finish']) self.assertEqual(messages_list[2].as_reply, False) self.assertEqual(quest.is_started, False)
def readDataFromFile(file_name): try: sheet = read_excel(file_name, sheet_name="Sheet1") quests = [] for index, row in sheet.iterrows(): quests.append(Quest(row)) return quests except: print("Error reading file.") sys.exit()
def _complete_quest(self, quest: Quest): item_reward = quest.give_item_rewards() xp_reward = quest.give_reward() if isinstance(quest, FetchQuest): # if we just completed a fetch quest, we need to remove the required items for the quest self._remove_fetch_quest_required_items(quest) print(f'Quest {quest.name} is completed! XP awarded: {quest.xp_reward}!') if isinstance(item_reward, Item): print(f'{self.name} is awarded {item_reward.name} from the quest {quest.name}!') self.award_item(item_reward) elif isinstance(item_reward, list): for item in item_reward: print(f'{self.name} is awarded {item.name} from the quest {quest.name}!') self.award_item(item) del self.quest_log[quest.ID] # remove from quest log self.completed_quests.add(quest.ID) self._award_experience(xp_reward)
def generate_quests(source, items, rooms): """Returns a list of quests according to the specifications in a config file, (source). Source contains quest specifications of the form: reward | action | quest description | before_text | after_text | quest requirements | failure message | success message | quest location""" #Read the file for quests entered as a command line argument infile = open(source, "r") lines = [] while True: line = infile.readline() if line == "": break elif line == "\n": continue else: lines.append(line.strip()) infile.close() #Create quest objects (instances of the Quest class) that are appended to a list and returned. Check validity of rooms and rewards for quests and then assign the respective item/roomo object to the quest. total_quests = [] for quests in range(len(lines)): quest = lines[quests].split(" | ") if len(quest) != 9: sys.exit("Please specify a valid configuration file.") else: new_quest = Quest(quest[0], quest[1], quest[2], quest[3], quest[4], quest[5], quest[6], quest[7], quest[8]) new_quest.check_reward(items) new_quest.check_room(rooms) total_quests.append(new_quest) for room in range(len(rooms)): if new_quest.room.get_name() == rooms[room].get_name(): rooms[room].quest = new_quest return total_quests
class Game(): def __init__(self): logger.logger() logger.log("Initialization...") str_const.set_fracs_list() vk_session = vk_api.VkApi(token=vk_token.token) self.vk = vk_session.get_api() self.longpoll = VkLongPoll(vk_session, wait=const.wait) self.is_running = True #self.counter = 0 self.player = PlayerManager() self.database = LiteDB() self.quest = Quest() logger.log("Initialization complete!") def process(self): while self.is_running: self.quest.check_quest(self.vk, self.database) #logger.log("Begin check") events = self.longpoll.check() #logger.log("End check") if len(events) != 0: for i in range(len(events)): event = events[i] if event: self._proc_event(event) def _proc_event(self, event): if not event.from_me: if event.type == VkEventType.MESSAGE_NEW and event.text: random.seed() #---------------------------------------------------------------stop self.is_running = self.player.stop(self.vk, event) #---------------------------------------------------------------stop self.player.event_handling(self.vk, event, self.database, self.quest)
def make_quest(username, description, label, usernames): us = usernames[username] reward = 10 if label == 'hard': reward = 20 elif label == 'medium': reward = 15 # creating quest instance called task task = Quest(description, reward) # appending task to quest list us.add_quest(task)
def test_start_quest_if_already_started(self, questions_provider): questions_list = self.generate_questions_list() questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = True quest.current_question_number = 2 messages_list = quest.start_quest() self.assertEqual(quest.is_started, True) self.assertEqual(quest.get_current_question(), questions_provider.get_questions()[2]) self.assertEqual(quest.current_question_number, 2) self.assertEqual(len(messages_list), 1) self.assertEqual(messages_list[0].text, quest.messages['quest_already_started']) self.assertEqual(messages_list[0].as_reply, False)
def test_get_current_question_if_started(self, questions_provider): questions_list = self.generate_questions_list() q3 = questions_list[2] q3.get_question.return_value = q3.text questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = True quest.current_question_number = 2 messages_list = quest.get_question_text() self.assertEqual(quest.get_current_question(), questions_list[2]) self.assertEqual(quest.current_question_number, 2) self.assertEqual(len(messages_list), 2) self.assertEqual(messages_list[0].text, 'Question 3 of 3') self.assertEqual(messages_list[0].as_reply, False) self.assertEqual(messages_list[1].text, questions_list[2].get_question()) self.assertEqual(messages_list[1].as_reply, False)
def __init__(self, obstical_type, file_path, inital_position): pygame.sprite.Sprite.__init__(self) self.position = inital_position fps = 15 self.obstical_type = obstical_type self.file_path = file_path self.spritesheet = Spritesheet(self.file_path) # Size of rect for the first girl i found, this might be a parameter later self.rect = pygame.Rect(self.position[0], self.position[1], 40, 20) self.radius = 30 self.quest = Quest(obstical_type) # self..quest.speakables = [ # "This Drink Tastes Gross" # ] self.speak = Text_Display(self.quest.speak) self.animations = { "stand": [ Animation(self.spritesheet, fps, [(50, 0, 48, 48)]), Animation(self.spritesheet, fps, [(50, 55, 32, 48)]), Animation(self.spritesheet, fps, [(50, 102, 32, 48)]), Animation(self.spritesheet, fps, [(50, 151, 32, 48)]), ], "walk": [ Animation(self.spritesheet, fps, [(0, 7, 32, 48), (36, 7, 32, 48), (73, 7, 32, 48)]), Animation(self.spritesheet, fps, [(0, 55, 32, 48), (36, 55, 32, 48), (73, 55, 32, 48)]), Animation(self.spritesheet, fps, [(0, 102, 32, 48), (36, 102, 32, 48), (73, 102, 32, 48)]), Animation(self.spritesheet, fps, [(0, 151, 32, 48), (36, 151, 32, 48), (73, 151, 32, 48)]), ], } self.direction = NPC.SOUTH self.animation = NPC.STAND animation = self.animations[self.animation][self.direction] animation.updates(pygame.time.get_ticks()) self.image = animation.frame
def test_assess_answer_if_started_correct_answer(self, questions_provider): questions_list = self.generate_questions_list() q2 = questions_list[1] q2.assess_answer.return_value = (True, q2.success_message) questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) quest.is_started = True quest.current_question_number = 1 messages_list = quest.assess_answer(questions_list[1].answer) self.assertEqual(quest.get_current_question(), questions_list[2]) self.assertEqual(quest.current_question_number, 2) self.assertEqual(len(messages_list), 4) self.assertEqual(messages_list[0].text, questions_list[1].success_message) self.assertEqual(messages_list[0].as_reply, True) self.assertEqual(messages_list[1].text, quest.messages['correct_answer']) self.assertEqual(messages_list[1].as_reply, True) self.assertEqual(messages_list[2].text, 'Question 3 of 3') self.assertEqual(messages_list[2].as_reply, False) self.assertEqual(messages_list[3].text, questions_list[2].get_question()) self.assertEqual(messages_list[3].as_reply, False)
Lord([typeslist[2], typeslist[4]]), Lord([typeslist[2], typeslist[5]]), Lord([typeslist[3], typeslist[4]]), Lord([typeslist[3], typeslist[5]]), Lord([typeslist[4], typeslist[5]]), Lord([typeslist[0]]) ] def roll(): return random.randint(0, 5) quests = [ Quest(str(i), typeslist[random.randint(1, 5)], roll(), roll(), roll(), roll(), roll(), roll(), roll(), roll(), roll(), roll(), random.randint(0, 25)) for i in range(60) ] #players = [] def checkArgs(): return def main(): #shuffle decks using shuffle(deckobj, times) {for times random.shuffle(deck)} initializeGame() return
def test_init_with_valid_questions_provider(self, questions_provider): questions_list = self.generate_questions_list() questions_provider.get_questions.return_value = questions_list quest = Quest(questions_provider) self.assertEquals(quest.questions, questions_provider.get_questions())
class CommandQuest(Enum): slovo: list = [[Quest.get_quest_up(), 'up', 'вверх'], [Quest.get_quest_down(), 'down', 'вниз'], [Quest.get_quest_hello(), 'начать']]
def __init__(self, key: str, quest_name): super().__init__(key) self.quest = Quest.from_name(quest_name, self) self.data.quest_name = quest_name
def test_init_with_null_questions_provider(self): with self.assertRaises(AttributeError): quest = Quest(None)
class Game: def __init__(self, vision, controller, window): self.vision = vision self.controller = controller self.window = window self.current_resource = 2 self.train_troops = 0 self.state = State(vision, controller, window) self.gather = Gather(vision, self.state, controller) self.building = Building(vision, self.state, controller, window) self.quest = Quest(vision, controller) self.last_inf_check = 0 self.last_shelter_check = 0 def run(self): util.log("Starting MaggotBot!") while True and self.state != 'unknown': self.state.clean_state(turf=1) if self.vision.is_visible('dev_free', threshold=0.7): self.controller.click_object( self.vision.find_template('dev_free', threshold=0.7)) util.log('Finished research / building.') if self.vision.is_visible('dev_help', threshold=0.7): self.controller.click_object( self.vision.find_template('dev_help', threshold=0.7)) util.log('Requested help for research / building.') if time.time() - self.last_shelter_check > 300: self.building.to_building('shelter') util.log('Checking shelter.') if self.vision.is_visible('turf_shelter', threshold=0.675): self.controller.click_point( statics.buildings['shelter']['points']) time.sleep(1) self.controller.click_point(statics.shelter['hours']) time.sleep(0.3) self.controller.click_point(statics.shelter['ok']) time.sleep(0.75) self.controller.click_point(statics.shelter['clear']) time.sleep(0.3) self.controller.click_point(statics.shelter['grunt']) time.sleep(0.3) self.controller.click_point(statics.shelter['go']) time.sleep(1.25) self.vision.refresh_frame() self.last_shelter_check = time.time() util.log('Sheltered leader.') else: self.last_shelter_check = time.time() elif self.vision.is_visible('chest_collect', threshold=0.9): self.controller.click_point(statics.chest['chest']) if self.vision.is_visible('chest_5x', 0.8): util.log('Collected 5x free chest.') else: util.log('Collected free chest.') self.controller.click_point(statics.chest['claim']) elif self.vision.is_visible('hud_gift', threshold=0.7): self.controller.click_point(statics.hud['guild']) time.sleep(1.25) self.controller.click_point(statics.guild['tab1']) time.sleep(0.5) self.controller.click_point(statics.guild['gift']) time.sleep(0.5) self.vision.refresh_frame() while self.vision.is_visible('guild_open', threshold=0.7): self.controller.click_point(statics.guild['open']) time.sleep(0.5) self.controller.click_point(statics.guild['delete']) self.vision.refresh_frame() util.log('Collected guild gift.') elif not self.vision.is_visible('hud_army', threshold=0.8): util.log('Attempting to gather.') self.gather.gather() # elif self.vision.is_visible('barracks_idle') and self.train_troops == 1: # self.controller.click_object(self.vision.find_template('barracks_idle')) # time.sleep(1.25) # self.vision.refresh_frame() # if self.vision.is_visible('unit_ballista'): # self.controller.click_object(self.vision.find_template('unit_ballista')) # time.sleep(1.25) # self.vision.refresh_frame() # if self.vision.is_visible('barracks_train'): # self.controller.click_object(self.vision.find_template('barracks_train')) # self.vision.is_visible('quest_uncompleted') or elif (self.vision.is_visible('quest_has_q', threshold=0.8) or self.vision.is_visible( 'quest_has_completed', threshold=0.8)) and self.quest.time_lapsed(): self.quest.check_quests() elif self.vision.is_visible('dev_no_cr', threshold=0.8): self.building.upgrade() elif time.time() - self.last_inf_check > 300: self.building.to_building('infirmary') if self.vision.is_visible('turf_infirmary', threshold=0.65): self.controller.click_point( statics.buildings['infirmary']['points']) self.controller.click_point(statics.infirmary['heal']) util.log('Healing troops.') self.last_inf_check = time.time() time.sleep(1)
def quests(string): print() Quest.showCurrentQuests() print() return [True, False]
def init(): global gameOver global gameWin gameOver = False gameWin = False global dictOfCards global heroes global decks dictOfCards = {} heroes = [] decks = {} dictOfCards['Eowyn'] = Hero('Eowyn', 1, 1, 3, 4, 'Spirit', 9) dictOfCards['Eleanor'] = Hero('Eleanor', 1, 2, 3, 1, 'Spirit', 7) dictOfCards['Thalin'] = Hero('Thalin', 2, 2, 4, 1, 'Tactics', 9) dictOfCards['Wandering Took'] = Ally('Wandering Took', 1, 1, 2, 1, 'Spirit', 2) dictOfCards['Lorien Guide'] = Ally('Lorien Guide', 1, 1, 2, 0, 'Spirit', 3) dictOfCards['Northern Tracker'] = Ally('Northern Tracker', 2, 2, 3, 1, 'Spirit', 4) dictOfCards['Veteran Axehand'] = Ally('Veteran Axehand', 2, 1, 2, 0, 'Tactics', 2) dictOfCards['Gondorian Spearman'] = Ally('Gondorian Spearman', 1, 1, 1, 0, 'Tactics', 2) dictOfCards['Horseback Archer'] = Ally('Horseback Archer', 2, 1, 2, 0, 'Tactics', 3) dictOfCards['Beorn'] = Ally('Beorn', 3, 3, 6, 1, 'Tactics', 6) dictOfCards['Gandalf'] = Ally('Gandalf', 4, 4, 4, 4, 'Neutral', 5) dictOfCards['Flies and Spiders'] = Quest('Flies and Spiders', 'Passage through Mirkwood', 8) dictOfCards['A fork in the road'] = Quest('A fork in the road', 'Passage through Mirkwood', 2) dictOfCards['Beorns Path'] = Quest('Beorns Path', 'Passage through Mirkwood', 10) dictOfCards['Dol Guldur Orcs'] = Enemy('Dol Guldur Orcs', 2, 0, 3, 10, 2) dictOfCards['Chieftan Ufthak'] = Enemy('Chieftan Ufthak', 3, 3, 6, 35, 2) dictOfCards['Dol Guldur Beastmaster'] = Enemy('Dol Guldur Beastmaster', 3, 1, 5, 35, 2) dictOfCards['Necromancers Pass'] = Land('Necromancers Pass', 3, 2) dictOfCards['Enchanted Stream'] = Land('Enchanted Stream', 2, 2) dictOfCards['Forest Spider'] = Enemy('Forest Spider', 2, 1, 4, 25, 2) dictOfCards['Old Forest Road'] = Land('Old Forest Road', 1, 3) dictOfCards['East Bight Patrol'] = Enemy('East Bight Patrol', 3, 1, 2, 5, 3) dictOfCards['Black Forest Bats'] = Enemy('Black Forest Bats', 1, 0, 2, 15, 1) dictOfCards['Forest Gate'] = Land('Forest Gate', 2, 4) dictOfCards['King Spider'] = Enemy('King Spider', 3, 1, 3, 20, 2) dictOfCards['Hummerhorns'] = Enemy('Hummerhorns', 2, 0, 3, 40, 1) dictOfCards['Ungoliants Spawn'] = Enemy('Ungoliants Spawn', 5, 2, 9, 32, 3) dictOfCards['Great Forest Web'] = Land('Great Forest Web', 2, 2) dictOfCards['Mountains of Mirkwood'] = Land('Mountains of Mirkwood', 2, 3) heroes.append(dictOfCards['Eowyn']) heroes.append(dictOfCards['Eleanor']) heroes.append(dictOfCards['Thalin']) playerDeck = RegularDeck('Player Deck') playerDeck.addCard(dictOfCards['Wandering Took'], 3) playerDeck.addCard(dictOfCards['Lorien Guide'], 3) playerDeck.addCard(dictOfCards['Northern Tracker'], 3) playerDeck.addCard(dictOfCards['Veteran Axehand'], 3) playerDeck.addCard(dictOfCards['Gondorian Spearman'], 3) playerDeck.addCard(dictOfCards['Horseback Archer'], 3) playerDeck.addCard(dictOfCards['Beorn'], 1) playerDeck.addCard(dictOfCards['Gandalf'], 3) decks['Player Deck'] = playerDeck questDeck = QuestDeck('Passage through Mirkwood') questDeck.addCard(dictOfCards['Flies and Spiders'], 1) decks['Quest Deck'] = questDeck # encounterDeck = RegularDeck('Encounter Deck') # encounterDeck.addCard(dictOfCards['Dol Guldur Orcs'], 4) # encounterDeck.addCard(dictOfCards['Enchanted Stream'], 4) # encounterDeck.addCard(dictOfCards['Black Forest Bats'], 4) # encounterDeck.addCard(dictOfCards['Hummerhorns'], 4) # encounterDeck.addCard(dictOfCards['Old Forest Road'], 4) # encounterDeck.addCard(dictOfCards['Forest Spider'], 4) # encounterDeck.addCard(dictOfCards['East Bight Patrol'], 4) # decks['Encounter Deck'] = encounterDeck # ---------------- Full Version ----------------------------- # questDeck = QuestDeck('Passage through Mirkwood') # questDeck.addCard(dictOfCards['Flies and Spiders'], 1) # questDeck.addCard(dictOfCards['A fork in the road'], 1) # questDeck.addCard(dictOfCards['Beorns Path'], 1) # decks['Quest Deck'] = questDeck encounterDeck = RegularDeck('Encounter Deck') encounterDeck.addCard(dictOfCards['Dol Guldur Orcs'], 3) encounterDeck.addCard(dictOfCards['Chieftan Ufthak'], 1) encounterDeck.addCard(dictOfCards['Dol Guldur Beastmaster'], 2) encounterDeck.addCard(dictOfCards['Necromancers Pass'], 2) encounterDeck.addCard(dictOfCards['Enchanted Stream'], 2) encounterDeck.addCard(dictOfCards['Forest Spider'], 4) encounterDeck.addCard(dictOfCards['Old Forest Road'], 2) encounterDeck.addCard(dictOfCards['East Bight Patrol'], 1) encounterDeck.addCard(dictOfCards['Black Forest Bats'], 1) encounterDeck.addCard(dictOfCards['Forest Gate'], 2) encounterDeck.addCard(dictOfCards['King Spider'], 2) encounterDeck.addCard(dictOfCards['Hummerhorns'], 1) encounterDeck.addCard(dictOfCards['Ungoliants Spawn'], 1) encounterDeck.addCard(dictOfCards['Great Forest Web'], 2) encounterDeck.addCard(dictOfCards['Mountains of Mirkwood'], 3) decks['Encounter Deck'] = encounterDeck
def main(): settings_provider = BotSettingsProvider() questions_provider = QuestionsProviderPsql(settings_provider) quest = Quest(questions_provider) bot = BotContainer(settings_provider, BotLogic(quest)) bot.start()
def test_init_with_none_questions_list_in_questions_provider(self, questions_provider): questions_provider.get_questions.return_value = None with self.assertRaises(AttributeError): quest = Quest(None)
def npc_need(self, level): """Returns a need/job from the NPC""" quest = Quest(level) self.quest_type, self.job = quest.main()
def __tester_load_stat(): quest = Quest(qid=0, qtype='SIMPLE', priority='A', topics=list(), question='test', answer_true='a', answers_false=['b']) quest.load_stat(asked=0, answered=0, last_10=str(), last_time=1000) p0 = quest.grade = 100 quest = Quest(qid=0, qtype='SIMPLE', priority='B', topics=list(), question='test', answer_true='a', answers_false=['b']) quest.load_stat(asked=0, answered=0, last_10=str(), last_time=1000) p1 = quest.grade = 90 quest = Quest(qid=0, qtype='SIMPLE', priority='C', topics=list(), question='test', answer_true='a', answers_false=['b']) quest.load_stat(asked=1000, answered=1000, last_10='1111111111', last_time=0) p2 = quest.grade = 1 u_tester.run(p0, p1, p2)
class NPC(pygame.sprite.Sprite): # Directions NORTH = 3 EAST = 2 SOUTH = 0 WEST = 1 # Define the Animations STAND = "stand" WALK = "walk" def __init__(self, obstical_type, file_path, inital_position): pygame.sprite.Sprite.__init__(self) self.position = inital_position fps = 15 self.obstical_type = obstical_type self.file_path = file_path self.spritesheet = Spritesheet(self.file_path) # Size of rect for the first girl i found, this might be a parameter later self.rect = pygame.Rect(self.position[0], self.position[1], 40, 20) self.radius = 30 self.quest = Quest(obstical_type) # self..quest.speakables = [ # "This Drink Tastes Gross" # ] self.speak = Text_Display(self.quest.speak) self.animations = { "stand": [ Animation(self.spritesheet, fps, [(50, 0, 48, 48)]), Animation(self.spritesheet, fps, [(50, 55, 32, 48)]), Animation(self.spritesheet, fps, [(50, 102, 32, 48)]), Animation(self.spritesheet, fps, [(50, 151, 32, 48)]), ], "walk": [ Animation(self.spritesheet, fps, [(0, 7, 32, 48), (36, 7, 32, 48), (73, 7, 32, 48)]), Animation(self.spritesheet, fps, [(0, 55, 32, 48), (36, 55, 32, 48), (73, 55, 32, 48)]), Animation(self.spritesheet, fps, [(0, 102, 32, 48), (36, 102, 32, 48), (73, 102, 32, 48)]), Animation(self.spritesheet, fps, [(0, 151, 32, 48), (36, 151, 32, 48), (73, 151, 32, 48)]), ], } self.direction = NPC.SOUTH self.animation = NPC.STAND animation = self.animations[self.animation][self.direction] animation.updates(pygame.time.get_ticks()) self.image = animation.frame def turn_towards_player(self, player_position): # These direction are not great yet, should probly be in npc as a function if player_position[0] < self.position[0]: self.direction = NPC.WEST self.animation = NPC.STAND elif player_position[0] > self.position[0]: self.direction = NPC.EAST self.animation = NPC.STAND elif player_position[1] < self.position[1]: self.direction = NPC.NORTH self.animation = NPC.STAND elif player_position[1] > self.position[1]: self.direction = NPC.SOUTH self.animation = NPC.STAND self.update() def update(self): """ Creates the animation of the npc occolating. Called in process_events in main """ animation = self.animations[self.animation][self.direction] animation.updates(pygame.time.get_ticks()) self.image = animation.frame # self.rect = animation.rect self.rect.x = self.position[0] self.rect.y = self.position[1] def action_advance(self): self.quest.progress_quest() self.speak = Text_Display(self.quest.speak) return self.speak