nodes/well.pyΒΆ
Part of Dungeon Explorer.
1"""The Well: coin toss to re-roll the dungeon, resets save points."""
2
3from simvx.core import Node2D
4
5
6class Well(Node2D):
7 """Well mechanic: toss a coin to re-roll the dungeon."""
8
9 BASE_COST = 50
10
11 def __init__(self, **kwargs):
12 super().__init__(name="Well", **kwargs)
13
14 @staticmethod
15 def get_cost(max_floor: int) -> int:
16 """Cost scales with highest floor cleared: 50 + 5 per floor."""
17 return Well.BASE_COST + max(0, max_floor) * 5
18
19 @staticmethod
20 def can_reroll(gold: int, max_floor: int = 0) -> bool:
21 return gold >= Well.get_cost(max_floor)
22
23 @staticmethod
24 def reroll(player, game_manager) -> bool:
25 """Toss a coin: re-roll dungeon and reset save points.
26
27 Returns True on success.
28 """
29 cost = Well.get_cost(game_manager.max_dungeon_reached)
30 if player.gold < cost:
31 return False
32 player.gold -= cost
33 game_manager.reroll_dungeon()
34 return True