"""Tests for Player client capabilities integration."""

from mudlib.caps import ClientCaps
from mudlib.player import Player


def test_player_default_caps():
    """Player has default 16-color ANSI caps when created without explicit caps."""
    player = Player(name="TestPlayer", x=0, y=0)
    assert player.caps.ansi is True
    assert player.caps.colors_256 is False
    assert player.caps.truecolor is False
    assert player.color_depth == "16"


def test_player_caps_truecolor():
    """Player with truecolor caps reports truecolor depth."""
    caps = ClientCaps(ansi=True, utf8=True, colors_256=True, truecolor=True)
    player = Player(name="TestPlayer", x=0, y=0, caps=caps)
    assert player.color_depth == "truecolor"


def test_player_caps_256():
    """Player with 256-color caps reports 256 depth."""
    caps = ClientCaps(ansi=True, utf8=True, colors_256=True, truecolor=False)
    player = Player(name="TestPlayer", x=0, y=0, caps=caps)
    assert player.color_depth == "256"


def test_player_caps_16():
    """Player with basic ANSI caps reports 16 depth."""
    caps = ClientCaps(ansi=True, utf8=True)
    player = Player(name="TestPlayer", x=0, y=0, caps=caps)
    assert player.color_depth == "16"


def test_player_caps_property_delegates():
    """Player.color_depth delegates to caps.color_depth."""
    player = Player(name="TestPlayer", x=0, y=0)
    # Modify caps and verify color_depth reflects the change
    player.caps = ClientCaps(ansi=True, colors_256=True, truecolor=True)
    assert player.color_depth == "truecolor"

    player.caps = ClientCaps(ansi=True, colors_256=True, truecolor=False)
    assert player.color_depth == "256"

    player.caps = ClientCaps(ansi=True)
    assert player.color_depth == "16"
