예제 #1
0
 def use_ability(cls, monster):
     if monster.target is None:
         return
     cls.reset_turn(monster)
     if monster == monster.target or monster.target.get_status(StatusEffectSoulbound) is not None:
         add_log_message(
             LogMessage(
                 get_message('soulsteal.fail'),
                 tcod.white
             )
         )
         return
     success_roll = randint(1, monster.get_soul_power() + monster.target.get_soul_power())
     success = success_roll <= monster.get_soul_power()
     if not success:
         add_log_message(
             LogMessage(
                 get_message('soulsteal.fail'),
                 tcod.white
             )
         )
         return
     monster.game_map.take_over_monster(monster.player, monster=monster.target)
     cls.reset_turn(monster.target)
     soulbound_turns = monster.get_soul_power() + monster.target.get_soul_power()
     monster.add_status(StatusEffectSoulbound, soulbound_turns * randint(27, 33))
     monster.target.add_status(StatusEffectSoulbound, soulbound_turns * randint(9, 11))
     monster.target.target = None
     monster.target = None
예제 #2
0
 def use(cls, item):
     add_log_message(
         LogMessage(
             get_message(
                 get_monster_message_prefix(item.monster) +
                 'item.potion.use').format(
                     str.capitalize(item.monster.get_name()),
                     item.get_name())))
예제 #3
0
def attack(attacker, target):
    message_key_prefix = get_monster_message_prefix(attacker)

    roll = make_attack_roll(attacker)
    evasion = target.get_evasion()
    roll -= evasion
    if roll <= 0:
        add_log_message(
            LogMessage(
                get_message(message_key_prefix + "miss_dodge").format(
                    str.capitalize(attacker.get_name()), target.get_name()),
                tcod.grey))
        return

    damage = make_damage_roll(attacker)
    if damage <= target.get_shield_block():
        shield = target.get_shield_rate()
        roll -= shield
        if roll <= 0:
            add_log_message(
                LogMessage(
                    get_message(message_key_prefix + "miss_block").format(
                        str.capitalize(attacker.get_name()),
                        target.get_name()), tcod.grey))
            return

    armor = target.get_armor_value()
    if armor >= 1:
        damage -= randint(0, armor)
    if damage <= 0:
        add_log_message(
            LogMessage(
                get_message(message_key_prefix + "miss_armor").format(
                    str.capitalize(attacker.get_name()), target.get_name()),
                tcod.grey))
        return

    add_log_message(
        LogMessage(
            get_message(message_key_prefix + "hit").format(
                str.capitalize(attacker.get_name()), target.get_name(),
                damage), tcod.white))
    target.take_damage(damage, attacker)
    attacker.apply_attack_effect(target)
예제 #4
0
 def remove_effect(self):
     if tcod.map_is_in_fov(self.monster.game_map.fov_map, self.monster.x,
                           self.monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "poison.end").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.desaturated_orange))
예제 #5
0
 def __init__(self, monster, turns):
     super().__init__(monster, turns)
     if tcod.map_is_in_fov(monster.game_map.fov_map, monster.x, monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "poison.begin").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.dark_orange))
예제 #6
0
 def heal(self, amount, with_message=True):
     self.hp += amount
     self.check_max_hp()
     if with_message:
         add_log_message(
             LogMessage(
                 get_message(get_monster_message_prefix(self) + 'healed')
                 .format(str.capitalize(self.get_name())),
                 tcod.desaturated_green if self.player is None else tcod.green
             )
         )
예제 #7
0
 def use_ability(cls, monster):
     items = monster.game_map.get_items_at(monster.x, monster.y)
     if not items:
         add_log_message(
             LogMessage(
                 get_message(get_monster_message_prefix(monster) + 'pickup_item.none'),
                 tcod.dark_grey
             )
         )
     else:
         item = items.pop()
         monster.inventory.add_item(item)
         add_log_message(
             LogMessage(
                 get_message(get_monster_message_prefix(monster) + 'pickup_item')
                 .format(monster.get_name(), item.get_name()),
                 tcod.white
             )
         )
     cls.reset_turn(monster)
예제 #8
0
 def remove_effect(self):
     self.monster.remove_stat_bonus('dexterity', 'spider_web')
     self.monster.remove_stat_bonus('land_speed', 'spider_web')
     if tcod.map_is_in_fov(self.monster.game_map.fov_map, self.monster.x,
                           self.monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "spider_web.end").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.desaturated_orange))
예제 #9
0
 def remove_effect(self):
     self.monster.remove_stat_bonus('strength', 'fatigue')
     self.monster.remove_stat_bonus('constitution', 'fatigue')
     self.monster.remove_stat_bonus('dexterity', 'fatigue')
     if tcod.map_is_in_fov(self.monster.game_map.fov_map, self.monster.x,
                           self.monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "fatigue.end").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.desaturated_orange))
예제 #10
0
 def __init__(self, monster, turns):
     super().__init__(monster, turns)
     monster.add_stat_bonus('strength', 'fatigue', -2)
     monster.add_stat_bonus('constitution', 'fatigue', -2)
     monster.add_stat_bonus('dexterity', 'fatigue', -2)
     if tcod.map_is_in_fov(monster.game_map.fov_map, monster.x, monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "fatigue.begin").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.dark_orange))
