Broaden type hints to Entity where applicable

This commit is contained in:
Jared Miller 2026-02-07 20:32:15 -05:00
parent 028dcb51b8
commit 910597e92d
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -3,6 +3,7 @@
from typing import Any from typing import Any
from mudlib.commands import CommandDefinition, register from mudlib.commands import CommandDefinition, register
from mudlib.entity import Entity
from mudlib.player import Player, players from mudlib.player import Player, players
# World instance will be injected by the server # World instance will be injected by the server
@ -93,11 +94,11 @@ async def move_player(player: Player, dx: int, dy: int, direction_name: str) ->
await cmd_look(player, "") await cmd_look(player, "")
async def send_nearby_message(player: Player, x: int, y: int, message: str) -> None: async def send_nearby_message(entity: Entity, x: int, y: int, message: str) -> None:
"""Send a message to all players near a location, excluding the player. """Send a message to all players near a location, excluding the entity.
Args: Args:
player: The player who triggered the message (excluded from receiving it) entity: The entity who triggered the message (excluded from receiving it)
x: X coordinate of the location x: X coordinate of the location
y: Y coordinate of the location y: Y coordinate of the location
message: The message to send message: The message to send
@ -106,7 +107,7 @@ async def send_nearby_message(player: Player, x: int, y: int, message: str) -> N
viewport_range = 10 viewport_range = 10
for other in players.values(): for other in players.values():
if other.name == player.name: if other.name == entity.name:
continue continue
# Check if other player is within viewport range (wrapping) # Check if other player is within viewport range (wrapping)