"""Tests for the score/stats/profile command.""" import pytest from mudlib.commands.score import cmd_score @pytest.mark.asyncio async def test_score_shows_player_name(player, mock_writer): """Score command displays the player's name.""" player.name = "Goku" await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "Goku" in output @pytest.mark.asyncio async def test_score_shows_pl_and_stamina(player, mock_writer): """Score command displays PL and stamina gauges.""" player.pl = 75 player.max_pl = 100 player.stamina = 80 player.max_stamina = 100 await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "75" in output assert "100" in output assert "80" in output @pytest.mark.asyncio async def test_score_shows_kill_death_stats(player, mock_writer): """Score command displays kills, deaths, and K/D ratio.""" player.kills = 10 player.deaths = 2 await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "10" in output # kills assert "2" in output # deaths assert "5.0" in output # K/D ratio @pytest.mark.asyncio async def test_score_shows_kd_ratio_na_with_zero_deaths(player, mock_writer): """Score command shows N/A for K/D ratio when deaths is zero.""" player.kills = 5 player.deaths = 0 await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "N/A" in output @pytest.mark.asyncio async def test_score_shows_time_played(player, mock_writer): """Score command formats and displays play time.""" player.play_time_seconds = 3661 # 1h 1m 1s player.session_start = 0 # No active session await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "1h" in output assert "1m" in output assert "1s" in output @pytest.mark.asyncio async def test_score_shows_unlocked_moves(player, mock_writer): """Score command displays unlocked moves.""" player.unlocked_moves = {"roundhouse", "sweep"} await cmd_score(player, "") messages = [call[0][0] for call in player.writer.write.call_args_list] output = "".join(messages) assert "roundhouse" in output assert "sweep" in output @pytest.mark.asyncio async def test_command_registered_with_aliases(player, mock_writer): """Score command is accessible via score, stats, and profile.""" from mudlib.commands import CommandDefinition, resolve_prefix score_cmd = resolve_prefix("score") stats_cmd = resolve_prefix("stats") profile_cmd = resolve_prefix("profile") assert isinstance(score_cmd, CommandDefinition) assert isinstance(stats_cmd, CommandDefinition) assert isinstance(profile_cmd, CommandDefinition) assert score_cmd.handler == stats_cmd.handler == profile_cmd.handler