Entity gains location from Object and narrows x/y back to int (entities always have spatial coordinates). No behavioral change — all existing tests pass unchanged.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Base entity class for characters in the world."""
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from mudlib.object import Object
|
|
|
|
|
|
@dataclass
|
|
class Entity(Object):
|
|
"""Base class for anything with position and identity in the world.
|
|
|
|
Inherits name, location from Object. Narrows x, y to int (entities
|
|
always have spatial coordinates).
|
|
"""
|
|
|
|
# Entities always have spatial coordinates (override Object's int | None)
|
|
x: int = 0
|
|
y: int = 0
|
|
# Combat stats
|
|
pl: float = 100.0 # power level (health and damage multiplier)
|
|
stamina: float = 100.0 # current stamina
|
|
max_stamina: float = 100.0 # stamina ceiling
|
|
defense_locked_until: float = 0.0 # monotonic time when defense recovery ends
|
|
resting: bool = False # whether this entity is currently resting
|
|
|
|
async def send(self, message: str) -> None:
|
|
"""Send a message to this entity. Base implementation is a no-op."""
|
|
pass
|
|
|
|
|
|
@dataclass
|
|
class Mob(Entity):
|
|
"""Represents a non-player character (NPC) in the world."""
|
|
|
|
description: str = ""
|
|
alive: bool = True
|
|
moves: list[str] = field(default_factory=list)
|
|
next_action_at: float = 0.0
|