init commit
This commit is contained in:
40
new_hero.py
Normal file
40
new_hero.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from app.utils.logging import get_logger
|
||||
from dataclasses import asdict
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
from app.game.generators.entity_factory import build_char
|
||||
from app.game.systems.leveling import calculate_xp_and_level
|
||||
|
||||
player = build_char(
|
||||
name="Philbert",
|
||||
origin_story="I came from a place",
|
||||
race_id="terran",
|
||||
class_id="arcanist"
|
||||
)
|
||||
|
||||
# MOVE HIT DICE TO WEAPONS!
|
||||
# ADD DEFENSE STAT
|
||||
# ADD ATTACK STAT - this will help with combat!
|
||||
|
||||
|
||||
new_xp_stats = calculate_xp_and_level(current_xp=player.xp,xp_gain=200)
|
||||
|
||||
player.xp = new_xp_stats.get("new_xp")
|
||||
player.level = new_xp_stats.get("new_level")
|
||||
player.xp_to_next_level = new_xp_stats.get("xp_to_next_level")
|
||||
|
||||
import json
|
||||
player_dict = asdict(player)
|
||||
print(json.dumps(player_dict,indent=True))
|
||||
|
||||
|
||||
# serialize / deserialize
|
||||
# to json
|
||||
# player_dict = asdict(player)
|
||||
|
||||
# from json to dataclass
|
||||
# from app.game.utils.loaders import from_dict
|
||||
# from app.game.models.entities import Entity
|
||||
# player_e = from_dict(Entity,player_dict)
|
||||
# print(player_e)
|
||||
Reference in New Issue
Block a user