679639df9f
Transitions: - Add I-HOUSEWRECK (tick 20) and I-VOGONS (tick 50) timed events to earth.py, queued at startup in main.py - I-VOGONS demolishes Earth and moves player to Vogon Hold - Fix airlock→Dark transition to call Dark room M-ENTER handler - Fix dream-restore to support multiple callbacks (list instead of single) - Add state.finish() call to RAMP for endgame victory Guide system: - Add 16-entry lookup database to GUIDE object (space, towel, vogons, poetry, beast, babel fish, earth, magrathea, marvin, etc.) - "consult guide about X" now returns relevant entry text Tests (79 passing): - test_engine.py (14): containment, flags, articles, clock mechanics - test_parser.py (20): directions, compound verbs, prepositions, synonyms - test_earth.py (21): full opening sequence, puzzles, navigation - test_vogon.py (4): room existence, Hold first-visit sequence - test_dark.py (7): inventory clearing, dream dispatch, probabilities - conftest.py: shared game fixture and send() helper Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
229 lines
6.2 KiB
Python
229 lines
6.2 KiB
Python
"""Tests for the Earth section of the game."""
|
|
|
|
from tests.conftest import send
|
|
|
|
|
|
def test_start_in_dark(game):
|
|
state, _, _ = game
|
|
assert not state.lit
|
|
text = send(game, "look")
|
|
assert "pitch black" in text.lower()
|
|
|
|
|
|
def test_turn_on_light(game):
|
|
text = send(game, "turn on light")
|
|
assert "Good start" in text
|
|
assert "light is now on" in text
|
|
state, _, _ = game
|
|
assert state.lit
|
|
|
|
|
|
def test_turn_off_light(game):
|
|
send(game, "turn on light")
|
|
text = send(game, "turn off light")
|
|
assert "pitch dark" in text
|
|
state, _, _ = game
|
|
assert not state.lit
|
|
|
|
|
|
def test_get_out_of_bed(game):
|
|
send(game, "turn on light")
|
|
text = send(game, "get out of bed")
|
|
assert "manage it" in text.lower()
|
|
state, _, _ = game
|
|
assert not state.lying_down
|
|
|
|
|
|
def test_cant_walk_while_lying_down(game):
|
|
send(game, "turn on light")
|
|
text = send(game, "south")
|
|
# Player starts in bed, so the message references getting out of bed
|
|
assert "get out" in text.lower() or "get up" in text.lower()
|
|
|
|
|
|
def test_take_gown_with_headache(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "get gown")
|
|
assert "large enough" in text.lower()
|
|
assert "pocket" in text.lower()
|
|
|
|
|
|
def test_wear_gown(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
text = send(game, "wear gown")
|
|
assert "wearing" in text.lower()
|
|
|
|
|
|
def test_look_in_pocket(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
text = send(game, "look in pocket")
|
|
# Gown should open and reveal contents
|
|
assert "thing" in text.lower() or "fluff" in text.lower() or "analgesic" in text.lower()
|
|
|
|
|
|
def test_eat_tablet(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket") # opens gown
|
|
text = send(game, "eat tablet")
|
|
assert "headache goes" in text.lower()
|
|
state, _, _ = game
|
|
assert not state.flags.get("headache")
|
|
assert state.score == 10
|
|
|
|
|
|
def test_cant_leave_bedroom_with_headache(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "open door")
|
|
text = send(game, "south")
|
|
assert "eighteen inches" in text.lower() or "jostles" in text.lower()
|
|
|
|
|
|
def test_leave_bedroom_after_tablet(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket")
|
|
send(game, "eat tablet")
|
|
text = send(game, "south")
|
|
# Should successfully leave bedroom
|
|
state, _, _ = game
|
|
assert state.here.id == "FRONT-PORCH"
|
|
|
|
|
|
def test_cant_leave_house_without_gown(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket")
|
|
send(game, "eat tablet")
|
|
send(game, "south")
|
|
# Now at front porch, take off gown
|
|
send(game, "take off gown")
|
|
text = send(game, "south")
|
|
assert "indecency" in text.lower()
|
|
|
|
|
|
def test_leave_house_with_gown(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket")
|
|
send(game, "eat tablet")
|
|
send(game, "south")
|
|
text = send(game, "south")
|
|
state, _, _ = game
|
|
assert state.here.id == "FRONT-OF-HOUSE"
|
|
|
|
|
|
def test_navigate_to_pub(game):
|
|
# Speed through to pub
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket")
|
|
send(game, "eat tablet")
|
|
send(game, "south") # front porch
|
|
send(game, "south") # front of house
|
|
send(game, "south") # country lane
|
|
text = send(game, "south") # pub
|
|
state, _, _ = game
|
|
assert state.here.id == "PUB"
|
|
# Ford should have arrived
|
|
assert "Ford" in text or state.flags.get("ford_arrived")
|
|
|
|
|
|
def test_drink_three_beers(game):
|
|
# Speed through to pub
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
send(game, "get gown")
|
|
send(game, "wear gown")
|
|
send(game, "look in pocket")
|
|
send(game, "eat tablet")
|
|
send(game, "south")
|
|
send(game, "south")
|
|
send(game, "south")
|
|
send(game, "south") # pub
|
|
|
|
text1 = send(game, "drink beer")
|
|
assert "2 pint" in text1.lower()
|
|
text2 = send(game, "drink beer")
|
|
assert "1 pint" in text2.lower()
|
|
text3 = send(game, "drink beer")
|
|
assert "wriggly" in text3.lower() or "ear" in text3.lower()
|
|
|
|
state, _, _ = game
|
|
assert state.score == 25 # 10 (tablet) + 15 (beers)
|
|
|
|
|
|
def test_score_command(game):
|
|
text = send(game, "score")
|
|
assert "0 of a possible 400" in text
|
|
|
|
|
|
def test_inventory_shows_headache(game):
|
|
text = send(game, "inventory")
|
|
assert "splitting headache" in text.lower()
|
|
|
|
|
|
def test_inventory_shows_no_tea(game):
|
|
text = send(game, "inventory")
|
|
assert "no tea" in text.lower()
|
|
|
|
|
|
def test_examine_bed(game):
|
|
send(game, "turn on light")
|
|
text = send(game, "examine bed")
|
|
assert "bed" in text.lower()
|
|
|
|
|
|
def test_look_under_bed(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "look under bed")
|
|
assert "handkerchiefs" in text.lower() or "nothing" in text.lower()
|
|
|
|
|
|
def test_open_curtains_reveals_bulldozer(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "open curtains")
|
|
assert "bulldozer" in text.lower()
|
|
|
|
|
|
def test_screwdriver_headache(game):
|
|
"""Can't take screwdriver while having a headache."""
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "take screwdriver")
|
|
assert "dances" in text.lower() or "possessed" in text.lower()
|
|
|
|
|
|
def test_toothbrush_headache(game):
|
|
"""Can't take toothbrush while having a headache."""
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "take toothbrush")
|
|
assert "lunge" in text.lower() or "spins" in text.lower()
|
|
|
|
|
|
def test_phone_action(game):
|
|
send(game, "turn on light")
|
|
send(game, "get out of bed")
|
|
text = send(game, "answer phone")
|
|
assert "receiver" in text.lower() or "dialling" in text.lower()
|