Skip to content

Commit

Permalink
style: 🚨 black + isort
Browse files Browse the repository at this point in the history
  • Loading branch information
qthequartermasterman committed Dec 15, 2023
1 parent ef636f1 commit f60fbe3
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 325 deletions.
2 changes: 1 addition & 1 deletion render_blocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from render_blocks.main import *
from render_blocks.main import *
4 changes: 2 additions & 2 deletions render_blocks/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Literal

COMBAT_DICE = '<img src="/Assets/combat_dice.png" class="combat-dice" alt="CD"></img>'
TAG_SKILL = '■'
TAG_SKILL = "■"
BULLET = "▪"
AttributeName = Literal["STR", "PER", "END", "CHA", "INT", "AGI", "LCK", "BODY", "MIND"]
SkillName = Literal[
Expand All @@ -26,5 +26,5 @@
"Unarmed",
"Melee",
"Guns",
"Other"
"Other",
]
14 changes: 10 additions & 4 deletions render_blocks/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import pathlib

from render_blocks.constants import COMBAT_DICE, TAG_SKILL, BULLET
from render_blocks.stats import Special, Entity, Character, Skill, Skills, Attack, Equipment, SpecialAbility, Creature
from render_blocks.constants import BULLET, COMBAT_DICE, TAG_SKILL
from render_blocks.stats import (Attack, Character, Creature, Entity,
Equipment, Skill, Skills, Special,
SpecialAbility)


def render_special(special: Special) -> str:
Expand Down Expand Up @@ -159,7 +161,9 @@ def render_attacks(attacks: list[Attack] | None, character: Entity) -> str:
def render_inventory(
inventory: list[Equipment] | None, butchery: str | None = None
) -> str:
rows = f"<tr><td><b> {BULLET} BUTCHERY:</b> {butchery} </td></tr>" if butchery else ""
rows = (
f"<tr><td><b> {BULLET} BUTCHERY:</b> {butchery} </td></tr>" if butchery else ""
)
if inventory:
rows += (
f"<tr><td>{', '.join(str(equipment) for equipment in inventory)}</td></tr>"
Expand Down Expand Up @@ -248,6 +252,7 @@ def render_body_mind_melee_guns_other(creature: Creature) -> str:
</div>
"""


def render_character_block(character: dict[str, Any]):
character = Character(**character)
return f"""<div class="character">
Expand All @@ -267,6 +272,7 @@ def render_character_block(character: dict[str, Any]):
</div>
"""


def render_creature_block(creature: dict[str, Any]):
creature = Creature(**creature)
return f"""<div class="character">
Expand All @@ -283,4 +289,4 @@ def render_creature_block(creature: dict[str, Any]):
{render_special_abilities(creature.special_abilities)}
{render_inventory(creature.inventory, creature.butchery)}
</div>
"""
"""
35 changes: 25 additions & 10 deletions render_blocks/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from render_blocks import constants


EmptySkill = pydantic.Field(default_factory=lambda: Skill(rank=0, tag=False))


class Attack(pydantic.BaseModel):
name: str
target_attr: constants.AttributeName
Expand Down Expand Up @@ -176,17 +176,30 @@ def hp(self) -> int:
@pydantic.model_validator(mode="after")
def validate_attr(self) -> "Creature":
if self.type == Type.normal:
if self.body + self.mind != (expected_total_attr := math.ceil(8 + self.level/2)):
raise ValueError(f"Normal creatures must have a total of {expected_total_attr} (ceil(8 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points.")
if self.body + self.mind != (
expected_total_attr := math.ceil(8 + self.level / 2)
):
raise ValueError(
f"Normal creatures must have a total of {expected_total_attr} (ceil(8 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points."
)
elif self.type == Type.mighty:
if self.body + self.mind != (expected_total_attr := math.ceil(10 + self.level/2)):
raise ValueError(f"Mighty creatures must have a total of of {expected_total_attr} (ceil(10 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points.")
if self.body + self.mind != (
expected_total_attr := math.ceil(10 + self.level / 2)
):
raise ValueError(
f"Mighty creatures must have a total of of {expected_total_attr} (ceil(10 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points."
)
elif self.type == Type.legendary:
if self.body + self.mind != (expected_total_attr := math.ceil(12 + self.level/2)):
raise ValueError(f"Legendary creatures must have a total of of {expected_total_attr} (ceil(12 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points.")

if self.body + self.mind != (
expected_total_attr := math.ceil(12 + self.level / 2)
):
raise ValueError(
f"Legendary creatures must have a total of of {expected_total_attr} (ceil(12 + level/2)) BODY + MIND points, but this creature has {self.body + self.mind} points."
)

def get_target_number(self, target_attr: constants.AttributeName, target_skill: str) -> int:
def get_target_number(
self, target_attr: constants.AttributeName, target_skill: str
) -> int:
if target_attr == "BODY":
attr = self.body
elif target_attr == "MIND":
Expand Down Expand Up @@ -321,7 +334,9 @@ def validate_skills(self) -> "Character":

return self

def get_target_number(self, target_attr: constants.AttributeName, target_skill: str) -> int:
def get_target_number(
self, target_attr: constants.AttributeName, target_skill: str
) -> int:
if target_attr == "STR":
attr = self.special.strength
elif target_attr == "PER":
Expand Down
2 changes: 1 addition & 1 deletion render_map/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from render_map.render_map import *
from render_map.render_map import *
31 changes: 23 additions & 8 deletions render_map/map_icons.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import enum


class MapIcon(enum.Enum):
SETTLEMENT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/f/f9/163.svg"
SETTLEMENT = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/f/f9/163.svg"
)
FARM = "https://static.wikia.nocookie.net/fallout_gamepedia/images/3/32/156.svg"
LARGE_SETTLEMENT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/8/8a/38.svg"
LARGE_SETTLEMENT = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/8/8a/38.svg"
)

