"""Tests for player description and home_zone fields."""

from unittest.mock import AsyncMock, MagicMock

import pytest

from mudlib.player import Player


@pytest.fixture
def mock_writer():
    writer = MagicMock()
    writer.write = MagicMock()
    writer.drain = AsyncMock()
    return writer


@pytest.fixture
def mock_reader():
    return MagicMock()


def test_player_default_description(mock_reader, mock_writer):
    """Test that Player has default empty description."""
    player = Player(name="Hero", x=0, y=0, reader=mock_reader, writer=mock_writer)
    assert player.description == ""


def test_player_default_home_zone(mock_reader, mock_writer):
    """Test that Player has default None home_zone."""
    player = Player(name="Hero", x=0, y=0, reader=mock_reader, writer=mock_writer)
    assert player.home_zone is None


def test_player_default_return_location(mock_reader, mock_writer):
    """Test that Player has default None return_location."""
    player = Player(name="Hero", x=0, y=0, reader=mock_reader, writer=mock_writer)
    assert player.return_location is None


def test_player_custom_description(mock_reader, mock_writer):
    """Test that Player can have custom description."""
    player = Player(
        name="Hero",
        x=0,
        y=0,
        reader=mock_reader,
        writer=mock_writer,
        description="A brave adventurer",
    )
    assert player.description == "A brave adventurer"


def test_player_custom_home_zone(mock_reader, mock_writer):
    """Test that Player can have custom home_zone."""
    player = Player(
        name="Hero",
        x=0,
        y=0,
        reader=mock_reader,
        writer=mock_writer,
        home_zone="residential",
    )
    assert player.home_zone == "residential"


def test_player_custom_return_location(mock_reader, mock_writer):
    """Test that Player can have custom return_location."""
    player = Player(
        name="Hero",
        x=0,
        y=0,
        reader=mock_reader,
        writer=mock_writer,
        return_location=("residential", 10, 20),
    )
    assert player.return_location == ("residential", 10, 20)


def test_player_all_housing_fields(mock_reader, mock_writer):
    """Test that Player can have all housing fields set together."""
    player = Player(
        name="Hero",
        x=0,
        y=0,
        reader=mock_reader,
        writer=mock_writer,
        description="A homeowner",
        home_zone="residential",
        return_location=("residential", 5, 15),
    )
    assert player.description == "A homeowner"
    assert player.home_zone == "residential"
    assert player.return_location == ("residential", 5, 15)
