"""Tests for the Vogon ship section."""

from tests.conftest import send


def test_hold_exists(game):
    """Verify the Hold room was registered."""
    state, _, _ = game
    hold = state.world.get_room("HOLD")
    assert hold is not None
    assert hold.id == "HOLD"


def test_hold_first_visit(game):
    """Test that the Hold's first-visit M-END sequence gives peanuts and score."""
    state, _, loop = game
    hold = state.world.get_room("HOLD")
    state.here = hold
    state.protagonist.move_to(hold)
    state.lying_down = False
    # The first-visit logic is in M-END, not M-ENTER
    if hold.action:
        hold.action(state, "M-END")
    text = state.output.flush()
    # Should mention waking up and give peanuts
    assert len(text) > 0
    assert state.score >= 8
    peanuts = state.world.get("PEANUTS")
    assert peanuts.parent is state.protagonist


def test_airlock_room_exists(game):
    """Verify the Airlock room was registered."""
    state, _, _ = game
    airlock = state.world.get_room("AIRLOCK")
    assert airlock is not None
    assert airlock.id == "AIRLOCK"


def test_captains_quarters_exists(game):
    """Verify the Captain's Quarters room was registered."""
    state, _, _ = game
    quarters = state.world.get_room("CAPTAINS-QUARTERS")
    assert quarters is not None