ROCKET = "https://static.wikia.nocookie.net/fallout_gamepedia/images/c/ce/153.svg"
SATELLITE = "https://static.wikia.nocookie.net/fallout_gamepedia/images/e/ea/47.svg"
Expand All @@ -15,28 +20,38 @@ class MapIcon(enum.Enum):
DRILL = "https://static.wikia.nocookie.net/fallout_gamepedia/images/f/f1/Drill.svg"
WAREHOUSE = "https://static.wikia.nocookie.net/fallout_gamepedia/images/0/03/99.svg"

MONUMENT ="https://static.wikia.nocookie.net/fallout_gamepedia/images/6/6a/209.svg"
CLOCK_TOWER = "https://static.wikia.nocookie.net/fallout_gamepedia/images/2/21/182.svg"
MONUMENT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/6/6a/209.svg"
CLOCK_TOWER = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/2/21/182.svg"
)

BASEBALL = "https://static.wikia.nocookie.net/fallout_gamepedia/images/b/bd/176.svg"

BROTHERHOOD_OF_STEEL = "https://static.wikia.nocookie.net/fallout_gamepedia/images/0/01/215.svg"
BROTHERHOOD_OF_STEEL = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/0/01/215.svg"
)

AIRPORT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/e/eb/218.svg"

VAULT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/1/12/8.svg"

TREE = "https://static.wikia.nocookie.net/fallout_gamepedia/images/4/41/Tree.svg/"

RADIATION = "https://static.wikia.nocookie.net/fallout_gamepedia/images/5/5c/65.svg/"
RADIATION = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/5/5c/65.svg/"
)

GOVERNMENT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/2/2e/105.svg"
GOVERNMENT = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/2/2e/105.svg"
)
MILITARY = "https://static.wikia.nocookie.net/fallout_gamepedia/images/5/50/111.svg"
CHURCH = "https://static.wikia.nocookie.net/fallout_gamepedia/images/2/2c/191.svg"
CITY = "https://static.wikia.nocookie.net/fallout_gamepedia/images/e/ee/188.svg"
HOSPITAL = "https://static.wikia.nocookie.net/fallout_gamepedia/images/4/40/141.svg"
FACTORY = "https://static.wikia.nocookie.net/fallout_gamepedia/images/3/3e/135.svg"
WATER_TREATMENT = "https://static.wikia.nocookie.net/fallout_gamepedia/images/a/a7/138.svg"
WATER_TREATMENT = (
"https://static.wikia.nocookie.net/fallout_gamepedia/images/a/a7/138.svg"
)

SWAMP = "https://static.wikia.nocookie.net/fallout_gamepedia/images/f/fe/85.svg"

Expand Down
Loading

0 comments on commit f60fbe3

Please sign in to comment.