Skip to content

Commit

Permalink
fix: set maximum character level to 20
Browse files Browse the repository at this point in the history
  • Loading branch information
leomartius committed Dec 20, 2024
1 parent 0f4d3dc commit d1be910
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions game/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def level_up(player: Actor, log: MessageLog) -> None:
while player.stats.xp >= threshold:
level += 1
threshold *= 2
level = min(level, 20)
if level > player.stats.hd:
log.append(f"Welcome to level {level}!")
hp_gain = roll(level - player.stats.hd, d=10)
Expand Down
5 changes: 4 additions & 1 deletion game/consumable.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def use(self, actor: Actor, level: Level, log: MessageLog) -> None:
@dataclass(frozen=True, slots=True)
class RaiseLevel(Consumable):
def use(self, actor: Actor, level: Level, log: MessageLog) -> None:
actor.stats.xp = 5 * 2**actor.stats.hd + 1
target_xp = 10
while target_xp <= actor.stats.xp:
target_xp *= 2
actor.stats.xp = target_xp + 1
log.append("You suddenly feel much more skillful.")
level_up(actor, log)

Expand Down

0 comments on commit d1be910

Please sign in to comment.