From 0f6433eabdfc03349909afc2af842df699b64986 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 18 Nov 2021 17:24:46 -0800 Subject: [PATCH] More updates to the example game. Won't be specific here - too much changing, sorry. Signed-off-by: Alek Ratzloff --- examplegame/__init__.py | 2 +- examplegame/rooms.py | 92 ++++++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/examplegame/__init__.py b/examplegame/__init__.py index 24bc6ed..5383959 100644 --- a/examplegame/__init__.py +++ b/examplegame/__init__.py @@ -13,6 +13,6 @@ from . import vars # Build the game state game = Game( database=database, - room=database.rooms["inside_cabin"], + room=database.rooms["cabin_inside"], vars=vars.vars, ) diff --git a/examplegame/rooms.py b/examplegame/rooms.py index a0e76cf..60f8f37 100644 --- a/examplegame/rooms.py +++ b/examplegame/rooms.py @@ -15,11 +15,14 @@ database.add_items( room_desc="A door rests upon the south wall.", synonyms=("door",), triggers={ - LOOK: [PrintAction("A strong, sturdy door.")], + 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 exit the cabin."), TeleportAction("outside_cabin")], + GO: [ + PrintAction("You step outside."), + TeleportAction("cabin_outside"), + ], OPEN: [ CheckVarAction( "cabin_door_open", @@ -68,7 +71,10 @@ database.add_items( room_desc=None, triggers={ LOOK: [PrintAction("It's brown and gray.")], - GO: [PrintAction("You exit the cabin."), TeleportAction("outside_cabin")], + GO: [ + PrintAction("You step outside."), + TeleportAction("cabin_outside"), + ], }, ), Item( @@ -80,12 +86,12 @@ database.add_items( LOOK: [PrintAction("It's brown and gray.")], OPEN: [ PrintAction( - "This window is simply a pane of glass in a fixed frame, it be neither opened nor closed." + "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 be neither opened nor closed." + "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.")], @@ -95,7 +101,7 @@ database.add_items( database.add_room( Room( - id="inside_cabin", + id="cabin_inside", name="Inside the cabin", desc="", items=[ @@ -113,11 +119,11 @@ database.add_room( ANJAS_LETTER = [ "Dear Juni!", - "If you are reading this message you have finally arrived in the West, near where " - "the horrible machine resides. Turn it off, and its life-sapping force in the " - "world will cease.", + "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", + "- Anja", ] database.add_items( Item( @@ -131,7 +137,7 @@ database.add_items( }, ), Item( - id="mailbox", + 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.", @@ -191,7 +197,7 @@ database.add_items( }, ), Item( - id="west_path", + id="cabin_outside_west_path", name="Western path", synonyms=( "path to west", @@ -221,17 +227,73 @@ database.add_items( 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="outside_cabin", + id="cabin_outside", name="Outside the cabin", desc=[], items=[ - database.items["mailbox"].create_inst(), + # 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), - database.items["west_path"].create_inst(), ], ), )