예제 #1
0
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,
        }
예제 #2
0
 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
예제 #3
0
    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)
예제 #4
0
 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
예제 #5
0
 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"]
예제 #6
0
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')
예제 #7
0
 def warning(self):
     self.game.events.add_event({
         "message": Texts.get_text('TARGET_MODE_ON'),
         "color": color_config.TARGET_MESS_COLOR,
     })
     self.game.events.add_event({
         "message":
         Texts.get_text('TARGET_CONTROLS_EXPLAIN'),
         "color":
         color_config.TARGET_MESS_COLOR,
     })
예제 #8
0
 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
예제 #9
0
    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
예제 #10
0
 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
예제 #11
0
    def use(self, item_entity):
        event_handler = self.owner.game.events
        item_component = item_entity.item
        if item_entity.equippable:
            equippable_component = item_entity.equippable
        else:
            equippable_component = None

        # Equipable item and can be equip by inventory owner
        if equippable_component and self.owner.equipment:
            self.owner.equipment.toggle_equip(item_entity)
            self.action_take_round()
            return True  # has been equipped

        # L item que j utilise n a pas de fonctionnalité.
        elif item_component.use_function is None:
            event_handler.add_event({
                "message":
                Texts.get_text('CANNOT_USE_ITEM').format(item_entity.name),
                "color":
                color_config.CANNOT_BE_USED,
            })
            return False  # Can t be use

        # L item a une fonctionnalité.
        elif item_component.use_function:
            # Target!
            target_type = item_component.target_type
            game = self.owner.game
            game.activate_target_mode(item_component, target_type)

        else:
            raise NotImplementedError
예제 #12
0
    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()
예제 #13
0
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)
예제 #14
0
    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 = []
예제 #15
0
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
예제 #16
0
 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,
         }
     )
예제 #17
0
 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,
         }
     )
예제 #18
0
파일: level.py 프로젝트: Kavekha/LostForest
 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,
         }
     )
예제 #19
0
    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]
예제 #20
0
 def add_item(self, item, event_handler=None):
     if len(self.items) >= self.capacity:
         if event_handler:
             event_handler.add_event({
                 "message":
                 Texts.get_text('INVENTORY_FULL'),
                 "color":
                 color_config.INVENTORY_FULL,
             })
         return False
     else:
         if event_handler:
             event_handler.add_event({
                 "message":
                 Texts.get_text('PICK_UP_ITEM').format(item.name),
                 "color":
                 color_config.ITEM_PICKED,
             })
         self.owner.game.dungeon.current_map.get_entities().remove(item)
         self.items.append(item)
         return True
예제 #21
0
 def validate_target(self):
     results, valid = self.get_info_from_tile()
     # on envoie les resultats, meme si not valid, pour messages sympas & rigolos potentiels.
     if results:
         self.play_function_on_target(results)
     if not valid:
         self.game.events.add_event({
             "message":
             Texts.get_text('TARGET_TYPE_INVALID'),
             "color":
             color_config.TARGET_ERROR_COLOR,
         })
     self.quit_target_mode()
예제 #22
0
    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,
            })
예제 #23
0
 def pick_up(self):
     event_handler = self.owner.game.events
     entities = self.owner.game.dungeon.current_map.get_entities()
     for entity in entities:
         if entity.item and entity.x == self.owner.x and entity.y == self.owner.y:
             action_resolution = self.add_item(entity, event_handler)
             if action_resolution:
                 return True  # On indique que l'action est un succès.
             else:
                 break
     else:
         event_handler.add_event({
             "message":
             Texts.get_text('NOTHING_TO_PICK_UP'),
             "color":
             color_config.NOTHING_TO_PICK_UP,
         })
     return False  # On indique que l action n a pas reussi.
예제 #24
0
    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})
예제 #25
0
    def drop(self, item_entity):
        event_handler = self.owner.game.events
        game_map = self.owner.game.dungeon.current_map

        if (item_entity.equippable and self.owner.equipment
                and item_entity == get_equipment_in_slot(
                    item_entity.equippable.slot, self.owner.equipment)):
            self.owner.equipment.toggle_equip(item_entity)
        else:
            item_entity.x, item_entity.y = self.owner.x, self.owner.y
            game_map.add_entity(item_entity)
            self.remove_item(item_entity)
            event_handler.add_event({
                "message":
                Texts.get_text('DROP_ITEM').format(item_entity.name),
                "color":
                color_config.ITEM_DROPED,
            })
        return True  # please update menu
예제 #26
0
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}
예제 #27
0
 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))
예제 #28
0
 def __init__(self, inventory):
     super().__init__(inventory)
     self.header = Texts.get_text('INVENTORY_HEADER')
     self.forced_width = 40
     self.update_options()
예제 #29
0
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
    })
예제 #30
0
 def return_choice_result(self, string_choice):
     Texts.set_language(string_choice)
     self.update_options()