Beispiel #1
0
def create_character(race, kit, model, action_factory, rng):
    """
    Creates a new character with given race and kit
    """
    global race_stats
    global kit_stats
    global __logger

    if race_stats == None:
        initialise_stat_tables()

    temp_race = race_stats[race]
    temp_kit = kit_stats[kit]

    new_character = Character(model,
                              action_factory,
                              EffectsCollection(),
                              rng)
    new_character.body = temp_race['body'] + temp_kit['body']
    new_character.finesse = temp_race['finesse'] + temp_kit['finesse']
    new_character.mind = temp_race['mind'] + temp_kit['mind']
    new_character.hit_points = temp_race['hp'] + temp_kit['hp']
    new_character.max_hp = new_character.hit_points
    new_character.speed = temp_race['speed'] + temp_kit['speed']
    new_character.size = 'medium'
    new_character.attack = 3

    new_character.feats.append(WeaponProficiency('simple'))
    new_character.icon = herculeum.config.tiles.HUMAN_FIGHTER

    return new_character
Beispiel #2
0
    def build(self):
        """
        Build character

        :returns: character
        :rtype: Character
        """
        character = Character(self.model)

        if self.player_character:
            self.model.player = character

        character.name = self.name

        character.hit_points = self.hit_points
        character.max_hp = self.max_hp
        character.spirit = self.spirit
        character.max_spirit = self.max_spirit

        character.mind = self.mind
        character.body = self.body
        character.finesse = self.finesse
        character.size = self.size
        character.attack = self.attack

        character.speed = self.speed
        character.tick = self.tick
        character.level = self.level
        character.location = self.location
        character.inventory.weapon = self.weapon

        for item in self.items:
            character.inventory.append(item)

        for handle in self.effect_handles:
            character.add_effect_handle(handle)

        for effect in self.effects:
            character.add_effect(effect)

        for listener in self.listeners:
            character.register_event_listener(listener)

        for listener in self.update_listeners:
            character.register_for_updates(listener)

        for domain, level in self.domains.items():
            character.add_domain_level(domain, level)

        for entry in self.spell_entries:
            character.add_spell_entry(entry)

        for skill, limit in self.cooldowns.items():
            cooldown(character, skill, limit)

        return character
Beispiel #3
0
    def build(self):
        """
        Build character

        Returns:
            Character
        """
        character = Character(model = self.model,
                              action_factory = self.action_factory,
                              rng = self.rng,
                              effects_collection = self.effects_collection)

        if self.player_character:
            self.model.player = character

        character.name = self.name

        character.hit_points = self.hit_points
        character.max_hp = self.max_hp

        character.mind = self.mind
        character.body = self.body
        character.attack = self.attack

        character.speed = self.speed
        character.tick = self.tick
        character.level = self.level
        character.location = self.location

        for handle in self.effect_handles:
            character.add_effect_handle(handle)

        for effect in self.effects:
            character.add_effect(effect)

        for listener in self.listeners:
            character.register_event_listener(listener)

        return character
Beispiel #4
0
    def generate_creature(self, name):
        """
        Generate creature

        :param name: name of the creature to generate
        :type name: string
        """
        config = self.__get_creature_config(name)

        new_creature = Character(self.model,
                                 self.action_factory,
                                 EffectsCollection(),
                                 self.rng)

        new_creature.name = config.name
        new_creature.body = config.body
        new_creature.finesse = config.finesse
        new_creature.mind = config.mind
        new_creature.hit_points = config.hp
        new_creature.speed = config.speed
        new_creature.icon = config.icons #TODO: pick random
        new_creature.attack = config.attack

        for spec in config.effect_handles:
            new_handle = EffectHandle(trigger = spec.trigger,
                                       effect = spec.effect,
                                       parameters = spec.parameters,
                                       charges = spec.charges)

            new_creature.add_effect_handle(new_handle)

        if not config.ai == None:
            new_creature.artificial_intelligence = config.ai(new_creature)

        return new_creature