def create(self, name, class_uid, race_uid, stats, body_uid): """ Creates a new character based on arguments :return: """ uid = "player" new_instance = Character( uid=uid, name=name, character_class=self.get_class_template_by_uid(class_uid).copy(), character_race=self.get_race_template_by_uid(race_uid).copy(), stats=stats, display=Display((255, 255, 255), (0, 0, 0), "@"), body=self.factory_service.build_body_instance_by_uid(body_uid), inventory=Inventory()) health_base = new_instance.character_class.hit_die constitution_bonus = new_instance.get_stat_modifier( StatsEnum.Constitution) total_health = health_base + constitution_bonus new_instance.stats.set_core_current_value(StatsEnum.Health, total_health) new_instance.stats.set_core_maximum_value(StatsEnum.Health, total_health) return new_instance
class Player: def __init__(self): self.character = Character() def act(self): # self.character.position['x'] = (self.character.position['x'] + 1) % pyxel.width # GAMEPAD_1_LEFT throwing error. # if (pyxel.btn(pyxel.KEY_S) or pyxel.btn(pyxel.GAMEPAD_1_LEFT)) and (pyxel.btn(pyxel.KEY_F) or pyxel.btn(pyxel.GAMEPAD_1_RIGHT)): # self.character.momentum_horizontal = 0 # elif pyxel.btn(pyxel.KEY_S) or pyxel.btn(pyxel.GAMEPAD_1_LEFT): # self.character.momentum_horizontal = 1 # elif pyxel.btn(pyxel.KEY_F) or pyxel.btn(pyxel.GAMEPAD_1_RIGHT): # self.character.momentum_horizontal = -1 # else: # self.character.momentum_horizontal = 0 if pyxel.btn(pyxel.KEY_S) and pyxel.btn(pyxel.KEY_F): self.character.momentum_horizontal = 0 elif pyxel.btn(pyxel.KEY_S): self.character.momentum_horizontal = -1 elif pyxel.btn(pyxel.KEY_F): self.character.momentum_horizontal = 1 else: self.character.momentum_horizontal = 0 self.character.act()
def normalizeCharacters(characterInfos): characters = [] for characterInfo in characterInfos: character = Character(characterInfo) normalizeEvents(character.events, characterInfo.events) characters.append(character) return characters
def setUp(self): self.c1 = Character() self.c2 = Character(name='pippo', xp=1000, hp=25, level=2) self.rpgc1 = RPGCharacter()
from characters.character import Character from components.display import Display from components.stats import make_character_stats from components.outfitter import Outfitter from data.python_templates.classes import thief_class, warrior_class from data.python_templates.races import human_race, orc_race, troll_race from data.python_templates.body import humanoid_body from util.colors import Colors weak_orc = Character( uid="weak_orc", name="Weak Orc", character_class=warrior_class, character_race=orc_race, stats=make_character_stats(health=10), display=Display(Colors.ORC_GREEN, Colors.BLACK_COLOR, "O"), body=humanoid_body.copy(), ) strong_orc = Character( uid="strong_orc", name="Strong Orc", character_class=warrior_class, character_race=orc_race, stats=make_character_stats(health=16, strength=12, constitution=12), display=Display(Colors.ORC_GREEN, Colors.BLACK_COLOR, "O"), body=humanoid_body.copy(), ) weak_troll = Character( uid="weak_troll", name="Weak Troll",
def __init__(self, name, items, max_weight): Character.__init__(self, name, items) self.max_weight = max_weight
def __init__(self): self.character = Character()
def assignArmy(self, size: int, army_type: CharacterType) -> None: self._size = size if army_type == CharacterType.SOLDIER: self._army = [Character() for x in range(size)]