def _fulfill(self, data): """ Wordt aangeroepen als hij (gedeeltelijk) de items inlevert. :param data: self.engine.data """ itemcounter = 0 for key, value in self.condition.items(): if key.startswith('eqp'): pass # todo, dit is dus nog niet geimplementeerd. staat ook een notitie van bij quest6. elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) itm_qty = data.pouch.get_quantity( itm_obj) # de hoeveelheid die je bezit if itm_qty: # als het aantal groter is dan 0 if itm_qty >= value[ 'qty']: # als het item en aantal kloppen data.pouch.remove( itm_obj, value['qty']) # haal de gevraagde hoeveelheid weg itemcounter += value[ 'qty'] # en doe het aantal bij de counter elif itm_qty < value[ 'qty']: # maar als minder is dan de gevraagde hoeveelheid data.pouch.remove( itm_obj, itm_qty) # haal dan alles wat je wel hebt weg itemcounter += itm_qty # en doe het aantal bij de counter # todo, er mag nog alleen maar een reward van 'itm1' zijn. dat moet universeler uiteindelijk self.reward['itm1'][ 'qty'] *= itemcounter # zet alles om naar de beloning
def on_enter(self): """ Als een hero confirmbox in beeld is geweest. Als de inn confirmbox in beeld is geweest. Als de quest confirmbox in beeld is geweest. """ if self.hero_box: choice = self.hero_box.cur_item yes = self.hero_box.TOPINDEX scr_capt = self.hero_box.scr_capt hero_object = self.hero_box.callback if choice == yes: if self.engine.data.party.add(hero_object): self.engine.audio.play_sound(SFX.join) self.engine.key_timer = NEWMAPTIMEOUT self.load_map() self.engine.gamestate.push(Transition()) else: text = HeroDatabase.closing() push_object = MessageBox(text, face_image=hero_object.FAC, scr_capt=scr_capt, last=True) self.engine.gamestate.push(push_object) else: self.engine.audio.play_sound(SFX.done) self.hero_box = None elif self.inn_box: choice = self.inn_box.cur_item yes = self.inn_box.TOPINDEX scr_capt = self.inn_box.scr_capt inn_enum_val = self.inn_box.callback if choice == yes: gold = inventoryitems.factory_pouch_item(PouchItemDatabase.gold) if self.engine.data.pouch.remove(gold, inn_enum_val['price']): self.engine.gamestate.push(Transition()) push_object = MessageBox(InnDatabase.paid_text(), face_image=inn_enum_val['face'], scr_capt=scr_capt, sound=SFX.coins, last=True) self.engine.gamestate.push(push_object) for hero in self.party: hero.recover_full_hp() else: push_object = MessageBox(InnDatabase.fail_text(), face_image=inn_enum_val['face'], scr_capt=scr_capt, last=True) self.engine.gamestate.push(push_object) else: push_object = MessageBox(InnDatabase.deny_text(), face_image=inn_enum_val['face'], scr_capt=scr_capt, last=True) self.engine.gamestate.push(push_object) self.inn_box = None elif self.quest_box: person_enum_val = self.quest_box.callback the_quest = PeopleDatabase.get_active_quest(person_enum_val['quest'], self.engine.data.logbook) the_quest.decided(self.engine.gamestate, self.engine.data, self.engine.audio, person_enum_val['face'], self.quest_box.cur_item, self.quest_box.TOPINDEX, self.quest_box.scr_capt, self.display_loot) self.quest_box = None
def _fill_table_data(self, potion_database, hero_alc_skill): for potion in potion_database: potion_obj = inventoryitems.factory_pouch_item(potion) percentage = str(hero_alc_skill.get_percentage( potion_obj.ALC)) + " %" self.table_data.append( # row[0], row[1], row[2], row[3], row[4] [potion_obj.SPR, potion_obj.NAM, percentage, None, potion_obj])
def __init__(self, engine, shoptype_list, shopmaterial_list, face): super().__init__(engine, "Buy", "Sell") # is een list van bijv: [EquipmentType.arm, WeaponType.swd] self.subtype_list = list(shoptype_list) # het moet een kopie van de lijst zijn, niet de lijst zelf, # vanwege de _init_selectors(), waar iets uit de lijst vervangen wordt. door een kopie te maken kan dat. self.material_list = shopmaterial_list self.databases = {} self.name = GameState.Shop self.main_title_pos_x = 1 / 16 self.main_title_pos_y = 1 / 32 self.source_title1 = SOURCETITLE1 self.source_title1_pos_x = 1 / 16 self.source_title1_pos_y = 11 / 16 self.sub_title_pos_x = 5 self.sub_title_pos_y1 = 15 / 100 self.sub_title_pos_y2 = 17 / 100 self.face_pos_x = 1 / 16 self.face_pos_y = 3 / 16 self.extra_face_size_x = 20 self.extra_face_size_y = 20 self.lines_next_to_face = 3 self.small_line_height = 30 self.leftbox_width = 3 / 16 self.leftbox_height = 73 / 100 self.leftbox_pos_x = 2 / 5 self.leftbox_pos_y = 6 / 32 self.rightbox_width = 5 / 16 self.rightbox_height = 73 / 100 self.rightbox_pos_x = 15 / 24 self.rightbox_pos_y = 6 / 32 self.infobox_width = 1 / 4 self.infobox_height = 1 / 6 self.infobox_pos_x = 1 / 16 self.infobox_pos_y = 6 / 8 self.selector_pos_x = 2 / 32 self.selector_pos_y = 20 / 32 self.selector_width = 36 self.gold_amount = None self.gold_object = inventoryitems.factory_pouch_item(PouchItemDatabase.gold) self.sum_merchant = self.engine.data.party.get_sum_value_of_skill("mer") self._init_face_and_text(face, ShopDatabase.welcome_text()) self._init_selectors() self.subtype = self.subtype_list[0] # subtype declaratie verplaatst van bovenin naar onder _init_selectors() # omdat in de init_selectors() de subtype_list wordt aangepast naar een juist formaat. dat heeft te maken met # pouchitems die verkocht kunnen worden. die staan namelijk nog een tuple ipv rechtstreeks database. self._init_boxes() self._init_buttons() self._reset_vars()
def __init__(self, engine, skilltype_list, face): super().__init__(engine, "Train", "Known") self.skilltypes = skilltype_list self.subtype_list = list(self.engine.data.party.values()) self.subtype = self.subtype_list[0] self.name = GameState.Shop self.main_title_pos_x = 1 / 16 self.main_title_pos_y = 1 / 32 self.source_title1 = SOURCETITLE1 self.source_title1_pos_x = 1 / 16 self.source_title1_pos_y = 39 / 64 self.source_title2 = SOURCETITLE2 self.source_title2_pos_x = 1 / 16 self.source_title2_pos_y = 42 / 64 self.sub_title_pos_x = 5 self.sub_title_pos_y1 = 15 / 100 self.sub_title_pos_y2 = 17 / 100 self.face_pos_x = 1 / 16 self.face_pos_y = 3 / 16 self.extra_face_size_x = 20 self.extra_face_size_y = 20 self.lines_next_to_face = 3 self.small_line_height = 30 self.leftbox_width = 9 / 32 self.leftbox_height = 24 / 32 self.leftbox_pos_x = 2 / 5 self.leftbox_pos_y = 6 / 32 self.rightbox_width = 7 / 32 self.rightbox_height = 24 / 32 self.rightbox_pos_x = 23 / 32 self.rightbox_pos_y = 6 / 32 self.infobox_width = 8 / 32 self.infobox_height = 7 / 32 self.infobox_pos_x = 2 / 32 self.infobox_pos_y = 23 / 32 self.selector_pos_x = 2 / 32 self.selector_pos_y = 18 / 32 self.selector_width = 36 self.gold_amount = None self.gold_object = inventoryitems.factory_pouch_item( PouchItemDatabase.gold) self.xp_amount = None self._init_face_and_text(face, TrainerDatabase.welcome_text()) self._init_selectors() self._init_boxes() self._init_buttons() self._reset_vars()
def __init__(self, engine, schooltype_list, face): super().__init__(engine, "Learn", "Known") self.schooltypes = schooltype_list self.subtype_list = list(self.engine.data.party.values()) self.subtype = self.subtype_list[0] self.name = GameState.Shop self.main_title_pos_x = 1 / 16 self.main_title_pos_y = 1 / 32 self.source_title1 = SOURCETITLE1 self.source_title1_pos_x = 1 / 16 self.source_title1_pos_y = 39 / 64 self.source_title2 = SOURCETITLE2 self.source_title2_pos_x = 1 / 16 self.source_title2_pos_y = 42 / 64 self.sub_title_pos_x = 5 self.sub_title_pos_y1 = 15 / 100 self.sub_title_pos_y2 = 17 / 100 self.face_pos_x = 1 / 16 self.face_pos_y = 3 / 16 self.extra_face_size_x = 20 self.extra_face_size_y = 20 self.lines_next_to_face = 3 self.small_line_height = 30 self.leftbox_width = 9 / 32 self.leftbox_height = 24 / 32 self.leftbox_pos_x = 2 / 5 self.leftbox_pos_y = 6 / 32 self.rightbox_width = 7 / 32 self.rightbox_height = 24 / 32 self.rightbox_pos_x = 23 / 32 self.rightbox_pos_y = 6 / 32 self.infobox_width = 8 / 32 self.infobox_height = 7 / 32 self.infobox_pos_x = 2 / 32 self.infobox_pos_y = 23 / 32 self.selector_pos_x = 2 / 32 self.selector_pos_y = 18 / 32 self.selector_width = 36 self.gold_amount = None self.gold_object = inventoryitems.factory_pouch_item(PouchItemDatabase.gold) self.xp_amount = None self._init_face_and_text(face, SchoolDatabase.welcome_text()) self._init_selectors() self._init_boxes() self._init_buttons() self._reset_vars()
def new_game(data, debug_mode): """ Wat te doen bij het starten van een nieuw spel. :param debug_mode: :param data: self.engine.data """ # Vul de heroes database met alle hero objecten die in factory zijn gemaakt. data.heroes = characters.factory_all_heroes(HeroDatabase) data.logbook = inventoryitems.factory_all_quests(QuestDatabase) # Treasure chest en Sparklies worden geen losse objecten, maar blijven 1 object met meerdere dicts. data.treasure_chests = database.factory(TreasureChestDatabase) data.sparklies = database.factory(SparklyDatabase) data.chapters = database.factory(ChapterDatabase) data.move_events = database.factory(MoveEventDatabase) data.text_events = database.factory(TextEventDatabase) # Vul de party aan met de eerste hero data.party.add(data.heroes['alagos'], verbose=False) eqp_item = inventoryitems.factory_equipment_item(WeaponDatabase.bronzemace) data.inventory.add_i(eqp_item, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.gold) data.pouch.add(pouch_item, 1, verbose=False) if debug_mode: #### todo, tijdelijk data.pouch.add(pouch_item, 900, verbose=False) data.heroes['alagos'].gain_experience(999) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.herbs) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.spices) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.gemstones) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.cloth) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.leather) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.wood) data.pouch.add(pouch_item, 999, verbose=False) pouch_item = inventoryitems.factory_pouch_item(PouchItemDatabase.metals) data.pouch.add(pouch_item, 999, verbose=False) #################### data.map_name = 'ersin_forest_center' data.map_pos = 'start_game' # dit is de naam van de startpositie object in de tmx map data.map_dir = Direction.South data.custom_inventory_counter = 0
def _fulfill(self, data): """ Wordt aangeroepen als hij weet dat hij kàn voldoen. Je geeft de conditions. :param data: self.engine.data """ for key, value in self.condition.items(): if key.startswith('eqp'): eqp_obj = inventoryitems.factory_equipment_item(value['nam']) data.inventory.remove_i(eqp_obj, value['qty']) elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) data.pouch.remove(itm_obj, value['qty'])
def _fulfill(self, data): """ Wordt aangeroepen als hij weet dat hij kàn voldoen. Je geeft de conditions. :param data: self.engine.data """ for key, value in self.condition.items(): if key.startswith('eqp'): eqp_obj = inventoryitems.factory_equipment_item(value['nam']) data.inventory.remove_i(eqp_obj, value['qty']) elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) data.pouch.remove(itm_obj, value['qty'])
def _is_ready_to_fulfill(self, data): """ Bekijkt of hij voldoet aan de condition van de quest. :param data: self.engine.data :return: Als alle conditions goed zijn geeft hij True terug. """ all_items = [] for key, value in self.condition.items(): if key.startswith('eqp'): eqp_obj = inventoryitems.factory_equipment_item(value['nam']) all_items.append(data.inventory.contains(eqp_obj, value['qty'])) elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) all_items.append(data.pouch.contains(itm_obj, value['qty'])) return all(all_items)
def _is_ready_to_fulfill(self, data): """ Bekijkt of hij voldoet aan de condition van de quest. :param data: self.engine.data :return: Als alle conditions goed zijn geeft hij True terug. """ all_items = [] for key, value in self.condition.items(): if key.startswith('eqp'): eqp_obj = inventoryitems.factory_equipment_item(value['nam']) all_items.append(data.inventory.contains( eqp_obj, value['qty'])) elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) all_items.append(data.pouch.contains(itm_obj, value['qty'])) return all(all_items)
def _fill_table_data(self, equipment_database): for equipment_item in equipment_database.values(): # speciaal alleen voor pouchitems if equipment_item.value['typ'] == EquipmentType.itm: pouch_item_obj = inventoryitems.factory_pouch_item( equipment_item) pouch_item_spr = pygame.image.load( pouch_item_obj.SPR).convert_alpha() pouch_item_nam = pouch_item_obj.NAM pouch_item_val = str( round(pouch_item_obj.VAL - ((pouch_item_obj.VAL / 100) * self.sale))) self.table_data.append( # row[0], row[1], row[2], row[3], row[4] [ pouch_item_spr, pouch_item_nam, pouch_item_val, None, pouch_item_obj ]) else: if equipment_item.value['shp']: equipment_item_obj = inventoryitems.factory_equipment_item( equipment_item) equipment_item_spr = pygame.image.load( equipment_item_obj.SPR).subsurface( equipment_item_obj.COL, equipment_item_obj.ROW, self.subsurw, self.subsurh).convert_alpha() equipment_item_nam = equipment_item_obj.NAM equipment_item_val = str( round(equipment_item_obj.VAL - ((equipment_item_obj.VAL / 100) * self.sale))) self.table_data.append( # row[0], row[1], row[2], row[3], row[4] [ equipment_item_spr, equipment_item_nam, equipment_item_val, None, equipment_item_obj ])
def _handle_leftbox_click(self, event): heal_click, selected_hero = self.leftbox.mouse_click(event) if heal_click: if self.cur_hero.sta.cur < self.cur_hero.hlr.STA_COST: text = ["{} does not have enough stamina".format(self.cur_hero.NAM), "to heal {}.".format(selected_hero.NAM)] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif selected_hero.cur_hp >= selected_hero.max_hp: text = ["{} already at max health.".format(selected_hero.NAM)] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True if self.subtype == HealingType.herbs: herbs = inventoryitems.factory_pouch_item(PouchItemDatabase.herbs) hrb_qty = self.engine.data.pouch.get_quantity(herbs) if self.cur_hero.hlr.HRB_COST > hrb_qty: text = ["You do not have the right components", "to perform that action."] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True self.engine.data.pouch.remove(herbs, self.cur_hero.hlr.HRB_COST) self.cur_hero.sta.cur -= self.cur_hero.hlr.STA_COST healpoints = self.cur_hero.hlr.get_healpoints(self.subtype) old_hp = selected_hero.cur_hp selected_hero.recover_part_hp(healpoints) new_hp = selected_hero.cur_hp healpoints = new_hp - old_hp text = ["{} heals {} by {}.".format(self.cur_hero.NAM, selected_hero.NAM, healpoints)] push_object = MessageBox(text) self.engine.gamestate.push(push_object) self._init_boxes() return True return False
def _fulfill(self, data): """ Wordt aangeroepen als hij (gedeeltelijk) de items inlevert. :param data: self.engine.data """ itemcounter = 0 for key, value in self.condition.items(): if key.startswith('eqp'): pass # todo, dit is dus nog niet geimplementeerd. staat ook een notitie van bij quest6. elif key.startswith('itm'): itm_obj = inventoryitems.factory_pouch_item(value['nam']) itm_qty = data.pouch.get_quantity(itm_obj) # de hoeveelheid die je bezit if itm_qty: # als het aantal groter is dan 0 if itm_qty >= value['qty']: # als het item en aantal kloppen data.pouch.remove(itm_obj, value['qty']) # haal de gevraagde hoeveelheid weg itemcounter += value['qty'] # en doe het aantal bij de counter elif itm_qty < value['qty']: # maar als minder is dan de gevraagde hoeveelheid data.pouch.remove(itm_obj, itm_qty) # haal dan alles wat je wel hebt weg itemcounter += itm_qty # en doe het aantal bij de counter # todo, er mag nog alleen maar een reward van 'itm1' zijn. dat moet universeler uiteindelijk self.reward['itm1']['qty'] *= itemcounter # zet alles om naar de beloning
def display_loot(self, content_data, text, image): """ Soort van static method. geeft alleen de gevraagde dingen terug. :return: geeft de tekst en de plaatjes terug voor een messagebox """ for key, value in content_data.items(): if key.startswith('eqp'): equipment_item = inventoryitems.factory_equipment_item(value['nam']) equipment_item_spr = pygame.image.load(equipment_item.SPR).subsurface( equipment_item.COL, equipment_item.ROW, ICONSIZE, ICONSIZE).convert_alpha() self.engine.data.inventory.add_i(equipment_item, quantity=value['qty']) text.append("{} {}".format(value['qty'], equipment_item.NAM)) image.append(equipment_item_spr) elif key.startswith('itm'): pouch_item = inventoryitems.factory_pouch_item(value['nam']) pouch_item_spr = pygame.image.load(pouch_item.SPR).convert_alpha() # bij een quest kàn de beloning 0 zijn, dat gaat fout met een error als je het toch toevoegd. # vandaar deze voorwaarde. Je krijgt dan wel 0 te zien als de 'toegevoegde' beloning. if value['qty'] > 0: self.engine.data.pouch.add(pouch_item, quantity=value['qty']) text.append("{} {}".format(value['qty'], pouch_item.NAM)) image.append(pouch_item_spr) return text, image
def _handle_leftbox_click(self, event): create_click, selected_equipment = self.leftbox.mouse_click(event) if create_click: cloth = inventoryitems.factory_pouch_item(PouchItemDatabase.cloth) leather = inventoryitems.factory_pouch_item( PouchItemDatabase.leather) wood = inventoryitems.factory_pouch_item(PouchItemDatabase.wood) metals = inventoryitems.factory_pouch_item( PouchItemDatabase.metals) clt_qty = self.engine.data.pouch.get_quantity(cloth) ltr_qty = self.engine.data.pouch.get_quantity(leather) wod_qty = self.engine.data.pouch.get_quantity(wood) mtl_qty = self.engine.data.pouch.get_quantity(metals) if selected_equipment.CLT > clt_qty or \ selected_equipment.LTR > ltr_qty or \ selected_equipment.WOD > wod_qty or \ selected_equipment.MTL > mtl_qty: text = [ "You do not have the right components", "to create that {}.".format(selected_equipment.NAM) ] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif self.cur_hero.sta.cur < self.cur_hero.mec.STA_COST: text = [ "{} does not have enough stamina".format( self.cur_hero.NAM), "to create that {}.".format(selected_equipment.NAM) ] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif 'pouch is full' is False: # todo, moet 'pouch is vol' hier? of in pouch? self.engine.audio.play_sound(SFX.menu_cancel) return True self.engine.data.pouch.remove(cloth, selected_equipment.CLT, force=True) # want kan ook 0 zijn. self.engine.data.pouch.remove(leather, selected_equipment.LTR, force=True) self.engine.data.pouch.remove(wood, selected_equipment.WOD, force=True) self.engine.data.pouch.remove(metals, selected_equipment.MTL, force=True) self.cur_hero.sta.cur -= self.cur_hero.mec.STA_COST # hoog het custom nummer op en zet die achter de .RAW zodat er meerdere customs in de inventory kunnen self.engine.data.custom_inventory_counter += 1 selected_equipment.RAW += str( self.engine.data.custom_inventory_counter) # loop door alle attributen van selected_equipment heen # list(), zodat uit de iterate verwijderd kan worden for attr, value in list(vars(selected_equipment).items()): # als er een waarde van een attribute op 'X' vanuit de database staat, # dat betekent dat hij nog gevuld moet worden. if value == 'X': # wat is de waarde van de gelijknamige attribute met 'MIN_' ervoor min_value = getattr(selected_equipment, 'MIN_' + attr) max_value = getattr(selected_equipment, 'MAX_' + attr) # vraag bij de Mechanic Skill de berekende waarden op. en zet attribute op die waarde. setattr( selected_equipment, attr, self.cur_hero.mec.get_eqp_itm_attr_value( min_value, max_value)) # en verwijder de overblijfselen delattr(selected_equipment, 'MIN_' + attr) delattr(selected_equipment, 'MAX_' + attr) text = ["{} successfully created.".format(selected_equipment.NAM)] self.engine.data.inventory.add_i(selected_equipment) push_object = MessageBox(text) self.engine.gamestate.push(push_object) self._init_boxes() return True return False
def _handle_leftbox_click(self, event): create_click, selected_equipment = self.leftbox.mouse_click(event) if create_click: cloth = inventoryitems.factory_pouch_item(PouchItemDatabase.cloth) leather = inventoryitems.factory_pouch_item(PouchItemDatabase.leather) wood = inventoryitems.factory_pouch_item(PouchItemDatabase.wood) metals = inventoryitems.factory_pouch_item(PouchItemDatabase.metals) clt_qty = self.engine.data.pouch.get_quantity(cloth) ltr_qty = self.engine.data.pouch.get_quantity(leather) wod_qty = self.engine.data.pouch.get_quantity(wood) mtl_qty = self.engine.data.pouch.get_quantity(metals) if selected_equipment.CLT > clt_qty or \ selected_equipment.LTR > ltr_qty or \ selected_equipment.WOD > wod_qty or \ selected_equipment.MTL > mtl_qty: text = ["You do not have the right components", "to create that {}.".format(selected_equipment.NAM)] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif self.cur_hero.sta.cur < self.cur_hero.mec.STA_COST: text = ["{} does not have enough stamina".format(self.cur_hero.NAM), "to create that {}.".format(selected_equipment.NAM)] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif 'pouch is full' is False: # todo, moet 'pouch is vol' hier? of in pouch? self.engine.audio.play_sound(SFX.menu_cancel) return True self.engine.data.pouch.remove(cloth, selected_equipment.CLT, force=True) # want kan ook 0 zijn. self.engine.data.pouch.remove(leather, selected_equipment.LTR, force=True) self.engine.data.pouch.remove(wood, selected_equipment.WOD, force=True) self.engine.data.pouch.remove(metals, selected_equipment.MTL, force=True) self.cur_hero.sta.cur -= self.cur_hero.mec.STA_COST # hoog het custom nummer op en zet die achter de .RAW zodat er meerdere customs in de inventory kunnen self.engine.data.custom_inventory_counter += 1 selected_equipment.RAW += str(self.engine.data.custom_inventory_counter) # loop door alle attributen van selected_equipment heen # list(), zodat uit de iterate verwijderd kan worden for attr, value in list(vars(selected_equipment).items()): # als er een waarde van een attribute op 'X' vanuit de database staat, # dat betekent dat hij nog gevuld moet worden. if value == 'X': # wat is de waarde van de gelijknamige attribute met 'MIN_' ervoor min_value = getattr(selected_equipment, 'MIN_'+attr) max_value = getattr(selected_equipment, 'MAX_'+attr) # vraag bij de Mechanic Skill de berekende waarden op. en zet attribute op die waarde. setattr(selected_equipment, attr, self.cur_hero.mec.get_eqp_itm_attr_value(min_value, max_value)) # en verwijder de overblijfselen delattr(selected_equipment, 'MIN_'+attr) delattr(selected_equipment, 'MAX_'+attr) text = ["{} successfully created.".format(selected_equipment.NAM)] self.engine.data.inventory.add_i(selected_equipment) push_object = MessageBox(text) self.engine.gamestate.push(push_object) self._init_boxes() return True return False
def condition11(self, data): import inventoryitems from .pouchitem import PouchItemDatabase negen_kleuren = inventoryitems.factory_pouch_item( PouchItemDatabase.kleuren_drankje) return data.pouch.contains(negen_kleuren, 1)
def condition5(self, data): import inventoryitems from .pouchitem import PouchItemDatabase recept1 = inventoryitems.factory_pouch_item(PouchItemDatabase.recept1) return data.pouch.contains(recept1, 1)
def _handle_leftbox_click(self, event): create_click, selected_potion = self.leftbox.mouse_click(event) if create_click: herbs = inventoryitems.factory_pouch_item(PouchItemDatabase.herbs) spices = inventoryitems.factory_pouch_item( PouchItemDatabase.spices) gemstones = inventoryitems.factory_pouch_item( PouchItemDatabase.gemstones) hrb_qty = self.engine.data.pouch.get_quantity(herbs) spc_qty = self.engine.data.pouch.get_quantity(spices) gms_qty = self.engine.data.pouch.get_quantity(gemstones) if selected_potion.HRB > hrb_qty or \ selected_potion.SPC > spc_qty or \ selected_potion.GMS > gms_qty: text = [ "You do not have the right components", "to create that {}.".format(selected_potion.NAM) ] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif self.cur_hero.sta.cur < self.cur_hero.alc.STA_COST: text = [ "{} does not have enough stamina".format( self.cur_hero.NAM), "to create that {}.".format(selected_potion.NAM) ] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) return True elif 'pouch is full' is False: # todo, moet 'pouch is vol' hier? of in pouch? self.engine.audio.play_sound(SFX.menu_cancel) return True self.engine.data.pouch.remove(herbs, selected_potion.HRB, force=True) # want kan ook 0 zijn. self.engine.data.pouch.remove(spices, selected_potion.SPC, force=True) self.engine.data.pouch.remove(gemstones, selected_potion.GMS, force=True) self.cur_hero.sta.cur -= self.cur_hero.alc.STA_COST rnd_percentage = random.randint(1, 100) potion_chance = self.cur_hero.alc.get_percentage( selected_potion.ALC) if potion_chance >= rnd_percentage: text = ["{} successfully created.".format(selected_potion.NAM)] self.engine.data.pouch.add(selected_potion) push_object = MessageBox(text) self.engine.gamestate.push(push_object) else: text = ["Failed to create a {}.".format(selected_potion.NAM)] push_object = MessageBox(text, sound=SFX.menu_cancel) self.engine.gamestate.push(push_object) self._init_boxes() return True return False