33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Rest command for restoring stamina."""
|
|
|
|
from mudlib.commands.movement import send_nearby_message
|
|
from mudlib.player import Player
|
|
|
|
|
|
async def cmd_rest(player: Player, args: str) -> None:
|
|
"""Toggle resting state to restore stamina over time.
|
|
|
|
Cannot rest if stamina is already full.
|
|
Broadcasts to nearby players when beginning and ending rest.
|
|
Stamina restoration happens via the game loop while resting.
|
|
"""
|
|
# Check if stamina is already full
|
|
if player.stamina >= player.max_stamina:
|
|
await player.send("You're not tired.\r\n")
|
|
return
|
|
|
|
# Toggle resting state
|
|
if player.resting:
|
|
# Stop resting
|
|
player.resting = False
|
|
await player.send("You stop resting.\r\n")
|
|
await send_nearby_message(
|
|
player, player.x, player.y, f"{player.name} stops resting.\r\n"
|
|
)
|
|
else:
|
|
# Start resting
|
|
player.resting = True
|
|
await player.send("You begin to rest.\r\n")
|
|
await send_nearby_message(
|
|
player, player.x, player.y, f"{player.name} begins to rest.\r\n"
|
|
)
|