def heal(user, source_of_effect, dict_results, events): # source of effect is an item_component for now. power = source_of_effect.power target = dict_results.get("requested") if target.fighter.hp == target.fighter.max_hp: return { "consume_item": False, "message": Texts.get_text('FULL_HEAL_ALREADY'), "color": color_config.FULL_HEAL_ALREADY, } else: events.add_event( { "message": Texts.get_text('CHAR_DRINKS_SOMETHING').format( target.name, source_of_effect.owner.name ), "color": color_config.THROW_ITEM_COLOR, } ) target.fighter.heal(power) return { "consume_item": True, "message": Texts.get_text('WOUND_HEALED'), "color": color_config.WOUND_HEALED, }
def do_damage(self, target, damage, events): # get hit retourne les dmg modifiés par les effets se trouvant sur la Target. modified_damage = target.fighter.get_hit(self, damage, events) if modified_damage <= 0: events.add_event( { "message": Texts.get_text('CHAR_ATTACKS_OTHER_NO_DAMAGE').format( self.owner.name.capitalize(), target.name ), "color": color_config.NO_DAMAGE_ATTACK, } ) else: events.add_event( { "message": Texts.get_text('CHAR_ATTACKS_OTHER_WITH_DAMAGE').format( self.owner.name.capitalize(), target.name, str(modified_damage) ), "color": color_config.DAMAGING_ATTACK, } ) # take_damage joue de potentiels effets dû à des dmg. target.fighter.take_damage(self, modified_damage, events)
def __init__(self, app): super().__init__(app) self.header = Texts.get_text('QUIT_GAME_MENU_HEADER') self._options = [ Texts.get_text('YES_ANSWER'), Texts.get_text('NO_ANSWER') ] self.back_to_main = False
def update_options(self): self.header = Texts.get_text('LEVEL_UP_MENU_HEADER').format( self.source.level.available_stat_points ) self.display_options = [Texts.get_text('MIGHT_GAME_TERM'), Texts.get_text('DEXTERITY_GAME_TERM'), Texts.get_text('VITALITY_GAME_TERM') ] self._options = ["Might", 'Dexterity', "Vitality"]
def slot_to_text(slot): if slot == EquipmentSlot.MAIN_HAND: return Texts.get_text('EQUIPMENT_SLOT_MAIN_HAND') elif slot == EquipmentSlot.OFF_HAND: return Texts.get_text('EQUIPMENT_SLOT_OFF_HAND') elif slot == EquipmentSlot.NECK: return Texts.get_text('EQUIPMENT_SLOT_NECK') elif slot == EquipmentSlot.CHEST: return Texts.get_text('EQUIPMENT_SLOT_CHEST') return Texts.get_text('EQUIPMENT_SLOT_NONE')
def __init__(self, source): super().__init__(source) self.type = MenuType.GRAPHIC self.title = "CURSED FOREST" self.header = "" self.background_image = libtcod.image_load("menu_background.png") self.display_options = [Texts.get_text('MAIN_MENU_NEW_GAME'), Texts.get_text('MAIN_MENU_LOAD_GAME'), Texts.get_text('MAIN_MENU_LANGUAGES'), Texts.get_text('MAIN_MENU_QUIT')] self._options = ["new game", "load game", "languages", "quit"] self.forced_width = 24
def __init__(self): super().__init__() self.type = MenuType.GRAPHIC self.title = Texts.get_text('VICTORY_1_TITLE') self.header = (""" """ + Texts.get_text('VICTORY_1_PART_1') + ' \n' + Texts.get_text('VICTORY_1_PART_2') + '\n' + """ """) self.background_image = libtcod.image_load("menu_background.png") self._options = [] self.forced_width = 48 self.back_to_main = True
def __init__(self, source): super().__init__(source) self.type = MenuType.GRAPHIC self.title = app_config.APP_TITLE self.header = "Welcome" self.info = app_config.VERSION self.background_image = './medias/creepy_wood.jpg' self.display_options = [ Texts.get_text('MAIN_MENU_NEW_GAME'), Texts.get_text('MAIN_MENU_LOAD_GAME'), Texts.get_text('MAIN_MENU_LANGUAGES'), Texts.get_text('MAIN_MENU_QUIT') ] self._options = ["new game", "load game", "languages", "quit"] self.forced_width = 24
def __init__(self, source): super().__init__(source) self.source = source self.header = Texts.get_text('MENU_CHOOSE_LANGUAGE') self.display_options = list(Texts.get_available_languages()) self._options = list(Texts.get_available_languages()) self.forced_width = 24
def __init__(self, player, game, target_source, target_type): super().__init__(game, player.x, player.y, "+", libtcod.white, "Target") self.target_source = target_source self.function_on_validate = target_source.use_function self.player = player self.game_map = game.dungeon.current_map self.render_order = RenderOrder.TARGET self.target_type = target_type self.game_map.add_entity(self) if self.target_type == TargetType.NONE: self.game.events.add_event({ "message": Texts.get_text('TARGET_TYPE_INVALID'), "color": color_config.TARGET_MESS_COLOR, }) self.quit_target_mode() elif self.target_type == TargetType.SELF: # on lance directement l effet sur soit, sans selection possible. self.play_function_on_target({ "requested": self.player, "not_requested": [], "tile": self.get_map_tile(self.x, self.y), }) else: self.warning()
def kill_monster(monster, attacker, events): events.add_event({ "message": Texts.get_text('CHAR_IS_DEAD').format(monster.name.capitalize()), "color": color_config.HOSTILE_KILLED, }) become_corpse(monster)
def update_options(self): self.header = ( ' {} '.format(self.source.name) + " - " + Texts.get_text('LEVEL_GAME_TERM') + ' {}'.format(self.source.level.current_level) + "\n" + """---------------------------------------- """ + Texts.get_text('MAX_HP_GAME_TERM') + ' : {} + {} \n'.format( self.source.fighter.base_max_hp, self.source.fighter.max_hp - self.source.fighter.base_max_hp) + Texts.get_text('MIGHT_GAME_TERM') + ' : {} + {} \n'.format( self.source.fighter.base_might, self.source.fighter.might - self.source.fighter.base_might) + Texts.get_text('DEXTERITY_GAME_TERM') + ' : {} + {} \n'.format( self.source.fighter.base_dexterity, self.source.fighter.dexterity - self.source.fighter.base_dexterity) + Texts.get_text('VITALITY_GAME_TERM') + ' : {} + {} \n'.format( self.source.fighter.base_vitality, self.source.fighter.vitality - self.source.fighter.base_vitality) + '\n \n' + Texts.get_text('PHYSICAL_POWER_GAME_TERM') + ' : {} '.format(self.source.fighter.physical_power) + '\n' + Texts.get_text('PHYSICAL_RESISTANCE_GAME_TERM') + ' : {} '.format(self.source.fighter.physical_resistance) + '\n \n' + Texts.get_text('WEAPON_DAMAGE_GAME_TERM') + ' : {} \n'.format(self.source.fighter.damage) + """ {} / {} """.format(self.source.level.current_xp, self.source.level.experience_to_next_level) + Texts.get_text('UNTIL_NEXT_LEVEL_CHAR_SCREEN') + """ ---------------------------------------- """) if self.source.level.available_stat_points: self._options = ["level_up_screen"] self.display_options = [ Texts.get_text('CHOOSE_STATS_INCREASE_CHAR_SCREEN') + ' ({})'.format(self.source.level.available_stat_points) ] else: self._options = []
def become_corpse(entity, npc_killed=True): entity.char = "%" entity.color = libtcod.dark_red if npc_killed: entity.render_order = RenderOrder.CORPSE entity.blocks = False entity.fighter = None entity.ai = None entity.name = Texts.get_text('REMAINS_OF_SOMEONE') + entity.name
def equip_item(self, slot, entity_to_equip): events = self.owner.game.events self.set_equipment_in_slot(slot, entity_to_equip) events.add_event( { "message": Texts.get_text('EQUIP_ITEM').format(entity_to_equip.name), "color": color_config.EQUIP, } )
def on_miss(self, target, events): events.add_event( { "message": Texts.get_text('CHAR_ATTACKS_OTHER_MISS').format( self.owner.name.capitalize(), target.name ), "color": color_config.NO_DAMAGE_ATTACK, } )
def leveled_up(self, events): self.available_stat_points += 1 events.add_event( { "message": Texts.get_text('LEVEL_UP').format(self.current_level), "color": color_config.POSITIVE_INFO_COLOR, "level_up": self.owner, } )
def update_options(self): if len(self.source.items) == 0: self.header = (Texts.get_text('INVENTORY_HEADER') + "\n" + Texts.get_text('INVENTORY_EMPTY')) self.display_options = [] self._options = [] else: self.display_options = [] player = self.source.owner for item in self.source.items: if (item.equippable and player.equipment and item == get_equipment_in_slot( item.equippable.slot, player.equipment)): self.display_options.append("{} [{}]".format( item.name, slot_to_text(item.equippable.slot))) else: self.display_options.append(item.name) self._options = [item for item in self.source.items]
def take_landmark(self): entities = self.game.dungeon.current_map.get_entities() for entity in entities: if entity.landmark and entity.x == self.x and entity.y == self.y: self.game.dungeon.next_floor() self.game.full_recompute_fov() self.end_turn() break else: self.game.events.add_event({ "message": Texts.get_text('NO_LANDMARK_THERE'), "color": color_config.IMPORTANT_INFO_COLOR, })
def next_floor(self): new_floor = self.current_floor + 1 if new_floor <= self.max_floor: self.current_floor += 1 self.generate_floor(self.get_floor_to_create()) self.game.recompute_fov() # empecher artefacts de la carte precedente. Fix merdique. Dans Engine, render et Game aussi. self.game.reset_game_windows = True self.game.player.fighter.heal(self.game.player.fighter.max_hp // 2) self.game.events.add_event( { "message": Texts.get_text('REST_AFTER_LANDMARK'), "color": color_config.REST_AFTER_LANDMARK_COLOR, } ) else: self.game.events.add_event({"victory": True})
def acide(user, source_of_effect, dict_results, events): # source of effect is an item_component for now. power = source_of_effect.power target = dict_results.get("requested") damage = randint(int(power / 2), int(power * 1.5)) if target and target.fighter and user.fighter: events.add_event( { "message": Texts.get_text('CHAR_THROW_SOMETHING_AT_SOMEONE').format( user.name, source_of_effect.owner.name, target.name ), "color": color_config.THROW_ITEM_COLOR, } ) user.fighter.do_damage(target, damage, events) return {"consume_item": True} else: return {"consume_item": False}
def kill_player(player, attacker, events): become_corpse(player, npc_killed=False) events.add_event({ "message": Texts.get_text('YOU_DIED'), "color": color_config.YOU_ARE_DEAD })
def return_choice_result(self, string_choice): if string_choice == Texts.get_text('YES_ANSWER'): self.back_to_main = True self.source.command_controller.execute(ExitWindow(self.source))
def __init__(self, inventory): super().__init__(inventory) self.header = Texts.get_text('INVENTORY_HEADER') self.forced_width = 40 self.update_options()