diff --git a/content/help/zones.toml b/content/help/zones.toml new file mode 100644 index 0000000..bcefbce --- /dev/null +++ b/content/help/zones.toml @@ -0,0 +1,21 @@ +name = "zones" +title = "zones" +admin = true +body = """ + zones are spatial containers - rooms, dungeons, overworld areas. + each zone has a terrain grid, spawn point, and optional portals. + + listing zones + @zones list all registered zones + + navigating + @goto teleport to a zone's spawn point + enter step through a portal to another zone + + building + @dig create a new blank zone + @paint toggle paint mode for terrain editing + @save save current zone to file + + see: @zones, @goto, @dig, @paint, @save +""" diff --git a/src/mudlib/commands/help.py b/src/mudlib/commands/help.py index 9b08534..c80e446 100644 --- a/src/mudlib/commands/help.py +++ b/src/mudlib/commands/help.py @@ -357,30 +357,6 @@ async def cmd_client(player: Player, args: str) -> None: await player.send("\r\n".join(lines) + "\r\n") -async def cmd_zones_help(player: Player, args: str) -> None: - """Show the zones guide.""" - lines = [ - "zones", - " zones are spatial containers - rooms, dungeons, overworld areas.", - " each zone has a terrain grid, spawn point, and optional portals.", - "", - " listing zones", - " @zones list all registered zones", - "", - " navigating", - " @goto teleport to a zone's spawn point", - " enter step through a portal to another zone", - "", - " building", - " @dig create a new blank zone", - " @paint toggle paint mode for terrain editing", - " @save save current zone to file", - "", - " see: @zones, @goto, @dig, @paint, @save", - ] - await player.send("\r\n".join(lines) + "\r\n") - - # Register the commands command register( CommandDefinition( @@ -414,18 +390,6 @@ register( ) ) -# Register the zones help topic -register( - CommandDefinition( - "zones", - cmd_zones_help, - mode="*", - hidden=True, - admin=True, - help="zone building guide", - ) -) - async def cmd_help(player: Player, args: str) -> None: """Show help for a command or skill. diff --git a/tests/test_help_command.py b/tests/test_help_command.py index 2dd3119..cbf12c7 100644 --- a/tests/test_help_command.py +++ b/tests/test_help_command.py @@ -12,6 +12,8 @@ from mudlib.commands import ( look, # noqa: F401 movement, # noqa: F401 ) +from mudlib.commands.help import _help_topics +from mudlib.content import load_help_topics @pytest.fixture @@ -43,6 +45,19 @@ def admin_player(mock_reader, mock_writer): return p +@pytest.fixture(autouse=True) +def _load_zones_topic(): + """Load the zones help topic for tests that need it.""" + from pathlib import Path + + help_dir = Path(__file__).resolve().parents[1] / "content" / "help" + if help_dir.exists(): + loaded = load_help_topics(help_dir) + _help_topics.update(loaded) + yield + _help_topics.clear() + + @pytest.mark.asyncio async def test_help_command_is_registered(): """The help command should be registered in the command registry.""" @@ -117,9 +132,6 @@ async def test_help_zones_shows_see_also(admin_player): @pytest.mark.asyncio async def test_help_zones_requires_admin(player): """Non-admin players cannot see admin help topics.""" - # Import build to ensure @zones help topic is registered - from mudlib.commands import build # noqa: F401 - await commands.dispatch(player, "help zones") output = "".join([call[0][0] for call in player.writer.write.call_args_list]) assert "unknown" in output.lower() diff --git a/tests/test_help_topics.py b/tests/test_help_topics.py index af89eed..2e601b3 100644 --- a/tests/test_help_topics.py +++ b/tests/test_help_topics.py @@ -144,3 +144,13 @@ async def test_help_admin_topic_visible_to_admins(admin_player): await commands.dispatch(admin_player, "help secret") output = "".join(c[0][0] for c in admin_player.writer.write.call_args_list) assert "hidden" in output + + +def test_zones_toml_loads_from_content(): + from pathlib import Path + + help_dir = Path(__file__).resolve().parents[1] / "content" / "help" + topics = load_help_topics(help_dir) + assert "zones" in topics + assert topics["zones"].admin is True + assert "@zones" in topics["zones"].body