feat(combat): metamagic

This commit is contained in:
ctan
2026-08-29 20:44:17 +02:00
parent 53aa3567f2
commit beee8e4e6a
3 changed files with 137 additions and 45 deletions
+4 -2
View File
@@ -80,10 +80,12 @@ class DiceExpr(BaseModel):
def mean(self) -> float:
"""Expected value: count * (sides + 1) / 2 + bonus."""
if self.count == 0:
return float(self.bonus)
return self.count * (self.sides + 1) / 2 + self.bonus
def max_value(self) -> int:
"""Maximum possible value: count * sides + bonus."""
return self.count * self.sides + self.bonus
def parse_dice(text: str) -> DiceExpr:
"""Parse a dice notation string into a DiceExpr.