Split out examplegame defs by items, rooms, and vars
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -6,90 +6,14 @@ from agame.trigger import *
|
|||||||
|
|
||||||
# This is the *game* here
|
# This is the *game* here
|
||||||
database = Database()
|
database = Database()
|
||||||
database.add_items(
|
|
||||||
Item(
|
from . import items
|
||||||
id="glowing_rock",
|
from . import rooms
|
||||||
name="glowing rock",
|
from . import vars
|
||||||
desc="This rock is glowing.",
|
|
||||||
synonyms=("rock",),
|
|
||||||
room_desc="You see a ((glowing rock)). You have **got** to have it.",
|
|
||||||
triggers={
|
|
||||||
GET: [
|
|
||||||
PrintAction(
|
|
||||||
"You try to pick up the rock, but it slips out of your greasy hands.",
|
|
||||||
"Maybe you should wash your hands, you disgusting little man.",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
LOOK: [PrintAction("Man, that rock looks awesome.")],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Item(
|
|
||||||
id="cell_door",
|
|
||||||
name="door",
|
|
||||||
room_desc="A ((door)) sits on the far wall.",
|
|
||||||
triggers={
|
|
||||||
GET: [PrintAction("The door is pretty attached to its wall.")],
|
|
||||||
OPEN: [
|
|
||||||
CheckVarAction(
|
|
||||||
"cell_door_open",
|
|
||||||
Compare.EQUALS,
|
|
||||||
True,
|
|
||||||
yes=[
|
|
||||||
PrintAction(
|
|
||||||
"It's already open. You push on the door even //more//, just in case."
|
|
||||||
),
|
|
||||||
SleepAction(1.0),
|
|
||||||
PrintAction("..."),
|
|
||||||
SleepAction(1.0),
|
|
||||||
PrintAction("Yup, still open."),
|
|
||||||
],
|
|
||||||
no=[
|
|
||||||
SetVarAction("cell_door_open", True),
|
|
||||||
PrintAction("The door swings open, thanks to you."),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
CLOSE: [
|
|
||||||
CheckVarAction(
|
|
||||||
"cell_door_open",
|
|
||||||
Compare.EQUALS,
|
|
||||||
True,
|
|
||||||
yes=[
|
|
||||||
PrintAction("You close that door. Nice job."),
|
|
||||||
SetVarAction("cell_door_open", False),
|
|
||||||
],
|
|
||||||
no=[PrintAction("The door is already closed.")],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
LOOK: [
|
|
||||||
CheckVarAction(
|
|
||||||
"cell_door_open",
|
|
||||||
Compare.EQUALS,
|
|
||||||
True,
|
|
||||||
yes=[PrintAction("It's a door, wide open, because you opened it.")],
|
|
||||||
no=[PrintAction("A closed door. You can change this.")],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
database.add_rooms(
|
|
||||||
Room(
|
|
||||||
id="start",
|
|
||||||
name="Test room",
|
|
||||||
desc="You're in ((Todd's Test Cell)).",
|
|
||||||
items=[
|
|
||||||
database.items["glowing_rock"].create_inst(),
|
|
||||||
database.items["cell_door"].create_inst(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Build the game state
|
# Build the game state
|
||||||
game = Game(
|
game = Game(
|
||||||
database=database,
|
database=database,
|
||||||
room=database.rooms["start"],
|
room=database.rooms["start"],
|
||||||
vars={
|
vars=vars.vars,
|
||||||
"cell_door_open": False,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|||||||
72
examplegame/items.py
Normal file
72
examplegame/items.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
from agame.item import Item
|
||||||
|
from agame.trigger import *
|
||||||
|
from agame.action import *
|
||||||
|
from . import database
|
||||||
|
|
||||||
|
database.add_items(
|
||||||
|
Item(
|
||||||
|
id="glowing_rock",
|
||||||
|
name="glowing rock",
|
||||||
|
desc="This rock is glowing.",
|
||||||
|
synonyms=("rock",),
|
||||||
|
room_desc="You see a ((glowing rock)). You have **got** to have it.",
|
||||||
|
triggers={
|
||||||
|
GET: [
|
||||||
|
PrintAction(
|
||||||
|
"You try to pick up the rock, but it slips out of your greasy hands.",
|
||||||
|
"Maybe you should wash your hands, you disgusting little man.",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
LOOK: [PrintAction("Man, that rock looks awesome.")],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Item(
|
||||||
|
id="cell_door",
|
||||||
|
name="door",
|
||||||
|
room_desc="A ((door)) sits on the far wall.",
|
||||||
|
triggers={
|
||||||
|
GET: [PrintAction("The door is pretty attached to its wall.")],
|
||||||
|
OPEN: [
|
||||||
|
CheckVarAction(
|
||||||
|
"cell_door_open",
|
||||||
|
Compare.EQUALS,
|
||||||
|
True,
|
||||||
|
yes=[
|
||||||
|
PrintAction(
|
||||||
|
"It's already open. You push on the door even //more//, just in case."
|
||||||
|
),
|
||||||
|
SleepAction(1.0),
|
||||||
|
PrintAction("..."),
|
||||||
|
SleepAction(1.0),
|
||||||
|
PrintAction("Yup, still open."),
|
||||||
|
],
|
||||||
|
no=[
|
||||||
|
SetVarAction("cell_door_open", True),
|
||||||
|
PrintAction("The door swings open, thanks to you."),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
CLOSE: [
|
||||||
|
CheckVarAction(
|
||||||
|
"cell_door_open",
|
||||||
|
Compare.EQUALS,
|
||||||
|
True,
|
||||||
|
yes=[
|
||||||
|
PrintAction("You close that door. Nice job."),
|
||||||
|
SetVarAction("cell_door_open", False),
|
||||||
|
],
|
||||||
|
no=[PrintAction("The door is already closed.")],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
LOOK: [
|
||||||
|
CheckVarAction(
|
||||||
|
"cell_door_open",
|
||||||
|
Compare.EQUALS,
|
||||||
|
True,
|
||||||
|
yes=[PrintAction("It's a door, wide open, because you opened it.")],
|
||||||
|
no=[PrintAction("A closed door. You can change this.")],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
14
examplegame/rooms.py
Normal file
14
examplegame/rooms.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from agame.room import Room
|
||||||
|
from . import database
|
||||||
|
|
||||||
|
database.add_rooms(
|
||||||
|
Room(
|
||||||
|
id="start",
|
||||||
|
name="Test room",
|
||||||
|
desc="You're in ((Todd's Test Cell)).",
|
||||||
|
items=[
|
||||||
|
database.items["glowing_rock"].create_inst(),
|
||||||
|
database.items["cell_door"].create_inst(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
7
examplegame/vars.py
Normal file
7
examplegame/vars.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
"""
|
||||||
|
Define all game variables here.
|
||||||
|
"""
|
||||||
|
|
||||||
|
vars = {
|
||||||
|
"cell_door_open": False,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user