34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""Resting system for stamina regeneration."""
|
|
|
|
from mudlib.commands.movement import send_nearby_message
|
|
from mudlib.gmcp import send_char_status, send_char_vitals
|
|
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
|
|
send_char_status(player)
|
|
send_char_vitals(player)
|
|
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"
|
|
)
|