Files
ages/examplegame/rooms.py

263 lines
8.9 KiB
Python
Raw Normal View History

from agame.action import *
from agame.item import Item
from agame.room import Room
from agame.trigger import *
from . import database
################################################################################
# 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.")],
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")],
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 exit the cabin."), TeleportAction("outside_cabin")],
},
),
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 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."
)
],
GO: [PrintAction("Try using the door instead.")],
},
),
)
database.add_room(
Room(
id="inside_cabin",
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 in the West, near where "
"the horrible machine resides. Turn it off, and its life-sapping force in the "
"world will cease.",
"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="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="west_path",
name="Western path",
synonyms=(
"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")],
},
),
)
database.add_rooms(
Room(
id="outside_cabin",
name="Outside the cabin",
desc=[],
items=[
database.items["mailbox"].create_inst(),
database.items["anjas_letter"].create_inst(revealed=False),
database.items["west_path"].create_inst(),
],
),
)
################################################################################
# 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=[], items=[]))