-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.py
315 lines (226 loc) · 7.86 KB
/
item.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
"""
This module contains all item classes which defines the effects of the items
and the message received upon collection
"""
from map import *
from constants import *
class Item(GeneralSquare):
def add_to_group(self):
COLLISION_TYPE.add(self)
ITEM_TYPE.add(self)
class RedGem(Item):
ID = 0
message = 'Gain a red gem. ATK + 3!'
def effect(self, player):
player.STATE['ATK'] += 3
return True
class BlueGem(Item):
ID = 1
message = 'Gain a blue gem. DEF + 3!'
def effect(self, player):
player.STATE['DEF'] += 3
return True
class RedPotion(Item):
ID = 2
message = 'Gain a red potion. HP + 200!'
def effect(self, player):
player.STATE['HP'] += 200
return True
class BluePotion(Item):
ID = 3
message = 'Gain a blue potion. HP + 500!'
def effect(self, player):
player.STATE['HP'] += 500
return True
class HolyWater(Item):
ID = 4
message = 'Gain a holy water!'
def effect(self, player):
player.STATE['HP'] += (player.STATE['ATK'] + player.STATE['DEF']) // 2
return True
class YellowKey(Item):
ID = 5
message = 'Gain a yellow key!'
def effect(self, player):
player.KEY_COLLECTION['Yellow Key'] += 1
return True
class BlueKey(Item):
ID = 6
message = 'Gain a blue key!'
def effect(self, player):
player.KEY_COLLECTION['Blue Key'] += 1
return True
class RedKey(Item):
ID = 7
message = 'Gain a red key!'
def effect(self, player):
player.KEY_COLLECTION['Red Key'] += 1
return True
class AllKeys(Item):
ID = 8
message = 'Gain all type keys!'
def effect(self, player):
player.KEY_COLLECTION['Yellow Key'] += 1
player.KEY_COLLECTION['Blue Key'] += 1
player.KEY_COLLECTION['Red Key'] += 1
return True
class Coin(Item):
ID = 9
message = 'Gain a coin. GOLD + 300!'
def effect(self, player):
player.STATE['GOLD'] += 300
return True
class Pickaxe(Item):
ID = 10
message = 'Gain a pickaxe. Unlock path and stair in floor 19!'
def effect(self, world_overlays, world_floors):
world_overlays[18]['block_121'] = StairUp('Map', SCREEN_X / 13, SCREEN_Y / 13)
world_overlays[18]['block_121'].set_position(SCREEN_X / 13 + SCREEN_X / 13 * 10, SCREEN_Y / 13 + SCREEN_Y / 13 * 10)
world_floors[18]['block_94'] = Ground('Map', SCREEN_X / 13, SCREEN_Y / 13)
world_floors[18]['block_105'] = Ground('Map', SCREEN_X / 13, SCREEN_Y / 13)
world_floors[18]['block_94'].set_position(SCREEN_X / 13 + SCREEN_X / 13 * 5, SCREEN_Y / 13 + SCREEN_Y / 13 * 8)
world_floors[18]['block_105'].set_position(SCREEN_X / 13 + SCREEN_X / 13 * 5, SCREEN_Y / 13 + SCREEN_Y / 13 * 9)
class Compass(Item):
ID = 11
message = 'Gain a compass. Press J to teleport!'
def effect(self, player):
player.COMPASS = True
return True
class Cross(Item):
ID = 12
message = 'Gain a cross!'
def effect(self, player):
player.STATE['HP'] += player.STATE['HP'] // 3
player.STATE['ATK'] += player.STATE['ATK'] // 3
player.STATE['DEF'] += player.STATE['DEF'] // 3
return True
class Illustration(Item):
ID = 13
message = 'Gain an illustration. Press I to show monster details!'
def effect(self, player):
player.ILLUSTRATION = True
return True
class SmallFeather(Item):
ID = 14
message = 'Gain a small feather. LEVEL + 1!'
def effect(self, player):
player.STATE['LEVEL'] += 1
player.STATE['HP'] += 1000
player.STATE['ATK'] += 10
player.STATE['DEF'] += 10
return True
class BigFeather(Item):
ID = 15
message = 'Gain a big feather. LEVEL + 3!'
def effect(self, player):
player.STATE['LEVEL'] += 3
player.STATE['HP'] += 3000
player.STATE['ATK'] += 30
player.STATE['DEF'] += 30
return True
class Sword(Item):
ID = 16
message = 'Gain a sword. ATK + 10!'
def effect(self, player):
player.STATE['ATK'] += 10
return True
class Sword2(Item):
ID = 17
message = 'Gain a sword 2. ATK + 30!'
def effect(self, player):
player.STATE['ATK'] += 30
return True
class Sword3(Item):
ID = 18
message = 'Gain a sword 3. ATK + 70!'
def effect(self, player):
player.STATE['ATK'] += 70
return True
class Sword4(Item):
ID = 19
message = 'Require 500 EXP to gain!'
def effect(self, player):
if player.STATE['EXP'] >= 500:
player.STATE['ATK'] += 120
player.STATE['EXP'] -= 500
self.message = 'Gain a sword 4. ATK + 120!'
return True
return False
class Sword5(Item):
ID = 20
message = 'Gain a sword 5. ATK + 150!'
def effect(self, player):
player.STATE['ATK'] += 150
return True
class Shield(Item):
ID = 21
message = 'Gain a shield. DEF + 10!'
def effect(self, player):
player.STATE['DEF'] += 10
return True
class Shield2(Item):
ID = 22
message = 'Gain a shield 2. DEF + 30!'
def effect(self, player):
player.STATE['DEF'] += 30
return True
class Shield3(Item):
ID = 23
message = 'Gain a shield 3. DEF + 85!'
def effect(self, player):
player.STATE['DEF'] += 85
return True
class Shield4(Item):
ID = 24
message = 'Require 500 GOLD to gain!'
def effect(self, player):
if player.STATE['GOLD'] >= 500:
player.STATE['DEF'] += 120
player.STATE['GOLD'] -= 500
self.message = 'Gain a shield 4. DEF + 120!'
return True
return False
class Shield5(Item):
ID = 25
message = 'Gain a shield 5. DEF + 190!'
def effect(self, player):
player.STATE['DEF'] += 190
return True
class Staff(Item):
ID = 26
message = 'Gain a staff. ATK + 700, DEF + 700!'
def effect(self, player):
player.STATE['ATK'] += 700
player.STATE['DEF'] += 700
return True
def get_item(obj):
"""function to return a class of the type passed in"""
# set item list
ITEM_LIST = [RedGem('Item', SCREEN_X / 13, SCREEN_Y / 13),
BlueGem('Item', SCREEN_X / 13, SCREEN_Y / 13),
RedPotion('Item', SCREEN_X / 13, SCREEN_Y / 13),
BluePotion('Item', SCREEN_X / 13, SCREEN_Y / 13),
HolyWater('Item', SCREEN_X / 13, SCREEN_Y / 13),
YellowKey('Item', SCREEN_X / 13, SCREEN_Y / 13),
BlueKey('Item', SCREEN_X / 13, SCREEN_Y / 13),
RedKey('Item', SCREEN_X / 13, SCREEN_Y / 13),
AllKeys('Item', SCREEN_X / 13, SCREEN_Y / 13),
Coin('Item', SCREEN_X / 13, SCREEN_Y / 13),
Pickaxe('Item', SCREEN_X / 13, SCREEN_Y / 13),
Compass('Item', SCREEN_X / 13, SCREEN_Y / 13),
Cross('Item', SCREEN_X / 13, SCREEN_Y / 13),
Illustration('Item', SCREEN_X / 13, SCREEN_Y / 13),
SmallFeather('Item', SCREEN_X / 13, SCREEN_Y / 13),
BigFeather('Item', SCREEN_X / 13, SCREEN_Y / 13),
Sword('Item', SCREEN_X / 13, SCREEN_Y / 13),
Sword2('Item', SCREEN_X / 13, SCREEN_Y / 13),
Sword3('Item', SCREEN_X / 13, SCREEN_Y / 13),
Sword4('Item', SCREEN_X / 13, SCREEN_Y / 13),
Sword5('Item', SCREEN_X / 13, SCREEN_Y / 13),
Shield('Item', SCREEN_X / 13, SCREEN_Y / 13),
Shield2('Item', SCREEN_X / 13, SCREEN_Y / 13),
Shield3('Item', SCREEN_X / 13, SCREEN_Y / 13),
Shield4('Item', SCREEN_X / 13, SCREEN_Y / 13),
Shield5('Item', SCREEN_X / 13, SCREEN_Y / 13),
Staff('Item', SCREEN_X / 13, SCREEN_Y / 13)]
return ITEM_LIST[obj]