Enrich GMCP Char.Status with admin, coords, and paint state
This commit is contained in:
parent
115675c02e
commit
7ae82480bc
2 changed files with 59 additions and 1 deletions
|
|
@ -27,7 +27,7 @@ def send_char_vitals(player: Player) -> None:
|
|||
|
||||
|
||||
def send_char_status(player: Player) -> None:
|
||||
"""Send Char.Status — flying, resting, mode, in_combat."""
|
||||
"""Send Char.Status — flying, resting, mode, in_combat, plus context."""
|
||||
if not player.gmcp_enabled:
|
||||
return
|
||||
player.send_gmcp(
|
||||
|
|
@ -37,6 +37,12 @@ def send_char_status(player: Player) -> None:
|
|||
"resting": player.resting,
|
||||
"mode": player.mode,
|
||||
"in_combat": player.mode == "combat",
|
||||
"is_admin": player.is_admin,
|
||||
"x": player.x,
|
||||
"y": player.y,
|
||||
"paint_mode": player.paint_mode,
|
||||
"painting": player.painting,
|
||||
"paint_brush": player.paint_brush,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,12 @@ def test_send_char_status_normal_mode(player):
|
|||
"resting": False,
|
||||
"mode": "normal",
|
||||
"in_combat": False,
|
||||
"is_admin": False,
|
||||
"x": 10,
|
||||
"y": 10,
|
||||
"paint_mode": False,
|
||||
"painting": False,
|
||||
"paint_brush": ".",
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -577,3 +583,49 @@ def test_gmcp_sends_skipped_when_not_negotiated(player):
|
|||
send_map_data(player)
|
||||
|
||||
player.writer.send_gmcp.assert_not_called()
|
||||
|
||||
|
||||
def test_char_status_includes_admin_flag(player):
|
||||
"""Test Char.Status includes is_admin field."""
|
||||
player.is_admin = True
|
||||
send_char_status(player)
|
||||
|
||||
args = player.writer.send_gmcp.call_args[0]
|
||||
assert args[1]["is_admin"] is True
|
||||
|
||||
|
||||
def test_char_status_includes_coordinates(player):
|
||||
"""Test Char.Status includes x/y coordinates."""
|
||||
player.x = 42
|
||||
player.y = 13
|
||||
send_char_status(player)
|
||||
|
||||
args = player.writer.send_gmcp.call_args[0]
|
||||
assert args[1]["x"] == 42
|
||||
assert args[1]["y"] == 13
|
||||
|
||||
|
||||
def test_char_status_includes_paint_state(player):
|
||||
"""Test Char.Status includes paint mode fields."""
|
||||
player.paint_mode = True
|
||||
player.painting = True
|
||||
player.paint_brush = "#"
|
||||
send_char_status(player)
|
||||
|
||||
args = player.writer.send_gmcp.call_args[0]
|
||||
assert args[1]["paint_mode"] is True
|
||||
assert args[1]["painting"] is True
|
||||
assert args[1]["paint_brush"] == "#"
|
||||
|
||||
|
||||
def test_char_status_paint_mode_off(player):
|
||||
"""Test Char.Status includes paint fields even when paint mode is off."""
|
||||
player.paint_mode = False
|
||||
player.painting = False
|
||||
player.paint_brush = "."
|
||||
send_char_status(player)
|
||||
|
||||
args = player.writer.send_gmcp.call_args[0]
|
||||
assert args[1]["paint_mode"] is False
|
||||
assert args[1]["painting"] is False
|
||||
assert args[1]["paint_brush"] == "."
|
||||
|
|
|
|||
Loading…
Reference in a new issue