mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 04:27:16 +02:00
Add temp chargen sheet
This commit is contained in:
parent
19278a5e64
commit
8fff730d17
2 changed files with 62 additions and 55 deletions
|
|
@ -9,7 +9,7 @@ from evennia.utils.evform import EvForm
|
|||
from evennia.utils.evmenu import EvMenu, ask_yes_no
|
||||
from evennia.utils.evtable import EvTable
|
||||
from evennia.utils.logger import log_trace
|
||||
from evennia.utils.utils import inherits_from, lazy_property
|
||||
from evennia.utils.utils import lazy_property
|
||||
|
||||
from . import rules
|
||||
from .equipment import EquipmentError, EquipmentHandler
|
||||
|
|
@ -362,32 +362,20 @@ _SHEET = """
|
|||
"""
|
||||
|
||||
|
||||
def get_character_sheet(data):
|
||||
def get_character_sheet(character):
|
||||
"""
|
||||
Generate a character sheet. This is grouped in a class in order to make
|
||||
it easier to override the look of the sheet.
|
||||
|
||||
Args:
|
||||
data (EvAdventureCharacter or EvAdventureCharacterGeneration): This contains
|
||||
the data to put in the sheet, either as stored on a finished character
|
||||
or on the temporary chargen storage object.
|
||||
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get(data):
|
||||
def get(character):
|
||||
"""
|
||||
Generate a character sheet from the character's stats.
|
||||
|
||||
data
|
||||
|
||||
"""
|
||||
if inherits_from(data, DefaultCharacter):
|
||||
# a character, get info normally
|
||||
equipment = [item.key for item in character.equipment.all()]
|
||||
else:
|
||||
equipment
|
||||
|
||||
equipment = character.equipment.all()
|
||||
# divide into chunks of max 10 length (to go into two columns)
|
||||
equipment_table = EvTable(
|
||||
table=[equipment[i : i + 10] for i in range(0, len(equipment), 10)]
|
||||
|
|
@ -396,15 +384,15 @@ def get_character_sheet(data):
|
|||
form.map(
|
||||
cells={
|
||||
1: character.key,
|
||||
2: f"+{data.strength}({data.strength + 10})",
|
||||
3: f"+{data.dexterity}({data.dexterity + 10})",
|
||||
4: f"+{data.constitution}({data.constitution + 10})",
|
||||
5: f"+{data.wisdom}({data.wisdom + 10})",
|
||||
6: f"+{data.charisma}({data.charisma + 10})",
|
||||
7: f"{data.hp}/{data.hp_max}",
|
||||
8: data.xp,
|
||||
9: data.level,
|
||||
"A": data.db.desc,
|
||||
2: f"+{character.strength}({character.strength + 10})",
|
||||
3: f"+{character.dexterity}({character.dexterity + 10})",
|
||||
4: f"+{character.constitution}({character.constitution + 10})",
|
||||
5: f"+{character.wisdom}({character.wisdom + 10})",
|
||||
6: f"+{character.charisma}({character.charisma + 10})",
|
||||
7: f"{character.hp}/{character.hp_max}",
|
||||
8: character.xp,
|
||||
9: character.level,
|
||||
"A": character.db.desc,
|
||||
},
|
||||
tables={
|
||||
1: equipment_table,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@ from evennia.utils.evmenu import EvMenu
|
|||
from .random_tables import chargen_table
|
||||
from .rules import dice
|
||||
|
||||
_TEMP_SHEET = """
|
||||
STR +{strength} DEX +{dexterity} CON +{constitution} INT +{intelligence} WIS +{wisdom} CHA +{charisma}
|
||||
|
||||
{description}
|
||||
|
||||
{equipment}
|
||||
"""
|
||||
|
||||
|
||||
class EvAdventureCharacterGeneration:
|
||||
"""
|
||||
|
|
@ -29,8 +37,7 @@ class EvAdventureCharacterGeneration:
|
|||
|
||||
"""
|
||||
|
||||
def random_ability(self):
|
||||
""" """
|
||||
def _random_ability(self):
|
||||
return min(dice.roll("1d6"), dice.roll("1d6"), dice.roll("1d6"))
|
||||
|
||||
def generate(self):
|
||||
|
|
@ -43,29 +50,34 @@ class EvAdventureCharacterGeneration:
|
|||
self.name = dice.roll_random_table("1d282", chargen_table["name"])
|
||||
|
||||
# base attribute values
|
||||
self.strength = self.random_ability()
|
||||
self.dexterity = self.random_ability()
|
||||
self.constitution = self.random_ability()
|
||||
self.intelligence = self.random_ability()
|
||||
self.wisdom = self.random_ability()
|
||||
self.charisma = self.random_ability()
|
||||
self.strength = self._random_ability()
|
||||
self.dexterity = self._random_ability()
|
||||
self.constitution = self._random_ability()
|
||||
self.intelligence = self._random_ability()
|
||||
self.wisdom = self._random_ability()
|
||||
self.charisma = self._random_ability()
|
||||
|
||||
# physical attributes (only for rp purposes)
|
||||
self.physique = dice.roll_random_table("1d20", chargen_table["physique"])
|
||||
self.face = dice.roll_random_table("1d20", chargen_table["face"])
|
||||
self.skin = dice.roll_random_table("1d20", chargen_table["skin"])
|
||||
self.hair = dice.roll_random_table("1d20", chargen_table["hair"])
|
||||
self.clothing = dice.roll_random_table("1d20", chargen_table["clothing"])
|
||||
self.speech = dice.roll_random_table("1d20", chargen_table["speech"])
|
||||
self.virtue = dice.roll_random_table("1d20", chargen_table["virtue"])
|
||||
self.vice = dice.roll_random_table("1d20", chargen_table["vice"])
|
||||
self.background = dice.roll_random_table("1d20", chargen_table["background"])
|
||||
self.misfortune = dice.roll_random_table("1d20", chargen_table["misfortune"])
|
||||
self.alignment = dice.roll_random_table("1d20", chargen_table["alignment"])
|
||||
physique = dice.roll_random_table("1d20", chargen_table["physique"])
|
||||
face = dice.roll_random_table("1d20", chargen_table["face"])
|
||||
skin = dice.roll_random_table("1d20", chargen_table["skin"])
|
||||
hair = dice.roll_random_table("1d20", chargen_table["hair"])
|
||||
clothing = dice.roll_random_table("1d20", chargen_table["clothing"])
|
||||
speech = dice.roll_random_table("1d20", chargen_table["speech"])
|
||||
virtue = dice.roll_random_table("1d20", chargen_table["virtue"])
|
||||
vice = dice.roll_random_table("1d20", chargen_table["vice"])
|
||||
background = dice.roll_random_table("1d20", chargen_table["background"])
|
||||
misfortune = dice.roll_random_table("1d20", chargen_table["misfortune"])
|
||||
alignment = dice.roll_random_table("1d20", chargen_table["alignment"])
|
||||
|
||||
self.desc = (
|
||||
f"{background.title()}. Wears {clothing} clothes, and has {speech} "
|
||||
f"speech. Has a {physique} physique, a {face} face, {skin} skin and "
|
||||
f"{hair} hair. Is {virtue}, but {vice}. Has been {misfortune} in "
|
||||
f"the past. Favors {alignment}."
|
||||
)
|
||||
|
||||
# same for all
|
||||
self.exploration_speed = 120
|
||||
self.combat_speed = 40
|
||||
self.hp_max = max(5, dice.roll("1d8"))
|
||||
self.hp = self.hp_max
|
||||
self.xp = 0
|
||||
|
|
@ -89,20 +101,27 @@ class EvAdventureCharacterGeneration:
|
|||
dice.roll_random_table("1d20", chargen_table["general gear 2"]),
|
||||
]
|
||||
|
||||
def build_desc(self):
|
||||
def show_sheet(self):
|
||||
"""
|
||||
Generate a backstory / description paragraph from random elements.
|
||||
Show a temp character sheet, a compressed version of the real thing.
|
||||
|
||||
"""
|
||||
return (
|
||||
f"{self.background.title()}. Wears {self.clothing} clothes, and has {self.speech} "
|
||||
f"speech. Has a {self.physique} physique, a {self.face} face, {self.skin} skin and "
|
||||
f"{self.hair} hair. Is {self.virtue}, but {self.vice}. Has been {self.misfortune} in "
|
||||
f"the past. Favors {self.alignment}."
|
||||
equipment = (
|
||||
str(item)
|
||||
for item in [self.armor, self.helmet, self.shield, self.weapon] + self.backpack
|
||||
if item
|
||||
)
|
||||
|
||||
def show_sheet(self):
|
||||
return get_character_sheet(self)
|
||||
return _TEMP_SHEET.format(
|
||||
strength=self.strength,
|
||||
dexterity=self.dexterity,
|
||||
constitution=self.constitution,
|
||||
intelligence=self.intelligence,
|
||||
wisdom=self.wisdom,
|
||||
charisma=self.charisma,
|
||||
description=self.desc,
|
||||
equipment=", ".join(equipment),
|
||||
)
|
||||
|
||||
def adjust_attribute(self, source_attribute, target_attribute, value):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue