-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplace.py
executable file
·88 lines (72 loc) · 2.68 KB
/
place.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
class Place(object):
"""
Parent class to both City and unique place classes.
"""
def __init__(self, name, description, greetings):
"""
Initialize Place object.
@param name: The name of the Place.
@param description: A description of the Place.
@param greetings: The greetings upon entering Place.
"""
self._name = name
self._description = description
self._greetings = greetings
def getName(self):
"""
Returns name of place.
@return: The name of the place.
"""
return self._name
def getDescription(self):
"""
Returns description of place.
@return: The description of the place.
"""
return self._description
def getGreeting(self):
"""
Returns the greetings of place
"""
return self._greetings
def receiveSpaces(self, space, targetSpace):
"""
Helper method used to create references to the two spaces
used in quest-dependent port creation.
@param space: Player's current space.
@param targetSpace: The space to be linked with the
current space.
"""
self._space = space
self._targetSpace = targetSpace
def _createPort(self, direction, executed = False):
"""
Creates a port between the space and targetSpace. In this
construction, targetSpace is to the direction of space.
In LotR, this is used to unlock new space connections as a
reward for quest completion.
@param direction: The direction targetSpace is in with
respect to space.
@param executed: If this method has been executed. False by
default.
"""
#If already executed, no need to create additional port
self._executed = executed
if self._executed:
return
#Create port and print accompanying user text
self._space.createExit(direction, self._targetSpace,
outgoingOnly = False)
string = "%s is now accessible to the %s" % (self._targetSpace.getName(),
direction)
print string.upper()
print ""
#Update self._executed
self._executed = True
def enter(self, player):
"""
Parent enter method. Should be overridden by child classes.
@param player: The current player.
"""
print "This enter method should be overridden by child class."