예제 #11
0
 def remove_effect(self):
     self.monster.remove_stat_bonus('strength', 'rage')
     self.monster.remove_stat_bonus('constitution', 'rage')
     self.monster.remove_stat_bonus('dexterity', 'rage')
     self.monster.remove_stat_bonus('intelligence', 'rage')
     if tcod.map_is_in_fov(self.monster.game_map.fov_map, self.monster.x,
                           self.monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "rage.end").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.desaturated_blue))
     self.monster.add_status(StatusEffectFatigue, self.elapsed_turns * 2)
예제 #12
0
 def __init__(self, monster, turns):
     self.elapsed_turns = 0
     super().__init__(monster, turns)
     monster.add_stat_bonus('strength', 'rage', 8)
     monster.add_stat_bonus('constitution', 'rage', 4)
     monster.add_stat_bonus('dexterity', 'rage', -4)
     monster.add_stat_bonus('intelligence', 'rage', -8)
     if tcod.map_is_in_fov(monster.game_map.fov_map, monster.x, monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "rage.begin").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.blue))
예제 #13
0
 def take_damage(self, damage, source = None):
     self.hp -= damage
     if self.hp <= 0:
         add_log_message(
             LogMessage(
                 get_message(get_monster_message_prefix(self) + "die")
                 .format(str.capitalize(self.get_name())),
                 tcod.orange if self.player is None else tcod.red
             )
         )
         self.dead = True
         if source is not None:
             source.gain_exp(self.get_defeat_experience())
         if self.player is not None:
             delete_game()
예제 #14
0
 def __init__(self, monster, turns):
     super().__init__(monster, turns)
     self.total_turns = turns
     self.total_dex_malus = -1
     self.total_speed_malus = 25
     monster.add_stat_bonus('dexterity', 'spider_web', self.total_dex_malus)
     monster.add_stat_bonus('land_speed', 'spider_web',
                            self.total_speed_malus)
     if tcod.map_is_in_fov(monster.game_map.fov_map, monster.x, monster.y):
         add_log_message(
             LogMessage(
                 get_message(
                     get_monster_message_prefix(self.monster) +
                     "spider_web.begin").format(
                         str.capitalize(self.monster.get_name())),
                 tcod.dark_orange))
예제 #15
0
 def gain_level(self, level, log=False):
     if level < 1:
         return
     for _ in range(level - 1):
         self.monster_race.gain_level(self)
         if self.monster_class:
             self.monster_class.gain_level(self)
     self.level += level
     if log:
         add_log_message(
             LogMessage(
                 get_message(get_monster_message_prefix(self) + "level_up")
                 .format(str.capitalize(self.get_name())),
                 tcod.orange if self.player is None else tcod.green
             )
         )
예제 #16
0
    def stack(self, monster, turns):
        add_turns = min(300, self.turns + turns) - self.turns
        self.turns += add_turns
        self.total_turns += add_turns
        self.total_dex_malus = max(-5, self.total_dex_malus - 1)
        self.total_speed_malus = min(250, self.total_speed_malus + 25)

        multiplier = self.turns / self.total_turns
        monster.add_stat_bonus('dexterity', 'spider_web',
                               floor(self.total_dex_malus * multiplier))
        monster.add_stat_bonus('land_speed', 'spider_web',
                               ceil(self.total_speed_malus * multiplier))

        if tcod.map_is_in_fov(monster.game_map.fov_map, monster.x, monster.y):
            add_log_message(
                LogMessage(
                    get_message(
                        get_monster_message_prefix(self.monster) +
                        "spider_web.stack").format(
                            str.capitalize(self.monster.get_name())),
                    tcod.dark_orange))
예제 #17
0
    def run(self):
        while not tcod.console_is_window_closed():
            self.render_engine.render_scene(self.current_scene)
            if self.current_scene.data is not None:
                input_return = self.current_scene.manage_input(None)
            else:
                game_input = self.input_manager.get_input()
                input_return = self.current_scene.manage_input(game_input)
            if input_return is None:
                continue
            if input_return['action']:
                if input_return['action'] == 'confirm':
                    input_return = self.current_scene.need_confirm
                if input_return['action'] == 'cancel' or input_return['action'] == 'cancel_with_action':
                    if self.current_scene.previous_scene is not None:
                        current = self.current_scene
                        self.current_scene = self.current_scene.previous_scene
                        current.previous_scene = None
                        if input_return['action'] == 'cancel_with_action' and isinstance(self.current_scene, MapScene):
                            self.current_scene.player_took_action = True
                        self.current_scene.render_next = True
                        del current
                    else:
                        if self.current_scene.need_confirm is not None:
                            return True
                        self.current_scene.need_confirm = input_return
                        add_log_message(
                            LogMessage(
                                get_message("quit_game.confirm"),
                                tcod.light_cyan
                            )
                        )
                        self.current_scene.render_next = True
                elif input_return['action'] == 'change_scene':
                    self.current_scene = input_return['scene']
                    self.current_scene.render_next = True

        if not self.player.entity.dead:
            save_game(self.player)