Skip to content

Commit

Permalink
move periodical to driver
Browse files Browse the repository at this point in the history
  • Loading branch information
neph1 committed Jul 17, 2024
1 parent 8453caf commit 35ef32a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 8 additions & 1 deletion tale/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def start(self, game_file_or_path: str) -> None:
x._bind_target(self.zones)
self.unbound_exits = []
sys.excepthook = util.excepthook # install custom verbose crash reporter
self.register_periodicals(self)
self.start_main_loop() # doesn't exit! (unless game is killed)
self._stop_driver()

Expand Down Expand Up @@ -958,4 +959,10 @@ def build_location(self, targetLocation: base.Location, zone: Zone, player: play
return True

def do_on_player_death(self, player: player.Player) -> None:
pass
pass

@util.call_periodically(10)
def replenish(self):
for player in self.all_players.values():
player.player.stats.replenish_hp(1)
player.player.stats.replenish_combat_points(1)
7 changes: 1 addition & 6 deletions tale/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,4 @@ def destroy(self) -> None:
self.io = None # type: ignore
if self.player:
self.player.destroy(ctx)
self.player = None # type: ignore

@call_periodically(10)
def replenish(self) -> None:
self.stats.replenish_hp(1)
self.stats.replenish_combat_points(1)
self.player = None # type: ignore

0 comments on commit 35ef32a

Please sign in to comment.