-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·30 lines (25 loc) · 1.11 KB
/
example.py
File metadata and controls
executable file
·30 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
from pag import GameWorld
from pag import CommandLineInterface
from pag import classes
# This gives the Game the list of all locations that is updated every time a
# new location is created. Since setting a variable to another variable with a
# list points to the one list's memory address, the list in the game class also
# updates.
gameworld = GameWorld(locations=classes.location_list)
cli = CommandLineInterface(gameworld)
class ToiletPaper(classes.Item):
def __init__(self):
super().__init__(name='toilet paper',
description='The toilet paper is labeled "X-t'
'raSoft.',
loc_description='A roll of toilet paper is in '
'the room.',
weight=1)
home = classes.Location('Home', start=True, show_name_when_exit=True)
home.description = 'You\'re at home.'
bathroom = classes.Location('Bathroom', items=[ToiletPaper()], show_name_when_exit=True)
bathroom.description = 'You\'re in the bathroom.'
home.exits = {'south': bathroom}
bathroom.exits = {'north': home}
cli.play()