Use entity.send() for nearby message broadcasting
This commit is contained in:
parent
fea563f158
commit
3cba2cdb7a
1 changed files with 2 additions and 4 deletions
|
|
@ -69,8 +69,7 @@ async def move_player(player: Player, dx: int, dy: int, direction_name: str) ->
|
||||||
|
|
||||||
# Check if the target is passable
|
# Check if the target is passable
|
||||||
if not world.is_passable(target_x, target_y):
|
if not world.is_passable(target_x, target_y):
|
||||||
player.writer.write("You can't go that way.\r\n")
|
await player.send("You can't go that way.\r\n")
|
||||||
await player.writer.drain()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Send departure message to players in the old area
|
# Send departure message to players in the old area
|
||||||
|
|
@ -116,8 +115,7 @@ async def send_nearby_message(player: Player, x: int, y: int, message: str) -> N
|
||||||
dx_dist = min(dx_dist, world.width - dx_dist)
|
dx_dist = min(dx_dist, world.width - dx_dist)
|
||||||
dy_dist = min(dy_dist, world.height - dy_dist)
|
dy_dist = min(dy_dist, world.height - dy_dist)
|
||||||
if dx_dist <= viewport_range and dy_dist <= viewport_range:
|
if dx_dist <= viewport_range and dy_dist <= viewport_range:
|
||||||
other.writer.write(message)
|
await other.send(message)
|
||||||
await other.writer.drain()
|
|
||||||
|
|
||||||
|
|
||||||
# Define individual movement command handlers
|
# Define individual movement command handlers
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue