Fixed some stale code from a PR and fixed monk unarmed strike when importing from Foundry.

Pull-request https://github.com/canismarko/dungeon-sheets/pull/96
introduced some regressions in terms of the model between
``Character`` and ``Entity`` classes. These were cleaned up.
This commit is contained in:
Mark Wolfman
2021-06-12 13:55:21 -05:00
parent 4ce68d5642
commit 72af80f991
5 changed files with 17 additions and 25 deletions
+1 -19
View File
@@ -144,20 +144,10 @@ class Character(Entity):
# Character-specific
player_name = ""
xp = 0
# Hit points
hp_max = None
# Extra hit points info, for characters only
hp_current = None
hp_temp = None
# Base stats (ability scores)
strength = Ability()
dexterity = Ability()
constitution = Ability()
intelligence = Ability()
wisdom = Ability()
charisma = Ability()
armor_class = ArmorClass()
initiative = Initiative()
speed = Speed()
inspiration = False
attacks_and_spellcasting = ""
class_list = list()
@@ -173,14 +163,6 @@ class Character(Entity):
features_and_traits = "Describe any other features and abilities."
_proficiencies_text = list()
# Magic
spellcasting_ability = None
_spells = list()
_spells_prepared = list()
infusions = list()
# Features IN MAJOR DEVELOPMENT
custom_features = list()
feature_choices = list()
# Appearance
# portrait = placeholder not sure how to implement
+1 -1
View File
@@ -32,7 +32,7 @@ class MartialArts(Feature):
- When you use the Attack action with an unarmed strike or a monk
weapon on your turn, you can make one unarmed strike as a bonus
action. For example, if you take the Attack action and attack
with a quarter- staff, you can also make an unarmed strike as a
with a quarterstaff, you can also make an unarmed strike as a
bonus action, assuming you haven't already taken a bonus action
this turn.
+4 -2
View File
@@ -148,15 +148,17 @@ def create_character_pdf_template(character, basename, flatten=False):
("Wpn Name 2", "Wpn2 AtkBonus ", "Wpn2 Damage "),
("Wpn Name 3", "Wpn3 AtkBonus ", "Wpn3 Damage "),
]
if len(character.weapons) == 0:
if len(character.weapons) == 0 or hasattr(character, 'Monk'):
character.wield_weapon("unarmed")
for _fields, weapon in zip(weapon_fields, character.weapons):
name_field, atk_field, dmg_field = _fields
fields[name_field] = weapon.name
fields[atk_field] = "{:+d}".format(weapon.attack_modifier)
fields[dmg_field] = f"{weapon.damage}/{weapon.damage_type}"
# Additional attacks beyond 3
attack = [f"{w.name}: Atk {weapon.attack_modifier:+d}, Dam {weapon.damage}/{weapon.damage_type}"
for w in character.weapons[len(weapon_fields):]]
# Other attack information
attack = []
if character.armor:
attack.append(f"Armor: {character.armor}")
if character.shield:
+3 -2
View File
@@ -284,8 +284,9 @@ def make_character_sheet(
character_props = readers.read_sheet_file(char_file)
character = _char.Character.load(character_props)
# Set the fields in the FDF
char_base = os.path.splitext(character_file)[0] + "_char"
person_base = os.path.splitext(character_file)[0] + "_person"
basename = char_file.stem
char_base = basename + "_char"
person_base = basename + "_person"
sheets = [char_base + ".pdf", person_base + ".pdf"]
pages = []
tex = [
+8 -1
View File
@@ -314,6 +314,12 @@ class Roll20CharacterReader(JSONCharacterReader):
class FoundryCharacterReader(JSONCharacterReader):
# List of weapons to ignore, only for class features that get added automatically
_invalid_weapons = [
"unarmed strike (monk)",
"<no name>",
]
def _skill_proficiency_value(self, key: str) -> float:
proficiency_labels = {
"acrobatics": "acr",
@@ -377,7 +383,8 @@ class FoundryCharacterReader(JSONCharacterReader):
"""Iterator over the weapons the character is carrying in her inventory."""
items = self.json_data()["items"]
for item in items:
if item["type"] == "weapon" and item["name"] != "<no name>":
is_valid_weapon = (item["type"] == "weapon" and item["name"].lower() not in self._invalid_weapons)
if is_valid_weapon:
yield item["name"].lower()
def armor(self):