feat(models): combat resources
This commit is contained in:
@@ -180,9 +180,18 @@ class CombatantState:
|
||||
# New duration-tracked fields
|
||||
active_buffs: list[ActiveBuff] = field(default_factory=list)
|
||||
active_conditions: list[ActiveCondition] = field(default_factory=list)
|
||||
resources_left: dict[str, int] = field(default_factory=dict)
|
||||
moved_this_turn: bool = False
|
||||
power_attack: bool = False
|
||||
|
||||
def spend_resource(self, name: str, n: int = 1) -> bool:
|
||||
"""Spend n points of a resource. Returns True if successful, False if insufficient."""
|
||||
current = self.resources_left.get(name, 0)
|
||||
if current < n:
|
||||
return False
|
||||
self.resources_left[name] = current - n
|
||||
return True
|
||||
|
||||
@property
|
||||
def active(self) -> bool:
|
||||
return self.hp > 0
|
||||
|
||||
@@ -111,6 +111,7 @@ def build_states(spec: EncounterSpec) -> list[CombatantState]:
|
||||
side=side.name,
|
||||
pos=pos,
|
||||
hp=effective.hp_max,
|
||||
resources_left=dict(effective.resources),
|
||||
)
|
||||
)
|
||||
return states
|
||||
|
||||
Reference in New Issue
Block a user