Пример #1
0
def _create_monster_npc(encounter):
    current_monster = monster.Monster()
    current_monster.load_from_db(encounter['monster'])
    # Set the monster's level based on the specified level range
    if len(encounter['level_range']) > 1:
        level = random.randrange(encounter['level_range'][0],
                                 encounter['level_range'][1])
    else:
        level = encounter['level_range'][0]
    # Set the monster's level
    current_monster.level = 1
    current_monster.set_level(level)
    current_monster.current_hp = current_monster.hp

    # Create an NPC object which will be this monster's "trainer"
    npc = NPC("maple_girl")
    npc.add_monster(current_monster)
    # NOTE: random battles are implemented as trainer battles.
    #       this is a hack. remove this once trainer/random battlers are fixed
    current_monster.owner = None
    npc.party_limit = 0

    # Set the NPC object's AI model.
    npc.ai = ai.AI()
    return npc
Пример #2
0
    def start(self):
        player = self.session.player
        for slot, current_monster in enumerate(player.monsters):
            new_slug = current_monster.get_evolution(self.parameters.path)
            if new_slug:
                # TODO: implement an evolution animation

                # Store the properties of the old monster then remove it
                old_level = current_monster.level
                old_current_hp = current_monster.current_hp
                old_name = current_monster.name
                old_flairs = current_monster.flairs
                player.remove_monster(current_monster)

                # Add the new monster and load the old properties
                new_monster = monster.Monster()
                new_monster.load_from_db(new_slug)
                new_monster.set_level(old_level)
                new_monster.current_hp = min(old_current_hp, new_monster.hp)
                new_monster.name = old_name
                player.add_monster(new_monster)

                # If the new monster has a flair matching that of the old monster, copy it
                for new_flair in new_monster.flairs.values():
                    for old_flair in old_flairs.values():
                        if new_flair.category == old_flair.category:
                            new_monster.flairs[new_flair.category] = old_flair

                # Removing the old monster caused all monsters in front to move a slot back
                # Bring our new monster from the end of the list to its previous position
                for i in range(len(player.monsters) - 1, slot, -1):
                    player.switch_monsters(i, i - 1)

                # Only do one evolution per call
                return
Пример #3
0
    def start(self):
        monster_slug, monster_level = self.parameters

        current_monster = monster.Monster()
        current_monster.load_from_db(monster_slug)
        current_monster.set_level(monster_level)
        current_monster.current_hp = current_monster.hp

        self.session.player.add_monster(current_monster)