diff options
| author | Supremist <sergkarv@gmail.com> | 2025-10-28 23:47:23 +0200 |
|---|---|---|
| committer | Supremist <sergkarv@gmail.com> | 2025-10-28 23:47:23 +0200 |
| commit | f2c7dbddb602db06ec8e8a8c9a4134451acd52e9 (patch) | |
| tree | e3d2e0e7900baf8057efc4e0813065ff16990b34 /creature.py | |
| parent | e0911bc676e92ce15b7096b2e85f8b3965a48823 (diff) | |
| download | pf2e_calc-f2c7dbddb602db06ec8e8a8c9a4134451acd52e9.tar.xz pf2e_calc-f2c7dbddb602db06ec8e8a8c9a4134451acd52e9.zip | |
Move common data structs to game.py
Diffstat (limited to 'creature.py')
| -rw-r--r-- | creature.py | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/creature.py b/creature.py index aa2f7f4..e30f877 100644 --- a/creature.py +++ b/creature.py @@ -1,43 +1,6 @@ import csv -import re -from enum import Enum -from dataclasses import dataclass - -class Difficulty(Enum): - Terrible = -2 - Low = -1 - Moderate = 0 - High = 1 - Extreme = 2 - - @classmethod - def from_str(cls, name): - name = name.strip().lower() - for member in cls: - if member.name.lower() == name: - return member - raise ValueError(f"{name!r} is not a valid {cls.__name__}") - -@dataclass -class RollInfo: - die_size: int - dice_count: int = 1 - bonus: int = 0 - - @classmethod - def parse(cls, str_data): - # match strings like 2d6+8 (15) - match = re.fullmatch(r"^(\d+)d(\d+)\s*(\+\s*\d+)?\s*(\s*\(\s*\d+\s*\))?", - str_data) - if not match: - raise ValueError(f"{str_data!r} is not a valid RollInfo") - res = RollInfo(int(match.group(2).strip())) - res.dice_count = int(match.group(1).strip()) - bonus = match.group(3) - if bonus: - res.bonus = int(bonus.strip(" +")) - return res +from game import Difficulty, RollInfo def safe_item_level(creature_level: int): if creature_level <= 3: |
