Combat moves defined as TOML content files in content/combat/, not engine code. State machine (IDLE > TELEGRAPH > WINDOW > RESOLVE) processes timing-based exchanges. Counter relationships, stamina costs, damage formulas all tunable from data files. Moves: punch right/left, roundhouse, sweep, dodge right/left, parry high/low, duck, jump. Combat ends on knockout (PL <= 0) or exhaustion (stamina <= 0).
30 lines
829 B
Python
30 lines
829 B
Python
"""Player state and registry."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
from mudlib.entity import Entity
|
|
|
|
|
|
@dataclass
|
|
class Player(Entity):
|
|
"""Represents a connected player."""
|
|
|
|
writer: Any = None # telnetlib3 TelnetWriter for sending output
|
|
reader: Any = None # telnetlib3 TelnetReader for reading input
|
|
flying: bool = False
|
|
mode_stack: list[str] = field(default_factory=lambda: ["normal"])
|
|
|
|
@property
|
|
def mode(self) -> str:
|
|
"""Current mode is the top of the stack."""
|
|
return self.mode_stack[-1]
|
|
|
|
async def send(self, message: str) -> None:
|
|
"""Send a message to the player via their telnet writer."""
|
|
self.writer.write(message)
|
|
await self.writer.drain()
|
|
|
|
|
|
# Global registry of connected players
|
|
players: dict[str, Player] = {}
|