from agame.action import * from agame.item import Item from agame.room import Room from agame.trigger import * from . import database LINEBREAK = "=" * 70 ################################################################################ # Prelude ################################################################################ database.add_room( Room( id="prelude", name="Prelude", desc="", items={}, teleport_actions=[ PrintAction( LINEBREAK, # "Many stories have been told about this place. Some are tall " "tales and mostly contradictory. Some others, however, are true.", # "This is one of those stories.", LINEBREAK, ), PlayerInputAction(), PrintAction( LINEBREAK, # "There used to be trees here. Fifteen years ago, we were sitting " "in the shade, telling stories about last summer and what we hope " "would happen next, our laughter unable to break past the leaves " "and branches around us.", # "It is now desolate. Only the wind shakes the dry branches of the " "remaining trees. They chitter and clack; any other noise is a " "long echo. Nothing else stands tall enough to block the sound.", # "No animals patrol the sky nor ground. Life has left this place.", LINEBREAK, ), PlayerInputAction(), PrintAction( LINEBREAK, # "It is because of the ((machine)).", # LINEBREAK, ), PlayerInputAction(), SleepAction(1), PrintAction("."), SleepAction(1), PrintAction(".."), SleepAction(1), PrintAction("..."), SleepAction(1), PrintAction("...."), SleepAction(1), PrintAction("....."), SleepAction(1), PrintAction("......"), SleepAction(1), PrintAction("You awaken from a fitful sleep. Where are you again?"), PlayerInputAction(), TeleportAction("cabin_inside"), ], ) ) ################################################################################ # Inside the cabin ################################################################################ database.add_items( Item( id="cabin_inside_door", name="Cabin door", room_desc="A door rests upon the south wall.", synonyms=("door",), triggers={ LOOK: [PrintAction("A strong, sturdy door leading outside.")], GET: [PrintAction("The door is firmly attached to the wall.")], # Don't actually worry about the door being open here. It's just a # nice flavoring. GO: [ PrintAction("You step outside."), TeleportAction("cabin_outside"), ], OPEN: [ CheckVarAction( "cabin_door_open", yes=PrintAction("The door is already open."), no=[ PrintAction("You pull the cabin door open."), SetVarAction("cabin_door_open", True), ], ) ], CLOSE: [ CheckVarAction( "cabin_door_open", yes=[ PrintAction("You shut the door tight."), SetVarAction("cabin_door_open", False), ], no=PrintAction("The door is already closed."), ) ], }, ), Item( id="cabin_inside_bed", name="Bed", room_desc="A bed, freshly made, sits in the corner.", triggers={ LOOK: [ PrintAction("It's a comfortable looking bed, but no time for rest now.") ], GET: [PrintAction("Uh, no.")], USE: [ PrintAction("You've only just woken up, now is not the time for rest.") ], GO: [ PrintAction("You've only just woken up, now is not the time for rest.") ], }, ), Item( # The outside view, and also kind of a hack for the player to be allowed # to say "go outside" and "look outside" without having an "outside" # synonym for the door, so the player can't also do "open outside" id="cabin_inside_outside", name="Outside", room_desc=None, triggers={ LOOK: [PrintAction("It's brown and gray.")], GO: [ PrintAction("You step outside."), TeleportAction("cabin_outside"), ], }, ), Item( id="cabin_inside_window", name="Window", room_desc="A dull light pours in from the solitary window on the east wall.", synonyms=("outside window", "out window", "out the window"), triggers={ LOOK: [PrintAction("It's brown and gray.")], OPEN: [ PrintAction( "This window is simply a pane of glass in a fixed frame, it can be neither opened nor closed." ) ], CLOSE: [ PrintAction( "This window is simply a pane of glass in a fixed frame, it can be neither opened nor closed." ) ], GO: [PrintAction("Try using the door instead.")], }, ), ) database.add_room( Room( id="cabin_inside", name="Inside the cabin", desc="", items=[ database.items["cabin_inside_door"].create_inst(), database.items["cabin_inside_bed"].create_inst(), database.items["cabin_inside_outside"].create_inst(), database.items["cabin_inside_window"].create_inst(), ], ) ) ################################################################################ # Outside the cabin ################################################################################ ANJAS_LETTER = [ "Dear Juni!", "If you are reading this message you have finally arrived at my cabin in the " "West. Continue your journey further into the west - that is where the machine " "resides. Turn it off, and this land will begin healing anew.", "You are our only hope - we are counting on you!", "- Anja", ] database.add_items( Item( id="anjas_letter", name="Anja's letter", synonyms=("letter", "anjas letter", "anja's letter"), triggers={ GET: [GetAction("anjas_letter")], LOOK: [PrintAction(*ANJAS_LETTER)], READ: [PrintAction(*ANJAS_LETTER)], }, ), Item( id="cabin_outside_mailbox", name="Mailbox", synonyms=("mailbox", "postbox", "rusty mailbox", "rusty postbox"), room_desc="A rusty mailbox sits by the door to the cabin.", triggers={ GET: [ PrintAction( "The mailbox is firmly rooted in the ground. You don't have anywhere to put it, anyway." ) ], LOOK: [ CheckVarAction( var_id="mailbox_open", yes=[ CheckRoomItemsAction( item_ids="anjas_letter", yes=PrintAction("A single letter sits in the mailbox."), no=PrintAction("It's empty."), ) ], no=[ PrintAction("A rusty mailbox sits atop its post. It is closed.") ], ) ], OPEN: [ CheckVarAction( var_id="mailbox_open", yes=PrintAction("The mailbox is already open."), no=[ PrintAction( "You unlatch the lid to the mailbox, and it pops open." ), SetVarAction("mailbox_open", True), CheckRoomItemsAction( item_ids="anjas_letter", yes=[ PrintAction("A single letter sits inside."), RevealItemAction("anjas_letter"), ], ), ], ) ], CLOSE: [ CheckVarAction( var_id="mailbox_open", yes=[ PrintAction("The mailbox snaps shut."), SetVarAction("mailbox_open", False), CheckRoomItemsAction( "anjas_letter", yes=[UnrevealItemAction("anjas_letter")] ), ], no=PrintAction("It's already closed."), ) ], }, ), Item( id="cabin_outside_west_path", name="Western path", synonyms=( "path", "path to west", "path to the west", "path leading west", "path leading westward", "west", "westward", "westward path", "west path", "western path", ), room_desc=( "A path leads westward, where the sky loses its color and becomes a dark gray. " "The land becomes more barren in this direction." ), triggers={ LOOK: [ PrintAction( "A dirt path extends towards a barren wasteland. At one " "point it had become overgrown with disuse, but most anything " "that was once alive is either long gone or a husk of its " "former self." ) ], GO: [PrintAction("You head west."), TeleportAction("western_fork")], USE: [PrintAction("You head west."), TeleportAction("western_fork")], }, ), Item( id="cabin_outside_door", name="Cabin door", room_desc=None, synonyms=("door",), triggers={ LOOK: [ PrintAction("A strong, sturdy door leading to the inside of the cabin.") ], OPEN: [ CheckVarAction( var_id="cabin_door_open", yes=PrintAction("The cabin door is already open."), no=[ PrintAction("You push the cabin door open."), SetVarAction("cabin_door_open", True), ], ) ], CLOSE: [ CheckVarAction( var_id="cabin_door_open", yes=[ PrintAction("You shut the cabin door tight."), SetVarAction("cabin_door_open", False), ], no=PrintAction("The cabin door is already shut."), ) ], GO: [ PrintAction("You step inside the cabin."), TeleportAction("cabin_inside"), ], USE: [ PrintAction("You step inside the cabin."), TeleportAction("cabin_inside"), ], }, ), Item( id="cabin_outside_inside", name="Cabin", room_desc=None, synonyms=("inside", "inside cabin"), triggers={ LOOK: [PrintAction("The cabin is small, but sturdy. A door leads inside.")], GO: [ PrintAction("You step inside the cabin."), TeleportAction("cabin_inside"), ], }, ), ) database.add_rooms( Room( id="cabin_outside", name="Outside the cabin", desc=[], items=[ # Fixtures database.items["cabin_outside_mailbox"].create_inst(), database.items["cabin_outside_west_path"].create_inst(), database.items["cabin_outside_door"].create_inst(), database.items["cabin_outside_inside"].create_inst(), # Items database.items["anjas_letter"].create_inst(revealed=False), ], ), ) ################################################################################ # Western fork ################################################################################ database.add_items( Item( id="eastern_path", name="Eastern path", room_desc="A path that leads eastward. Your cabin lies in this direction.", synonyms=( "path to east", "path to the east", "path leading east", "path leading eastward", "east", "eastward", "eastward path", "east path", "eastern path", ), ) ) database.add_rooms( Room( id="western_fork", name="Western fork", desc="((This is currently the end of the game.)) Thanks for playing!", items=[], ) )