"""Resting system for stamina regeneration.""" from mudlib.commands.movement import send_nearby_message from mudlib.player import players # Stamina regeneration rate: 2.0 per second # At 10 ticks/sec, that's 0.2 per tick STAMINA_PER_TICK = 0.2 async def process_resting() -> None: """Process stamina regeneration for all resting players. Called once per game loop tick (10 times per second). Adds STAMINA_PER_TICK stamina to each resting player. Auto-stops resting when stamina reaches max. """ for player in list(players.values()): if not player.resting: continue # Add stamina for this tick player.stamina = min(player.stamina + STAMINA_PER_TICK, player.max_stamina) # Check if we reached max stamina if player.stamina >= player.max_stamina: player.resting = False await player.send("You feel fully rested.\r\n") await send_nearby_message( player, player.x, player.y, f"{player.name} stops resting.\r\n" )