-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment_02_JamesSalvatore.py
249 lines (198 loc) · 7.69 KB
/
Assignment_02_JamesSalvatore.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#-------------------------------------------------------------------------------
# Name: Rowan Zombie Text Adventure
# Purpose:
#
# Author: Owner
#
# Created: 20/02/2014
# Copyright: (c) Owner 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------
def main():
pass
class Stats:
#holds the value of ower and toughness
def __inint__(self,power=0,toughness=0):
self._power = power
self._toughness = toughness
def getPower(self):
return self._power
def getToughness(self):
return self._toughness
class Range:
def __init__(self, current = 0, min = 0, max = 10):
#Store a min, max and value
self._min = min
self._current = current
self._max = max
def setMin(self, min):
# '''
# Sets the min value, checks to make sure it is less than max
# '''
if min >= self._max:
self._min = min - 1
def getMin(self):
return self._min
def setMax(self, max):
if max <= self._min:
self._max = min + 1
def getMax(self):
return self._max
def setCurrent(self, current):
if current < self._min:
self._current = self._min
elif current > self._max:
self._current = self._max
else:
self._current = current
def getCurrent(self):
return self._current
class Entity:
#calls the "name" string
def __init__(self, name):
self.name = name
class Item(Entity):
#returns item name and stats
def __init__(self, name, description, stats):
self.description = description
self.stats = stats
def getDesctiption(self):
return self.description
def __str__(self):
return "%s : %s Stats: %s" % (self.name, self.description, self.stats)
class ItemGenerator(Item):
#all items in the game
def __init__(self, items):
self.items = {none, stick, dagger, backpack, axe}
none = 'none', 'You are defenseless', Stats(0,0)
stick = 'stick', 'A narrow piece of wood', Stats(1,1)
dagger = 'dagger', 'A sharp, double-edged knife', Stats(3,1),
backpack = 'backpack', 'A heavy knapsack filled with books', Stats(2,3)
axe = 'Axe', 'A large medieval weapon', Stats(6,3)
def getRandomItem(Item):
rand_item = random.choice(items)
return rand_item
def getItem(itemName):
return itemName
class Room(Entity):
#stores data for various rooms
def __init__(self, name, description, zombies, connections, isSpawnPoint):
self.description = description
self.zombies = zombies
self.connections = connections
self.isSpawnPoint = isSpawnPoint
def __str__(self):
return "%s : %s : %s zombies : connected to %s rooms" % str(name), str(description), str(zombies), str(connections), str(isSpawnPoint)
class Human(Entity):
#the player
def __init__(self, name, power, toughness, hitpoints, locationName, items):
self.power = power
self.toughness = toughness
self.hitpoints = 10
self.locationName = locationName
self.items = items
def getPower():
return power
def getToughness():
return toughness
def kill():
hitpoints = 0
def isAlive():
return hitpoints > 0
def __str__(self):
return "Power: %s Toughness: %s Health: %s Room: %s Items: %s"
class Zombie(Human):
#Zombies; no difference with "Human" code behavior
pass
class BattleManager:
#handles combat between the player and zombie
def __init__(self, human, enemies):
self.human = human
self.enemies = enemies
def battleLoop():
prompt_flight = raw_input("Do you want to attack or flee?")
if prompt_flight == "Attack":
while (enemies.hitpoints >= human.hitpoints):
zombie.toughness - human.power
if prompt_flight == 'Run':
while (human.hitpoints > 0):
print("You escaped!")
human.power - 1
if prompt_flight == 'Suicide':
print("Quitter!")
quit()
if prompt_flight == 'Stats':
return human
class LayoutManager:
#the arrangement of how rooms are connected
def __init__(self, room):
self.room = [Lab, Office, Hall, Atrium, Kitchen, Auditorium]
def createLayout(room):
#Auditorium has a (seven) in its 'connections' because the aim of the game is to reach 7, winning the game.
Lab = 'Lab', 'a computer lab', zombies, Hall, true
Hall = 'Hall', 'a long hallway', zombies, (Lab,Office,Kitchen,Atrium,Auditorium), true
Office = 'Office', 'an empty office', zombies, Hall, true
Kitchen = 'kitchen', 'a place for cookery', zombies, Hall, false
Atrium = 'atrium', 'a large space with chairs and tables', zombies, (Hall,Auditorium), false
Auditorium = 'Auditoriium', 'a wide stage area', zombies, seven, false
def addOneWayConnection(roomFrom, roomTo):
roomFrom = {Lab.connections.append(Hall),
Atrium.connections.append(Auditorium)}
roomTo = {Hall.connections.append(Lab),
Auditorium.connections.append(Atrium)}
def addTwoWayConnection(roomFrom, roomTo):
roomFrom = {Hall.connections.append(Office),
Office.connections.append(Hall),
Hall.connections.append(Kitchen),
Kitchen.connections.append(Hall),
Hall.connections.append(Atrium),
Atrium.connections.append(Hall),
Auditorium.connections.append(Atrium),
Atrium.connections.append(Auditorium),
Auditorium.connections.append(seven)}
roomTo = {Hall.connections.append(Office),
Office.connections.append(Hall),
Hall.connections.append(Kitchen),
Kitchen.connections.append(Hall),
Hall.connections.append(Atrium),
Atrium.connections.append(Hall),
Auditorium.connections.append(Atrium),
Atrium.connections.append(Auditorium),
seven.connections.append(Auditorium)}
class GameManager:
def __init__(layoutManager, player):
self.layoutManager = layoutManager
self.player = human
def gameLoop():
action = raw_input('What would you like to do: Inspect, Explore, or Quit?' )
if action == "Explore":
newRoom = raw_input('Do you want to go into the hall?')
if newRoom == "yes":
return room.connections.append(layoutManager)
BattleManager()
if action == "Inspect":
itemFind = raw_input('You found an item. Do you want it? ')
if itemFind == "yes":
[stick.item.Lab,
dagger.item.Kitchen,
backpack.item.Atrium,
axe.item.Office]
none.stats + item.stats
if action == "Quit":
quit()
#Does the player want to start the game or exit?
print "Menu\n"
print "(1)Start"
print "(2)Exit\n\n"
choice = (raw_input('>>'))
if choice=="1":
#Asks for player's name
person = raw_input('What is your name?: ')
#Gives the name of the game and the goal before starting actual gameplay
print('This is Rowan Zombie Die-pocalypse! The entire point of this is to survive the zombies and get out alive!')
gameLoop()
if choice=="2":
quit()
end
if __name__ == '__main__':
main()