neelthee-mansion 0.3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neelthee_mansion/Mansion_of_Amnesia.py +1017 -0
- neelthee_mansion/Quests.py +70 -0
- neelthee_mansion/Rooms.py +1818 -0
- neelthee_mansion/__init__.py +0 -0
- neelthee_mansion/__main__.py +4 -0
- neelthee_mansion/all_game_utils.py +13 -0
- neelthee_mansion/creatures.py +391 -0
- neelthee_mansion/items.py +74 -0
- neelthee_mansion/utils.py +388 -0
- neelthee_mansion-0.3.0.0.dist-info/METADATA +47 -0
- neelthee_mansion-0.3.0.0.dist-info/RECORD +14 -0
- neelthee_mansion-0.3.0.0.dist-info/WHEEL +5 -0
- neelthee_mansion-0.3.0.0.dist-info/entry_points.txt +2 -0
- neelthee_mansion-0.3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1017 @@
|
|
1
|
+
from .Rooms import *
|
2
|
+
from .creatures import *
|
3
|
+
from .items import *
|
4
|
+
from .Quests import *
|
5
|
+
from .all_game_utils import *
|
6
|
+
|
7
|
+
|
8
|
+
GameState = {
|
9
|
+
'Enemys killed': 0,
|
10
|
+
'collected items': [],
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
'''
|
15
|
+
Neel-thee's Mansion of Amnesia
|
16
|
+
'''
|
17
|
+
|
18
|
+
global player, evil_mage, commands, NOTE_NUM, credits, characters, color_coding, quest_manager
|
19
|
+
|
20
|
+
quest_manager = QuestManager()
|
21
|
+
|
22
|
+
color_coding = False
|
23
|
+
|
24
|
+
credits = '''
|
25
|
+
Made by: Alexander.E.F'''
|
26
|
+
|
27
|
+
|
28
|
+
name = ''
|
29
|
+
age = 0
|
30
|
+
height = Height()
|
31
|
+
weight = 0
|
32
|
+
|
33
|
+
|
34
|
+
charactersList = [
|
35
|
+
{'name': 'Jack', 'age': 19, 'height': Height('6ft 3'), 'weight(LBs)': 213},
|
36
|
+
{'name': 'Darcie-Mae', 'age': 19, 'height': Height('5ft 5'), 'weight(LBs)': 150},
|
37
|
+
{'name': 'John', 'age': 25, 'height': Height('5ft 10'), 'weight(LBs)': 180},
|
38
|
+
{'name': 'Emily', 'age': 22, 'height': Height('5ft 6'), 'weight(LBs)': 135},
|
39
|
+
{'name': 'William', 'age': 30, 'height': Height('6ft 1'), 'weight(LBs)': 200},
|
40
|
+
{'name': 'Samantha', 'age': 28, 'height': Height('5ft 8'), 'weight(LBs)': 155},
|
41
|
+
{'name': 'Mark', 'age': 23, 'height': Height('5ft 11'), 'weight(LBs)': 185},
|
42
|
+
{'name': 'Alex', 'age': 27, 'height': Height('6ft 0'), 'weight(LBs)': 190},
|
43
|
+
{'name': 'Sarah', 'age': 20, 'height': Height('5ft 4'), 'weight(LBs)': 125},
|
44
|
+
{'name': 'Natalie', 'age': 24, 'height': Height('5ft 7'), 'weight(LBs)': 140},
|
45
|
+
{'name': 'Michael', 'age': 32, 'height': Height('6ft 2'), 'weight(LBs)': 200},
|
46
|
+
{'name': 'Liam', 'age': 29, 'height': Height('5ft 10'), 'weight(LBs)': 180},
|
47
|
+
{'name': 'James', 'age': 25, 'height': Height('6ft 1'), 'weight(LBs)': 195},
|
48
|
+
{'name': 'Emma', 'age': 22, 'height': Height('5ft 6'), 'weight(LBs)': 130},
|
49
|
+
{'name': 'Olivia', 'age': 26, 'height': Height('5ft 8'), 'weight(LBs)': 135},
|
50
|
+
{'name': 'Sophia', 'age': 28, 'height': Height('5ft 5'), 'weight(LBs)': 145},
|
51
|
+
{'name': 'Daniel', 'age': 28, 'height': Height('6ft 0'), 'weight(LBs)': 180},
|
52
|
+
{'name': 'Matthew', 'age': 31, 'height': Height('5ft 11'), 'weight(LBs)': 175},
|
53
|
+
{'name': 'Jennifer', 'age': 25, 'height': Height('5ft 6'), 'weight(LBs)': 140},
|
54
|
+
{'name': 'Hannah', 'age': 23, 'height': Height('5ft 4'), 'weight(LBs)': 130},
|
55
|
+
{'name': 'Isabella', 'age': 24, 'height': Height('5ft 4'), 'weight(LBs)': 132},
|
56
|
+
{'name': 'Jake', 'age': 29, 'height': Height('5ft 6'), 'weight(LBs)': 140},
|
57
|
+
{'name': 'Zack', 'age': 21, 'height': Height('5ft 5'), 'weight(LBs)': 125},
|
58
|
+
{'name': 'Lucy', 'age': 27, 'height': Height('5ft 7'), 'weight(LBs)': 135},
|
59
|
+
{'name': 'Mia', 'age': 25, 'height': Height('5ft 3'), 'weight(LBs)': 128},
|
60
|
+
{'name': 'Brandon', 'age': 30, 'height': Height('6ft 1'), 'weight(LBs)': 180},
|
61
|
+
{'name': 'Ethan', 'age': 28, 'height': Height('6ft 0'), 'weight(LBs)': 175},
|
62
|
+
{'name': 'Andrew', 'age': 28, 'height': Height('6ft 0'), 'weight(LBs)': 175},
|
63
|
+
{'name': 'Nathan', 'age': 26, 'height': Height('5ft 10'), 'weight(LBs)': 165},
|
64
|
+
{'name': 'David', 'age': 22, 'height': Height('6ft 2'), 'weight(LBs)': 185},
|
65
|
+
{'name': 'Noah', 'age': 25, 'height': Height('5ft 11'), 'weight(LBs)': 175},
|
66
|
+
{'name': 'Aiden', 'age': 30, 'height': Height('6ft 0'), 'weight(LBs)': 180},
|
67
|
+
{'name': 'Lucas', 'age': 28, 'height': Height('5ft 10'), 'weight(LBs)': 170},
|
68
|
+
{'name': 'Ava', 'age': 22, 'height': Height('5ft 5'), 'weight(LBs)': 130},
|
69
|
+
{'name': 'Lily', 'age': 26, 'height': Height('5ft 6'), 'weight(LBs)': 135},
|
70
|
+
{'name': 'Grace', 'age': 29, 'height': Height('5ft 7'), 'weight(LBs)': 140},
|
71
|
+
{'name': 'Josh', 'age': 26, 'height': Height('5ft 6'), 'weight(LBs)': 135},
|
72
|
+
{'name': 'Luka', 'age': 29, 'height': Height('5ft 7'), 'weight(LBs)': 140},
|
73
|
+
]
|
74
|
+
|
75
|
+
|
76
|
+
evil_mage = PC(
|
77
|
+
'Neel-thee Contozt',
|
78
|
+
19836,
|
79
|
+
'Mage',
|
80
|
+
29,
|
81
|
+
'Evil prince',
|
82
|
+
Height('5ft 7.375'),
|
83
|
+
222,
|
84
|
+
xp=99180,
|
85
|
+
)
|
86
|
+
|
87
|
+
|
88
|
+
# Function to parse command
|
89
|
+
def parse_command(command_str: str, commands: dict):
|
90
|
+
global player
|
91
|
+
# Split the command string into parts
|
92
|
+
parts = command_str.split()
|
93
|
+
|
94
|
+
# Check for multi-word commands
|
95
|
+
for cmd in commands.keys():
|
96
|
+
cmd_parts = cmd.split()
|
97
|
+
if len(cmd_parts) > 1 and parts[:len(cmd_parts)] == cmd_parts:
|
98
|
+
action = ' '.join(cmd_parts)
|
99
|
+
targets = parts[len(cmd_parts):]
|
100
|
+
return action, targets
|
101
|
+
|
102
|
+
# Default single word command
|
103
|
+
action = parts[0]
|
104
|
+
targets = parts[1:] if len(parts) > 1 else []
|
105
|
+
return action, targets
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
def showInstructions():
|
110
|
+
global player
|
111
|
+
# Display the game instructions
|
112
|
+
type_text('''
|
113
|
+
===========================
|
114
|
+
Commands:
|
115
|
+
go [%*GREEN*%direction%*RESET*%/%*GREEN*%teleport%*RESET*%/%*GREEN*%number%*RESET*%] - Move to another location
|
116
|
+
get [%*BLUE*%item%*RESET*%] - Pick up an item from your current location
|
117
|
+
search [the/] [%*RED*%container%*RESET*%] - Search a container in your current location
|
118
|
+
use [%*BLUE*%item%*RESET*%] - Use an item from your inventory
|
119
|
+
put [%*BLUE*%item%*RESET*%] [the/] [%*RED*%container%*RESET*%] - Put an item from your inventory into a container in your current location
|
120
|
+
sleep - Rest for a bit and regain some health
|
121
|
+
look - Look around your current location
|
122
|
+
quit - Quit the game
|
123
|
+
help - Show these instructions
|
124
|
+
hint - Get a random hint for your current location
|
125
|
+
map - Display the map of places you have been to
|
126
|
+
''', colorTrue=color_coding)
|
127
|
+
|
128
|
+
|
129
|
+
def showHint():
|
130
|
+
global player
|
131
|
+
if 'Hints' in ROOMS[player.CURRENTROOM]:
|
132
|
+
type_text("You think:", colorTrue=color_coding)
|
133
|
+
hint = choice(ROOMS[player.CURRENTROOM]['Hints'])
|
134
|
+
type_text(hint, colorTrue=color_coding)
|
135
|
+
else:
|
136
|
+
type_text("You can't think of anything", colorTrue=color_coding)
|
137
|
+
|
138
|
+
def check_direction(var: str, directions: list):
|
139
|
+
global player
|
140
|
+
for direction in directions:
|
141
|
+
if var == direction:
|
142
|
+
return True
|
143
|
+
return False
|
144
|
+
|
145
|
+
|
146
|
+
def End(text: str, win: bool = True):
|
147
|
+
global player
|
148
|
+
type_text(text, colorTrue=color_coding)
|
149
|
+
if win:
|
150
|
+
type_text('Do you want to leave the game? Y/N', colorTrue=color_coding)
|
151
|
+
while True:
|
152
|
+
leave = input('>').lower()
|
153
|
+
if leave == 'n':
|
154
|
+
type_text('You decide to continue exploring.', colorTrue=color_coding)
|
155
|
+
break
|
156
|
+
elif leave == 'y':
|
157
|
+
type_text('You escaped the house... %*BOLD*%GAME OVER, YOU WIN!', colorTrue=color_coding)
|
158
|
+
commands["quit"]()
|
159
|
+
else:
|
160
|
+
type_text("Sorry, that wasn't 'y' or 'n'. Please enter 'y' or 'n'.", colorTrue=color_coding)
|
161
|
+
else:
|
162
|
+
type_text('%*BOLD*%GAME OVER, YOU LOSE!', colorTrue=color_coding)
|
163
|
+
commands["quit"]()
|
164
|
+
|
165
|
+
|
166
|
+
NOTE_NUM = 0
|
167
|
+
|
168
|
+
|
169
|
+
def add_note(note, parchment_index=None):
|
170
|
+
global player
|
171
|
+
player.NOTES.append(note)
|
172
|
+
NOTE_NUM += 1
|
173
|
+
inv_note = 'note ' + str(NOTE_NUM)
|
174
|
+
try:
|
175
|
+
del player.inventory[parchment_index]
|
176
|
+
except IndexError:
|
177
|
+
pass
|
178
|
+
player.inventory_add([item(inv_note)])
|
179
|
+
|
180
|
+
|
181
|
+
def Use_grappling_hook():
|
182
|
+
global player
|
183
|
+
|
184
|
+
def swing_into_forest():
|
185
|
+
global player
|
186
|
+
type_text("You throw your grappling-hook, it catches a branch of a nearby tree and hooks back onto itself. \nYou can swing into the forest!", colorTrue=color_coding)
|
187
|
+
if ask_for_consent("Do you want to swing into the forest"):
|
188
|
+
type_text("You swing into the forest", colorTrue=color_coding)
|
189
|
+
Move('Forest Clearing')
|
190
|
+
else:
|
191
|
+
type_text("You flick the rope and it unhooks. You continue exploring the house.", colorTrue=color_coding)
|
192
|
+
|
193
|
+
def climb_into_house():
|
194
|
+
global player
|
195
|
+
type_text("You throw your grappling-hook, it catches the railing of the nearby house and hooks back onto itself. \nYou can climb into the house!", colorTrue=color_coding)
|
196
|
+
if ask_for_consent("Do you want to climb into the house"):
|
197
|
+
type_text("You climb into the house", colorTrue=color_coding)
|
198
|
+
Move('Balcony')
|
199
|
+
else:
|
200
|
+
type_text("You flick the rope and it unhooks. You continue exploring the forest", colorTrue=color_coding)
|
201
|
+
|
202
|
+
if player.CURRENTROOM == 'Balcony' and 'grappling-hook' in player.inventory:
|
203
|
+
swing_into_forest()
|
204
|
+
elif player.CURRENTROOM == 'Forest Clearing' and 'grappling-hook' in player.inventory:
|
205
|
+
climb_into_house()
|
206
|
+
|
207
|
+
|
208
|
+
def Use_quill():
|
209
|
+
global player
|
210
|
+
|
211
|
+
if all(item in player.inventory for item in ['ink-pot', 'parchment', 'quill']):
|
212
|
+
parchment_index = player.inventory.index('parchment')
|
213
|
+
type_text('What do you want to write', colorTrue=color_coding)
|
214
|
+
write = str(input('>')).strip()
|
215
|
+
|
216
|
+
if write:
|
217
|
+
add_note(write, parchment_index)
|
218
|
+
else:
|
219
|
+
type_text("You can't write nothing", colorTrue=color_coding)
|
220
|
+
else:
|
221
|
+
type_text("You need an ink pot, parchment, and a quill to write.", colorTrue=color_coding)
|
222
|
+
|
223
|
+
|
224
|
+
def Use_note(note_number):
|
225
|
+
global player
|
226
|
+
"""Reads a specified note from the player's inventory."""
|
227
|
+
note_key = f'note {note_number}'
|
228
|
+
if note_key in player.inventory:
|
229
|
+
note_index = int(note_number) - 1
|
230
|
+
type_text(f'You read:', colorTrue=color_coding)
|
231
|
+
type_text(player.NOTES[note_index], colorTrue=color_coding)
|
232
|
+
else:
|
233
|
+
type_text('You do not have that note', colorTrue=color_coding)
|
234
|
+
|
235
|
+
|
236
|
+
def Use(moveone, movetwo=None):
|
237
|
+
global player
|
238
|
+
"""Uses an item from the player's inventory."""
|
239
|
+
if moveone in player.inventory:
|
240
|
+
item_obj = player.inventory[player.inventory.index(moveone)]
|
241
|
+
if isinstance(item_obj, item):
|
242
|
+
if item_obj.sell(player):
|
243
|
+
type_text(f"You sell the %*BLUE*%{moveone}%*RESET*%", colorTrue=color_coding)
|
244
|
+
player.inventory.remove(item_obj.name)
|
245
|
+
elif moveone == 'quill':
|
246
|
+
Use_quill()
|
247
|
+
elif moveone == 'grappling-hook':
|
248
|
+
Use_grappling_hook()
|
249
|
+
elif moveone == 'note' and movetwo:
|
250
|
+
Use_note(movetwo)
|
251
|
+
elif moveone == '0':
|
252
|
+
type_text("You can't use nothing", colorTrue=color_coding)
|
253
|
+
else:
|
254
|
+
type_text("You can't use that", colorTrue=color_coding)
|
255
|
+
|
256
|
+
|
257
|
+
def Move(move):
|
258
|
+
global player
|
259
|
+
|
260
|
+
|
261
|
+
def attempt_charter():
|
262
|
+
global player
|
263
|
+
if player.money >= 10:
|
264
|
+
player.money -= 10
|
265
|
+
if 'descovered' in ROOMS[newRoom] and not ROOMS[newRoom]['descovered']:
|
266
|
+
ROOMS[newRoom]['descovered'] = True
|
267
|
+
return ROOMS[player.CURRENTROOM]['directions'][move]
|
268
|
+
else:
|
269
|
+
type_text("You don't have enough money to charter a ship.", colorTrue=color_coding)
|
270
|
+
return player.CURRENTROOM
|
271
|
+
|
272
|
+
def attempt_move_to_garden():
|
273
|
+
global player
|
274
|
+
if 'key' in player.inventory:
|
275
|
+
End('You unlock the gate to the garden with the key!')
|
276
|
+
return newRoom
|
277
|
+
else:
|
278
|
+
type_text('The gate is locked.', colorTrue=color_coding)
|
279
|
+
return newRoom
|
280
|
+
|
281
|
+
def move_to_room():
|
282
|
+
global player
|
283
|
+
player.LASTROOM = player.CURRENTROOM
|
284
|
+
if move == '0':
|
285
|
+
return attempt_charter()
|
286
|
+
elif newRoom == 'Garden':
|
287
|
+
if 'descovered' in ROOMS[newRoom] and not ROOMS[newRoom]['descovered']:
|
288
|
+
ROOMS[newRoom]['descovered'] = True
|
289
|
+
return attempt_move_to_garden()
|
290
|
+
else:
|
291
|
+
if 'descovered' in ROOMS[newRoom] and not ROOMS[newRoom]['descovered']:
|
292
|
+
ROOMS[newRoom]['descovered'] = True
|
293
|
+
return newRoom
|
294
|
+
|
295
|
+
if move in ROOMS[player.CURRENTROOM]['directions']:
|
296
|
+
newRoom = ROOMS[player.CURRENTROOM]['directions'][move]
|
297
|
+
player.CURRENTROOM = move_to_room()
|
298
|
+
return
|
299
|
+
elif move in ROOMS:
|
300
|
+
newRoom = move
|
301
|
+
if newRoom == 'Garden':
|
302
|
+
player.CURRENTROOM = attempt_move_to_garden()
|
303
|
+
else:
|
304
|
+
player.CURRENTROOM = newRoom
|
305
|
+
player.LASTROOM = player.CURRENTROOM
|
306
|
+
return
|
307
|
+
type_text("You can't go that way!", colorTrue=color_coding)
|
308
|
+
|
309
|
+
|
310
|
+
def start():
|
311
|
+
global player
|
312
|
+
# type_text a main men, colorTrue=color_codingu
|
313
|
+
type_text(f'\nHello %*MAGENTA*%{player.name}%*RESET*% and welcome to my Role Playing Game. \nI hope you have fun!', colorTrue=color_coding)
|
314
|
+
showInstructions()
|
315
|
+
|
316
|
+
|
317
|
+
def showStatus():
|
318
|
+
global player
|
319
|
+
|
320
|
+
# Display player's current status
|
321
|
+
text = f'\n---------------------------'
|
322
|
+
|
323
|
+
# Display the current inventory
|
324
|
+
the_inventory = [itemnum.name for itemnum in player.inventory if isinstance(itemnum, item)]
|
325
|
+
text += f'\nInventory: %*BLUE*%{", ".join(the_inventory)}%*RESET*%; Money: {player.money}; XP: {player.xp}; Level: {player.Level}'
|
326
|
+
|
327
|
+
# Display possible directions of travel
|
328
|
+
text = display_directions(text)
|
329
|
+
|
330
|
+
# Display the map if available
|
331
|
+
if 'map' in ROOMS[player.CURRENTROOM]:
|
332
|
+
text += f'\n\nKey: {"; ".join(KEY)}\n'
|
333
|
+
text += f'\n{ROOMS[player.CURRENTROOM]["map"]}\n'
|
334
|
+
|
335
|
+
# Display the description of the current room
|
336
|
+
text += ('\n' + str(ROOMS[player.CURRENTROOM]['info']))
|
337
|
+
|
338
|
+
text += f"\n---------------------------"
|
339
|
+
|
340
|
+
type_text(text, colorTrue=color_coding)
|
341
|
+
|
342
|
+
# Optionally display additional room description
|
343
|
+
if 'description' in ROOMS[player.CURRENTROOM] and ask_for_consent("Do you want to observe the area"):
|
344
|
+
type_text("The area:", colorTrue=color_coding)
|
345
|
+
type_text(ROOMS[player.CURRENTROOM]['description'], colorTrue=color_coding)
|
346
|
+
|
347
|
+
|
348
|
+
def display_directions(text):
|
349
|
+
global player
|
350
|
+
directions = ['north', 'east', 'south', 'west', 'up', 'down', 'teleport']
|
351
|
+
direction_descriptions = {
|
352
|
+
'house': {
|
353
|
+
'north': "There is a door to the",
|
354
|
+
'east': "There is a door to the",
|
355
|
+
'south': "There is a door to the",
|
356
|
+
'west': "There is a door to the",
|
357
|
+
'up': "There is a staircase leading",
|
358
|
+
'down': "There is a staircase leading"
|
359
|
+
},
|
360
|
+
'forest': {
|
361
|
+
'north': "There is a path to the",
|
362
|
+
'east': "There is a path to the",
|
363
|
+
'south': "There is a path to the",
|
364
|
+
'west': "There is a path to the",
|
365
|
+
'up': "There is a ladder going",
|
366
|
+
'down': "There is a hole in the ground leading"
|
367
|
+
},
|
368
|
+
'cavern': {
|
369
|
+
'north': "There is a tunel to the",
|
370
|
+
'east': "There is a tunel to the",
|
371
|
+
'south': "There is a tunel to the",
|
372
|
+
'west': "There is a tunel to the",
|
373
|
+
'up': "There is a shoot with handhold going",
|
374
|
+
'down': "There is a shoot in the ground going"
|
375
|
+
},
|
376
|
+
}
|
377
|
+
|
378
|
+
room_type = ROOMS[player.CURRENTROOM]['room type']
|
379
|
+
if room_type in direction_descriptions:
|
380
|
+
for direction in directions:
|
381
|
+
if direction in ROOMS[player.CURRENTROOM]['directions']:
|
382
|
+
if direction != 'teleport':
|
383
|
+
text += f'\n{direction_descriptions[room_type][direction]} %*GREEN*%{direction}%*RESET*%.'
|
384
|
+
|
385
|
+
if 'teleport' in ROOMS[player.CURRENTROOM]['directions']:
|
386
|
+
text += "\nThere is a %*GREEN*%teleport%*RESET*%ation circle on the ground"
|
387
|
+
|
388
|
+
return text
|
389
|
+
|
390
|
+
def battle(player: PC, good_guys: list, bad_guys: list, last_room):
|
391
|
+
"""
|
392
|
+
Simulate a battle between the player (and allies) and monsters.
|
393
|
+
|
394
|
+
Args:
|
395
|
+
player (PC): The player character.
|
396
|
+
good_guys (list): The list of allies to help the player.
|
397
|
+
bad_guys (list): The list of monsters to battle the player.
|
398
|
+
last_room: The previous room before the battle.
|
399
|
+
|
400
|
+
Returns:
|
401
|
+
None if all bad guys are defeated, else the remaining bad guys.
|
402
|
+
"""
|
403
|
+
while player.hp > 0 and any(monster.hp > 0 for monster in bad_guys):
|
404
|
+
if ask_for_consent("Do you want to run away"):
|
405
|
+
Move(last_room)
|
406
|
+
return None, bad_guys
|
407
|
+
|
408
|
+
# Player and good guys' turn
|
409
|
+
for ally in [player] + good_guys:
|
410
|
+
if all(monster.hp <= 0 for monster in bad_guys):
|
411
|
+
handle_victory(player, bad_guys)
|
412
|
+
return good_guys, None
|
413
|
+
|
414
|
+
target = select_target(bad_guys)
|
415
|
+
player_turn(ally, target)
|
416
|
+
|
417
|
+
# Bad guys' turn
|
418
|
+
for monster in bad_guys:
|
419
|
+
if monster.hp > 0:
|
420
|
+
target = select_target([player] + good_guys)
|
421
|
+
monster_turn(target, monster)
|
422
|
+
|
423
|
+
if player.hp <= 0:
|
424
|
+
End(f'The monsters defeat you!', win=False)
|
425
|
+
return good_guys, bad_guys
|
426
|
+
|
427
|
+
return good_guys, bad_guys
|
428
|
+
|
429
|
+
|
430
|
+
def player_turn(player: PC, monster: creature):
|
431
|
+
"""
|
432
|
+
Handle a character's turn during the battle.
|
433
|
+
|
434
|
+
Args:
|
435
|
+
player (PC): The player or ally.
|
436
|
+
monster (creature): The monster being fought.
|
437
|
+
"""
|
438
|
+
player_action = loop_til_valid_input(
|
439
|
+
"Choose your action: (attack/defend/special): ",
|
440
|
+
"Invalid action. Please enter a valid action.",
|
441
|
+
PC_action
|
442
|
+
).value.lower()
|
443
|
+
|
444
|
+
if player_action == "attack":
|
445
|
+
perform_attack(player, monster)
|
446
|
+
elif player_action == "defend":
|
447
|
+
player.defending = True
|
448
|
+
type_text("You brace yourself for the next attack.", colorTrue=color_coding)
|
449
|
+
elif player_action == "special":
|
450
|
+
use_special_ability(player, monster)
|
451
|
+
|
452
|
+
|
453
|
+
def monster_turn(player: PC, monster: creature):
|
454
|
+
"""
|
455
|
+
Handle a monster's turn during the battle.
|
456
|
+
|
457
|
+
Args:
|
458
|
+
player (PC): The player or ally.
|
459
|
+
monster (creature): The monster attacking.
|
460
|
+
"""
|
461
|
+
type_text(f"The %*CYAN*%{monster.name}%*RESET*% attacks!", colorTrue=color_coding)
|
462
|
+
damage = calculate_damage(monster, player)
|
463
|
+
player.take_damage(damage)
|
464
|
+
|
465
|
+
|
466
|
+
def perform_attack(attacker: PC, defender: creature):
|
467
|
+
"""
|
468
|
+
Perform an attack action.
|
469
|
+
|
470
|
+
Args:
|
471
|
+
attacker (PC): The attacking character.
|
472
|
+
defender (creature): The defending monster.
|
473
|
+
"""
|
474
|
+
damage = calculate_damage(attacker, defender)
|
475
|
+
defender.take_damage(damage)
|
476
|
+
|
477
|
+
|
478
|
+
def handle_victory(player: PC, monsters: list):
|
479
|
+
"""
|
480
|
+
Handle the logic when the player and allies defeat all monsters.
|
481
|
+
|
482
|
+
Args:
|
483
|
+
player (PC): The player character.
|
484
|
+
monsters (list): The list of defeated monsters.
|
485
|
+
"""
|
486
|
+
type_text("You have defeated all the enemies!", colorTrue=color_coding)
|
487
|
+
for monster in monsters:
|
488
|
+
if monster.hp <= 0:
|
489
|
+
player.inventory_add(monster.dropped_items)
|
490
|
+
|
491
|
+
|
492
|
+
def calculate_damage(attacker, defender) -> int:
|
493
|
+
"""
|
494
|
+
Calculate the damage inflicted by the attacker on the defender.
|
495
|
+
|
496
|
+
Args:
|
497
|
+
attacker: The attacking character.
|
498
|
+
defender: The defending character.
|
499
|
+
|
500
|
+
Returns:
|
501
|
+
int: The calculated damage.
|
502
|
+
"""
|
503
|
+
damage_min, damage_max = calculate_damage_range(attacker.atpw)
|
504
|
+
damage = randint(damage_min, damage_max)
|
505
|
+
|
506
|
+
if random() < attacker.crit_chance:
|
507
|
+
damage *= 2
|
508
|
+
type_text("Critical hit!", colorTrue=color_coding)
|
509
|
+
|
510
|
+
if hasattr(defender, 'defending') and defender.defending:
|
511
|
+
damage //= 2
|
512
|
+
type_text("The attack is defended, reducing damage.", colorTrue=color_coding)
|
513
|
+
defender.defending = False
|
514
|
+
|
515
|
+
return damage
|
516
|
+
|
517
|
+
|
518
|
+
def calculate_damage_range(atpw: int) -> tuple[int, int]:
|
519
|
+
"""
|
520
|
+
Calculate the damage range based on attack power.
|
521
|
+
|
522
|
+
Args:
|
523
|
+
atpw (int): Attack power of the combatant.
|
524
|
+
|
525
|
+
Returns:
|
526
|
+
tuple[int, int]: Minimum and maximum damage range.
|
527
|
+
"""
|
528
|
+
damage_max_range = randint(1, 3)
|
529
|
+
damage_min_range = randint(1, 3)
|
530
|
+
damage_min = max(1, atpw - damage_min_range) # Ensure minimum damage is at least 1
|
531
|
+
damage_max = atpw + damage_max_range
|
532
|
+
return damage_min, damage_max
|
533
|
+
|
534
|
+
|
535
|
+
def use_special_ability(player: PC, monster: creature):
|
536
|
+
"""
|
537
|
+
Allow the player to use a special ability during combat.
|
538
|
+
|
539
|
+
Args:
|
540
|
+
player (PC): The player character.
|
541
|
+
monster (creature): The monster being fought.
|
542
|
+
"""
|
543
|
+
if player.special_ability.ready:
|
544
|
+
player.special_ability.activate(monster)
|
545
|
+
type_text(f"You use your special ability: {player.special_ability.name}.", colorTrue=color_coding)
|
546
|
+
player.special_ability.ready = False
|
547
|
+
else:
|
548
|
+
type_text("Your special ability is not ready yet.", colorTrue=color_coding)
|
549
|
+
|
550
|
+
|
551
|
+
def select_target(targets: list):
|
552
|
+
"""
|
553
|
+
Select a target from a list of characters.
|
554
|
+
|
555
|
+
Args:
|
556
|
+
targets (list): List of characters to select from.
|
557
|
+
|
558
|
+
Returns:
|
559
|
+
The selected target.
|
560
|
+
"""
|
561
|
+
# Basic logic to select the first valid target. Could be expanded to allow player choice.
|
562
|
+
for target in targets:
|
563
|
+
if target.hp > 0:
|
564
|
+
return target
|
565
|
+
|
566
|
+
|
567
|
+
def command():
|
568
|
+
global player
|
569
|
+
try:
|
570
|
+
ShouldBreak = False
|
571
|
+
|
572
|
+
while True:
|
573
|
+
showStatus()
|
574
|
+
user_input = get_player_input(False)
|
575
|
+
|
576
|
+
if user_input:
|
577
|
+
commands_list = user_input.split(',')
|
578
|
+
for command_str in commands_list:
|
579
|
+
action, targets = parse_command(command_str.strip(), commands)
|
580
|
+
|
581
|
+
if action in commands:
|
582
|
+
if has_named_arg(commands[action], 'player'):
|
583
|
+
if targets:
|
584
|
+
commands[action](player, *targets)
|
585
|
+
else:
|
586
|
+
commands[action](player)
|
587
|
+
elif targets:
|
588
|
+
commands[action](*targets)
|
589
|
+
else:
|
590
|
+
commands[action]()
|
591
|
+
else:
|
592
|
+
type_text(f"Unknown command '{action}'. Type 'help' for a list of commands.", colorTrue=color_coding)
|
593
|
+
if action in commands:
|
594
|
+
ShouldBreak = True
|
595
|
+
if ShouldBreak:
|
596
|
+
return
|
597
|
+
except KeyError as e:
|
598
|
+
type_text(f"KeyError: {e} - This might be due to an undefined command or incorrect arguments.", colorTrue=color_coding)
|
599
|
+
except ValueError as e:
|
600
|
+
type_text(f"ValueError: {e} - This might be due to incorrect arguments provided.", colorTrue=color_coding)
|
601
|
+
except Exception as e:
|
602
|
+
type_text(f"Unexpected Error: {e}", colorTrue=color_coding)
|
603
|
+
|
604
|
+
def handle_sleep_command(player: PC):
|
605
|
+
type_text("You decide to rest for a while.", colorTrue=color_coding)
|
606
|
+
|
607
|
+
# Simulate some time passing
|
608
|
+
sleep(2) # Example: sleep for 2 seconds
|
609
|
+
|
610
|
+
# Restore player's health or apply any other effects
|
611
|
+
player.heal(3) # Example: heal 5 health points during sleep
|
612
|
+
|
613
|
+
# Optional: Print a message or effect that happens during sleep
|
614
|
+
type_text("You feel refreshed after a good rest.", colorTrue=color_coding)
|
615
|
+
|
616
|
+
def get_player_input(split = True):
|
617
|
+
global player
|
618
|
+
move = ''
|
619
|
+
while move == '':
|
620
|
+
move = str(input('>')).strip().lower()
|
621
|
+
if split:
|
622
|
+
return move.split()
|
623
|
+
return move
|
624
|
+
|
625
|
+
def handle_go_command(direction):
|
626
|
+
global player
|
627
|
+
Move(direction)
|
628
|
+
|
629
|
+
def handle_get_command(player: PC, item_name):
|
630
|
+
if "item" in ROOMS[player.CURRENTROOM] and item_name == ROOMS[player.CURRENTROOM]['item'].name:
|
631
|
+
player.inventory_add([ROOMS[player.CURRENTROOM]['item']])
|
632
|
+
del ROOMS[player.CURRENTROOM]['item']
|
633
|
+
type_text(f'%*BLUE*%{item_name}%*RESET*% got!', colorTrue=color_coding)
|
634
|
+
else:
|
635
|
+
type_text(f"Can't get {item_name}!", colorTrue=color_coding)
|
636
|
+
|
637
|
+
def handle_look_command():
|
638
|
+
global player
|
639
|
+
return_ = False
|
640
|
+
if 'item' in ROOMS[player.CURRENTROOM]:
|
641
|
+
type_text(f'The item in the room: %*BLUE*%{ROOMS[player.CURRENTROOM]["item"].name}%*RESET*%.', colorTrue=color_coding)
|
642
|
+
return_ = True
|
643
|
+
if 'containers' in ROOMS[player.CURRENTROOM]:
|
644
|
+
type_text(f"The containers here are: %*RED*%{', '.join(ROOMS[player.CURRENTROOM]['containers'].keys())}%*RESET*%", colorTrue=color_coding)
|
645
|
+
return_ = True
|
646
|
+
if return_:
|
647
|
+
return
|
648
|
+
type_text('There is nothing of interest.', colorTrue=color_coding)
|
649
|
+
|
650
|
+
def handle_use_command(item = None, sub_item = None):
|
651
|
+
global player
|
652
|
+
Use(item, sub_item)
|
653
|
+
|
654
|
+
def handle_search_command(player, container = None, sub_container = None):
|
655
|
+
if 'containers' in ROOMS[player.CURRENTROOM]:
|
656
|
+
if container == 'the' and sub_container in ROOMS[player.CURRENTROOM]['containers'] and not all_same_value(ROOMS[player.CURRENTROOM]['containers'][sub_container].contents, None):
|
657
|
+
search_container(player, sub_container)
|
658
|
+
elif container in ROOMS[player.CURRENTROOM]['containers'] and not all_same_value(ROOMS[player.CURRENTROOM]['containers'][container].contents, None):
|
659
|
+
search_container(player, container)
|
660
|
+
else:
|
661
|
+
type_text(f"You cannot search the {container}", colorTrue=color_coding)
|
662
|
+
|
663
|
+
def search_container(player: PC, container):
|
664
|
+
player.inventory_add(ROOMS[player.CURRENTROOM]['containers'][container].contents)
|
665
|
+
type_text(f"You search the{' secret' if ROOMS[player.CURRENTROOM]['containers'][container].secret else ''} %*RED*%{container}%*RESET*% and find a ", newline=False, colorTrue=color_coding)
|
666
|
+
for searchitem in ROOMS[player.CURRENTROOM]['containers'][container].contents:
|
667
|
+
if searchitem:
|
668
|
+
if isinstance(searchitem, item):
|
669
|
+
end_str = ' and a ' if ROOMS[player.CURRENTROOM]['containers'][container].contents.index(searchitem) < last_index(ROOMS[player.CURRENTROOM]['containers'][container].contents) else '\n'
|
670
|
+
type_text(f"%*BLUE*%{searchitem.name}%*RESET*%{end_str}", newline=False, colorTrue=color_coding)
|
671
|
+
ROOMS[player.CURRENTROOM]['containers'][container].contents = []
|
672
|
+
|
673
|
+
|
674
|
+
def handle_put_command(player: PC, PutItem: item = None, container = None, sub_container = None):
|
675
|
+
if PutItem in player.inventory:
|
676
|
+
if 'containers' in ROOMS[player.CURRENTROOM]:
|
677
|
+
if container == 'the' and sub_container in ROOMS[player.CURRENTROOM]['containers']:
|
678
|
+
put_in_container(player, player.inventory[player.inventory.index(PutItem)], sub_container)
|
679
|
+
return
|
680
|
+
elif container in ROOMS[player.CURRENTROOM]['containers']:
|
681
|
+
put_in_container(player, player.inventory[player.inventory.index(PutItem)], container)
|
682
|
+
return
|
683
|
+
type_text(f"You cannot put the {PutItem.name} in the {container}", colorTrue=color_coding)
|
684
|
+
|
685
|
+
|
686
|
+
def put_in_container(player: PC, PutItem = None, container = None):
|
687
|
+
player.inventory.remove(PutItem.name)
|
688
|
+
if not ROOMS[player.CURRENTROOM]['containers'][container].contents:
|
689
|
+
ROOMS[player.CURRENTROOM][container].contents = []
|
690
|
+
if not isinstance(ROOMS[player.CURRENTROOM][container].contents, list):
|
691
|
+
ROOMS[player.CURRENTROOM]['containers'][container].contents = [ROOMS[player.CURRENTROOM]['containers'][container].contents]
|
692
|
+
ROOMS[player.CURRENTROOM]['containers'][container].contents += [PutItem]
|
693
|
+
type_text(f"You put you're %*BLUE*%{PutItem.name}%*RESET*% into the %*RED*%{container}%*RESET*%", colorTrue=color_coding)
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
def handle_get_quest_command(questnum):
|
698
|
+
global player
|
699
|
+
if 'quests' in ROOMS[player.CURRENTROOM]:
|
700
|
+
if questnum in ROOMS[player.CURRENTROOM]['quests']:
|
701
|
+
quest_manager.add_quest(ROOMS[player.CURRENTROOM]['quests'][questnum])
|
702
|
+
quest_manager.start_quest(ROOMS[player.CURRENTROOM]['quests'][questnum])
|
703
|
+
del ROOMS[player.CURRENTROOM]['quests'][questnum]
|
704
|
+
|
705
|
+
|
706
|
+
def PrintMap():
|
707
|
+
global player
|
708
|
+
type_text(ShowMap())
|
709
|
+
|
710
|
+
|
711
|
+
# Define handling functions for different types of enemies
|
712
|
+
def handle_hungry_bear(player: PC, enemy: creature):
|
713
|
+
enemy_reacting = True
|
714
|
+
if 'potion' in player.inventory:
|
715
|
+
if ask_for_consent("Do you want to throw your potion at the bear"):
|
716
|
+
enemy_reacting = False
|
717
|
+
del player.inventory[player.inventory.index('potion')]
|
718
|
+
type_text(f'You throw the potion at the bear and it explodes into a puff of magic smoke that stuns the bear!', colorTrue=color_coding)
|
719
|
+
if enemy_reacting:
|
720
|
+
return [enemy, enemy_reacting]
|
721
|
+
|
722
|
+
def handle_grumpy_pig(player: PC, enemy: creature):
|
723
|
+
enemy_reacting = True
|
724
|
+
if 'saddle' in player.inventory and 'pig-rod' in player.inventory:
|
725
|
+
if ask_for_consent("Do you want to use your saddle and pig-rod on the pig"):
|
726
|
+
enemy_reacting = False
|
727
|
+
type_text(f'You throw a saddle onto the pig and leap on steering it about with a pig fishing rod!', colorTrue=color_coding)
|
728
|
+
del ROOMS[player.CURRENTROOM]['creatures stats']
|
729
|
+
del player.inventory[player.inventory.index('saddle')]
|
730
|
+
del player.inventory[player.inventory.index('pig-rod')]
|
731
|
+
player.inventory_add(item['pig-steed'])
|
732
|
+
player.xp += 20
|
733
|
+
if 'torch' in player.inventory:
|
734
|
+
if ask_for_consent("Do you want to use your torch to scare the pig away"):
|
735
|
+
enemy_reacting = False
|
736
|
+
type_text(f'You wave your torch at the pig and it runs away through a tiny open window.', colorTrue=color_coding)
|
737
|
+
del ROOMS[player.CURRENTROOM]['creatures stats']
|
738
|
+
player.xp += 5
|
739
|
+
if 'rations' in player.inventory:
|
740
|
+
if ask_for_consent("Do you want to throw your ration at the pig"):
|
741
|
+
enemy_reacting = False
|
742
|
+
type_text(f"You quickly throw rations at the pig. It still doesn't look happy though.", colorTrue=color_coding)
|
743
|
+
del player.inventory[player.inventory.index('rations')]
|
744
|
+
player.xp += 15
|
745
|
+
|
746
|
+
if enemy_reacting:
|
747
|
+
return [enemy, enemy_reacting]
|
748
|
+
|
749
|
+
def handle_greedy_goblin(player: PC, enemy: creature):
|
750
|
+
enemy_reacting = True
|
751
|
+
if player.money >= 15:
|
752
|
+
if ask_for_consent("Do you want to pay the goblin to not attack you"):
|
753
|
+
enemy_reacting = False
|
754
|
+
type_text(f"You pay the {enemy.name} to not attack you for now, but he says you should run.", colorTrue=color_coding)
|
755
|
+
player.money -= 15
|
756
|
+
enemy.dropped_items[1].value += 15
|
757
|
+
if enemy_reacting:
|
758
|
+
return [enemy, enemy_reacting]
|
759
|
+
|
760
|
+
commands = {
|
761
|
+
'go': handle_go_command,
|
762
|
+
'get quest': handle_get_quest_command,
|
763
|
+
'get': handle_get_command,
|
764
|
+
'look': handle_look_command,
|
765
|
+
'use': handle_use_command,
|
766
|
+
'search': handle_search_command,
|
767
|
+
'quit': quit,
|
768
|
+
'help': showInstructions,
|
769
|
+
'hint': showHint,
|
770
|
+
'sleep': handle_sleep_command,
|
771
|
+
'put': handle_put_command,
|
772
|
+
'map': PrintMap,
|
773
|
+
}
|
774
|
+
|
775
|
+
|
776
|
+
def quit():
|
777
|
+
exit()
|
778
|
+
|
779
|
+
guards = [
|
780
|
+
Guard(
|
781
|
+
name="Guard",
|
782
|
+
hp=10,
|
783
|
+
atpw=4,
|
784
|
+
description="A 5'8\" human guard who looks like he doesn't belong here.",
|
785
|
+
flavor_text="A human guard spots you and says: 'You shouldn't be here.'",
|
786
|
+
type=creature_type('humanoid', 'human'),
|
787
|
+
current_room="Bedroom",
|
788
|
+
patrol_route=["Bedroom", "Office", "Tower Bottom", "Landing", "Bedroom"],
|
789
|
+
patrol_type='normal'
|
790
|
+
),
|
791
|
+
Guard(
|
792
|
+
name="Wolf",
|
793
|
+
hp=10,
|
794
|
+
atpw=4,
|
795
|
+
description="A large wolf with blood covering its face.",
|
796
|
+
flavor_text="A wolf spots you and growls.",
|
797
|
+
type=creature_type('beast', 'wolf'),
|
798
|
+
current_room="Balcony",
|
799
|
+
patrol_type='random',
|
800
|
+
frendly_text="The wolf nuzzles you"
|
801
|
+
),
|
802
|
+
]
|
803
|
+
|
804
|
+
def handle_wolf(player: PC, wolf: Guard):
|
805
|
+
enemy_reacting = True
|
806
|
+
if 'rations' in player.inventory:
|
807
|
+
if ask_for_consent("Do you want to give your ration to the wolf"):
|
808
|
+
enemy_reacting = False
|
809
|
+
type_text(
|
810
|
+
"You quickly give your rations to the wolf. It looks happy, walks up to you, and nuzzles you.",
|
811
|
+
colorTrue=color_coding
|
812
|
+
)
|
813
|
+
player.inventory.remove('rations')
|
814
|
+
wolf.patrol_type = "follow"
|
815
|
+
wolf.frendly = True
|
816
|
+
return wolf
|
817
|
+
if enemy_reacting:
|
818
|
+
return [wolf, enemy_reacting]
|
819
|
+
|
820
|
+
def handle_guard_action(guard):
|
821
|
+
# Dynamically build the function name
|
822
|
+
function_name = f"handle_{guard.name.lower()}"
|
823
|
+
|
824
|
+
# Use globals() to retrieve the function by name
|
825
|
+
function_to_call = globals().get(function_name)
|
826
|
+
|
827
|
+
if function_to_call:
|
828
|
+
# Call the found function
|
829
|
+
guard = function_to_call(player, guard)
|
830
|
+
return [True, guard] # Function was found and called
|
831
|
+
else:
|
832
|
+
return [False, guard] # Function was not found
|
833
|
+
|
834
|
+
def main():
|
835
|
+
global player, color_coding
|
836
|
+
global charactersList
|
837
|
+
|
838
|
+
|
839
|
+
df = pd.DataFrame(charactersList)
|
840
|
+
|
841
|
+
|
842
|
+
# this is the initializer
|
843
|
+
Standord_Player = loop_til_valid_input("Do you want to use a premade character?", "you didn't answer Y or N.", Y_N).value
|
844
|
+
|
845
|
+
if Standord_Player:
|
846
|
+
while True:
|
847
|
+
type_text("Who do you want to play as?", colorTrue=False)
|
848
|
+
print(df)
|
849
|
+
selected_character = loop_til_valid_input(
|
850
|
+
"Who do you want to play as? (please select the number to the left of there stats)",
|
851
|
+
"That wasn't one of the characters. Please choose one.",
|
852
|
+
int
|
853
|
+
)
|
854
|
+
lstIndex = last_index(charactersList)
|
855
|
+
if selected_character <= lstIndex:
|
856
|
+
character_info = charactersList[selected_character]
|
857
|
+
name = character_info['name']
|
858
|
+
age = character_info['age']
|
859
|
+
height = character_info['height']
|
860
|
+
weight = character_info['weight(LBs)']
|
861
|
+
break
|
862
|
+
else:
|
863
|
+
type_text(colorTrue=False)
|
864
|
+
|
865
|
+
else:
|
866
|
+
type_text("You will now have to enter a name, age, height, and weight. Please enter the height in this format: _ft _. These will be used throughout the game.", colorTrue=False)
|
867
|
+
|
868
|
+
name = loop_til_valid_input("What is your name?", "You didn't enter a string. Please enter a string.", str)
|
869
|
+
age = loop_til_valid_input("What is your age (in whole years)?", "You didn't enter an integer. Please enter an integer.", int)
|
870
|
+
height = loop_til_valid_input("What is your height?", "You didn't enter your height in the correct format. Please enter your height in the correct format.", Height)
|
871
|
+
weight = loop_til_valid_input("What is your weight (in lbs)?", "You didn't enter an integer. Please enter an integer.", int)
|
872
|
+
|
873
|
+
color_coding = loop_til_valid_input("Do you want color coding (Y/N)?", "you didn't answer Y or N.", Y_N).value
|
874
|
+
|
875
|
+
|
876
|
+
# start the player in the Hall and sets up everything else
|
877
|
+
player = PC(
|
878
|
+
name,
|
879
|
+
age,
|
880
|
+
'Warrior',
|
881
|
+
1,
|
882
|
+
'Soldier',
|
883
|
+
height,
|
884
|
+
weight,
|
885
|
+
[
|
886
|
+
f"You joined the army at {14 if age >= 14 else age}",
|
887
|
+
f"You joined the army to end the war and because you wanted glory",
|
888
|
+
f"You spent your first year of service training and the rest on the front lines, surprisingly you didn't die",
|
889
|
+
f"In your service, you made 3 friends, one of them died",
|
890
|
+
f"You fought your enemies from the tops of the mountains to the vast oceans",
|
891
|
+
f"Your father was never home; he was always off on great adventures until he died when you were {7 if age >= 7 else age}",
|
892
|
+
f"You have no friends back home; you were always very lonely",
|
893
|
+
f"You are an only child. You ran away from home to join the army; your mother misses you terribly",
|
894
|
+
f"She was a baker, and you spent a lot of time helping her bake bread. You never went to school",
|
895
|
+
f"The people you admire the most are Sam and Aragorn from Lord of the Rings, which you read as a child. You have also read the Hunger Games when you were {13 if age >= 13 else age}",
|
896
|
+
f"Your favorite weapon is a bow; however, the scimitar is a close second.",
|
897
|
+
],
|
898
|
+
backstory=f"""
|
899
|
+
You were born into a life of solitude as an only child. Your father was always away on grand adventures and passed away when you were just {7 if age >= 7 else age}. Your mother, a dedicated
|
900
|
+
baker, raised you alone. Although she did her best, you spent most of your time helping her in the bakery rather than attending school, which left you feeling quite isolated.
|
901
|
+
|
902
|
+
At the age of {14 if age >= 14 else age}, driven by a desire for glory and a wish to end the war, you left home to join the army. You spent your first year in rigorous training, followed by a
|
903
|
+
harsh life on the front lines. Against all odds, you survived, forging bonds with three close friends—though one of them tragically died in battle. Your journey took you from the heights of
|
904
|
+
mountains to the vast expanses of the ocean, each experience shaping who you are.
|
905
|
+
|
906
|
+
You were deeply influenced by the heroes of your childhood—Sam and Aragorn from %*ITALIC*%Lord of the Rings%*RESET*%, which you read as a child, and the characters from %*ITALIC*%The Hunger
|
907
|
+
Games%*RESET*%, which you read when you were {13 if age >= 13 else age}. These stories inspired you and fueled your dream of heroism. Though your favorite weapon is a bow, you also have a
|
908
|
+
fondness for the scimitar.
|
909
|
+
|
910
|
+
Now, you find yourself in the Mansion of Amnesia, a place that seems to have erased your memories. The details of your past are fragmented, but the echoes of your history drive you forward. You
|
911
|
+
must navigate the mansion and uncover the truth behind your captivity, all while drawing strength from the remnants of your past.
|
912
|
+
""",
|
913
|
+
CURRENTROOM='Hall'
|
914
|
+
)
|
915
|
+
|
916
|
+
# shows the instructions
|
917
|
+
start()
|
918
|
+
|
919
|
+
# loop forever while the player wants to play
|
920
|
+
while True:
|
921
|
+
command()
|
922
|
+
|
923
|
+
enemy_REFs = []
|
924
|
+
|
925
|
+
# Move guards
|
926
|
+
for guard in guards:
|
927
|
+
if isinstance(guard, Guard):
|
928
|
+
guard.move(ROOMS, player)
|
929
|
+
|
930
|
+
# Check for detection
|
931
|
+
for guard in guards:
|
932
|
+
if isinstance(guard, Guard):
|
933
|
+
if guard.check_detection(player.CURRENTROOM):
|
934
|
+
guard_handled = handle_guard_action(guard)
|
935
|
+
if not isinstance(guard_handled, list):
|
936
|
+
guard_handled = [guard_handled]
|
937
|
+
|
938
|
+
# Get is_reacting from guard_handled
|
939
|
+
is_reacting = guard_handled[1][1]
|
940
|
+
|
941
|
+
# Only update guard if the guard is reacting
|
942
|
+
if is_reacting:
|
943
|
+
if guard.frendly:
|
944
|
+
good_guys.append(guard)
|
945
|
+
else:
|
946
|
+
bad_guys.append(guard)
|
947
|
+
|
948
|
+
if guard_handled[0]:
|
949
|
+
guards[guards.index(guard)] = guard_handled[1][0]
|
950
|
+
|
951
|
+
# Handle creatures in the current room
|
952
|
+
if 'creatures stats' in ROOMS[player.CURRENTROOM]:
|
953
|
+
is_reactings = []
|
954
|
+
enemies = ROOMS[player.CURRENTROOM]['creatures stats']
|
955
|
+
if not isinstance(enemies, list):
|
956
|
+
enemies = [enemies] # Ensure enemies is a list even if there's only one creature
|
957
|
+
|
958
|
+
good_guys = []
|
959
|
+
bad_guys = []
|
960
|
+
|
961
|
+
for enemy in enemies:
|
962
|
+
if isinstance(enemy, creature):
|
963
|
+
enemy.type_text_flavor_text()
|
964
|
+
|
965
|
+
# Handle specific creatures
|
966
|
+
if enemy.name == 'hungry bear':
|
967
|
+
enemy_REF = handle_hungry_bear(player, enemy)
|
968
|
+
elif enemy.name == 'grumpy pig':
|
969
|
+
enemy_REF = handle_grumpy_pig(player, enemy)
|
970
|
+
elif enemy.name == 'greedy goblin':
|
971
|
+
enemy_REF = handle_greedy_goblin(player, enemy)
|
972
|
+
else:
|
973
|
+
enemy_REF = enemy
|
974
|
+
|
975
|
+
if isinstance(enemy_REF, list):
|
976
|
+
is_reacting = enemy_REF[1]
|
977
|
+
enemy_REF = enemy_REF[0]
|
978
|
+
is_reactings.append(is_reacting)
|
979
|
+
|
980
|
+
enemies[enemies.index(enemy)] = enemy_REF
|
981
|
+
|
982
|
+
# Add to good or bad lists if reacting
|
983
|
+
if is_reacting:
|
984
|
+
if enemy_REF.frendly:
|
985
|
+
good_guys.append(enemy_REF)
|
986
|
+
else:
|
987
|
+
bad_guys.append(enemy_REF)
|
988
|
+
|
989
|
+
if all_same_value(enemies, False):
|
990
|
+
del ROOMS[player.CURRENTROOM]['creatures stats']
|
991
|
+
else:
|
992
|
+
ROOMS[player.CURRENTROOM]['creatures stats'] = enemies
|
993
|
+
|
994
|
+
# Execute battle with separated good and bad guys
|
995
|
+
if bad_guys:
|
996
|
+
good_guys, bad_guys = battle(player, good_guys, bad_guys, player.LASTROOM)
|
997
|
+
|
998
|
+
# Handle NPC interactions
|
999
|
+
if 'NPCs' in ROOMS[player.CURRENTROOM]:
|
1000
|
+
for npcname, npcstats in ROOMS[player.CURRENTROOM]['NPCs'].items():
|
1001
|
+
if ask_for_consent("Do you want to interact with this NPC") or npcstats.aggressive:
|
1002
|
+
npcstats.interact()
|
1003
|
+
if npcstats.aggressive:
|
1004
|
+
ROOMS[player.CURRENTROOM]['NPCs'][npcname] = battle(player, [], [npcstats], player.LASTROOM)[1]
|
1005
|
+
|
1006
|
+
player.special_ability.Tick()
|
1007
|
+
quest_manager.update_objective(f"Kill {GameState['Enemies killed']} creatures")
|
1008
|
+
for Item in GameState['collected items']:
|
1009
|
+
if isinstance(Item, item):
|
1010
|
+
quest_manager.update_objective(f"Collect {Item.name}")
|
1011
|
+
|
1012
|
+
|
1013
|
+
|
1014
|
+
|
1015
|
+
|
1016
|
+
if __name__ == "__main__":
|
1017
|
+
main()
|