neelthee-mansion 2.4.1__py3-none-any.whl → 2.4.3__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 +118 -71
- neelthee_mansion/Rooms.py +8 -0
- neelthee_mansion/creatures.py +4 -4
- {neelthee_mansion-2.4.1.dist-info → neelthee_mansion-2.4.3.dist-info}/METADATA +1 -1
- {neelthee_mansion-2.4.1.dist-info → neelthee_mansion-2.4.3.dist-info}/RECORD +8 -8
- {neelthee_mansion-2.4.1.dist-info → neelthee_mansion-2.4.3.dist-info}/WHEEL +0 -0
- {neelthee_mansion-2.4.1.dist-info → neelthee_mansion-2.4.3.dist-info}/entry_points.txt +0 -0
- {neelthee_mansion-2.4.1.dist-info → neelthee_mansion-2.4.3.dist-info}/top_level.txt +0 -0
@@ -387,44 +387,53 @@ def display_directions(text):
|
|
387
387
|
|
388
388
|
return text
|
389
389
|
|
390
|
-
def battle(player: PC,
|
390
|
+
def battle(player: PC, good_guys: list, bad_guys: list, last_room):
|
391
391
|
"""
|
392
|
-
Simulate a battle between the player and
|
392
|
+
Simulate a battle between the player (and allies) and monsters.
|
393
393
|
|
394
394
|
Args:
|
395
395
|
player (PC): The player character.
|
396
|
-
|
396
|
+
good_guys (list): The list of allies to help the player.
|
397
|
+
bad_guys (list): The list of monsters to battle the player.
|
397
398
|
last_room: The previous room before the battle.
|
398
399
|
|
399
400
|
Returns:
|
400
|
-
|
401
|
+
None if all bad guys are defeated, else the remaining bad guys.
|
401
402
|
"""
|
402
|
-
while player.hp > 0 and monster.hp > 0:
|
403
|
+
while player.hp > 0 and any(monster.hp > 0 for monster in bad_guys):
|
403
404
|
if ask_for_consent("Do you want to run away"):
|
404
405
|
Move(last_room)
|
405
|
-
return
|
406
|
+
return None, bad_guys
|
406
407
|
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
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)
|
412
422
|
|
413
|
-
monster_turn(player, monster)
|
414
|
-
|
415
423
|
if player.hp <= 0:
|
416
|
-
End(f'The
|
417
|
-
return
|
424
|
+
End(f'The monsters defeat you!', win=False)
|
425
|
+
return good_guys, bad_guys
|
426
|
+
|
427
|
+
return good_guys, bad_guys
|
418
428
|
|
419
|
-
return monster
|
420
429
|
|
421
430
|
def player_turn(player: PC, monster: creature):
|
422
431
|
"""
|
423
|
-
Handle
|
432
|
+
Handle a character's turn during the battle.
|
424
433
|
|
425
434
|
Args:
|
426
|
-
player (PC): The player
|
427
|
-
monster (creature): The monster
|
435
|
+
player (PC): The player or ally.
|
436
|
+
monster (creature): The monster being fought.
|
428
437
|
"""
|
429
438
|
player_action = loop_til_valid_input(
|
430
439
|
"Choose your action: (attack/defend/special): ",
|
@@ -440,57 +449,53 @@ def player_turn(player: PC, monster: creature):
|
|
440
449
|
elif player_action == "special":
|
441
450
|
use_special_ability(player, monster)
|
442
451
|
|
452
|
+
|
443
453
|
def monster_turn(player: PC, monster: creature):
|
444
454
|
"""
|
445
|
-
Handle
|
455
|
+
Handle a monster's turn during the battle.
|
446
456
|
|
447
457
|
Args:
|
448
|
-
player (PC): The player
|
449
|
-
monster (creature): The monster
|
458
|
+
player (PC): The player or ally.
|
459
|
+
monster (creature): The monster attacking.
|
450
460
|
"""
|
451
461
|
type_text(f"The %*CYAN*%{monster.name}%*RESET*% attacks!", colorTrue=color_coding)
|
452
462
|
damage = calculate_damage(monster, player)
|
453
|
-
|
454
463
|
player.take_damage(damage)
|
455
464
|
|
465
|
+
|
456
466
|
def perform_attack(attacker: PC, defender: creature):
|
457
|
-
global player
|
458
467
|
"""
|
459
468
|
Perform an attack action.
|
460
469
|
|
461
470
|
Args:
|
462
471
|
attacker (PC): The attacking character.
|
463
472
|
defender (creature): The defending monster.
|
464
|
-
global player
|
465
473
|
"""
|
466
474
|
damage = calculate_damage(attacker, defender)
|
467
|
-
global player
|
468
475
|
defender.take_damage(damage)
|
469
|
-
global player
|
470
476
|
|
471
|
-
|
477
|
+
|
478
|
+
def handle_victory(player: PC, monsters: list):
|
472
479
|
"""
|
473
|
-
Handle the logic when the player
|
474
|
-
global player
|
480
|
+
Handle the logic when the player and allies defeat all monsters.
|
475
481
|
|
476
482
|
Args:
|
477
483
|
player (PC): The player character.
|
478
|
-
|
479
|
-
global player
|
484
|
+
monsters (list): The list of defeated monsters.
|
480
485
|
"""
|
481
|
-
type_text(
|
482
|
-
|
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
|
+
|
483
491
|
|
484
492
|
def calculate_damage(attacker, defender) -> int:
|
485
|
-
global player
|
486
493
|
"""
|
487
494
|
Calculate the damage inflicted by the attacker on the defender.
|
488
|
-
global player
|
489
495
|
|
490
496
|
Args:
|
491
497
|
attacker: The attacking character.
|
492
498
|
defender: The defending character.
|
493
|
-
global player
|
494
499
|
|
495
500
|
Returns:
|
496
501
|
int: The calculated damage.
|
@@ -509,8 +514,8 @@ def calculate_damage(attacker, defender) -> int:
|
|
509
514
|
|
510
515
|
return damage
|
511
516
|
|
517
|
+
|
512
518
|
def calculate_damage_range(atpw: int) -> tuple[int, int]:
|
513
|
-
global player
|
514
519
|
"""
|
515
520
|
Calculate the damage range based on attack power.
|
516
521
|
|
@@ -518,7 +523,7 @@ def calculate_damage_range(atpw: int) -> tuple[int, int]:
|
|
518
523
|
atpw (int): Attack power of the combatant.
|
519
524
|
|
520
525
|
Returns:
|
521
|
-
|
526
|
+
tuple[int, int]: Minimum and maximum damage range.
|
522
527
|
"""
|
523
528
|
damage_max_range = randint(1, 3)
|
524
529
|
damage_min_range = randint(1, 3)
|
@@ -526,6 +531,7 @@ def calculate_damage_range(atpw: int) -> tuple[int, int]:
|
|
526
531
|
damage_max = atpw + damage_max_range
|
527
532
|
return damage_min, damage_max
|
528
533
|
|
534
|
+
|
529
535
|
def use_special_ability(player: PC, monster: creature):
|
530
536
|
"""
|
531
537
|
Allow the player to use a special ability during combat.
|
@@ -542,6 +548,22 @@ def use_special_ability(player: PC, monster: creature):
|
|
542
548
|
type_text("Your special ability is not ready yet.", colorTrue=color_coding)
|
543
549
|
|
544
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
|
+
|
545
567
|
def command():
|
546
568
|
global player
|
547
569
|
try:
|
@@ -695,7 +717,7 @@ def handle_hungry_bear(player: PC, enemy: creature):
|
|
695
717
|
del player.inventory[player.inventory.index('potion')]
|
696
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)
|
697
719
|
if enemy_reacting:
|
698
|
-
return
|
720
|
+
return [enemy, enemy_reacting]
|
699
721
|
|
700
722
|
def handle_grumpy_pig(player: PC, enemy: creature):
|
701
723
|
enemy_reacting = True
|
@@ -722,7 +744,7 @@ def handle_grumpy_pig(player: PC, enemy: creature):
|
|
722
744
|
player.xp += 15
|
723
745
|
|
724
746
|
if enemy_reacting:
|
725
|
-
return
|
747
|
+
return [enemy, enemy_reacting]
|
726
748
|
|
727
749
|
def handle_greedy_goblin(player: PC, enemy: creature):
|
728
750
|
enemy_reacting = True
|
@@ -733,7 +755,7 @@ def handle_greedy_goblin(player: PC, enemy: creature):
|
|
733
755
|
player.money -= 15
|
734
756
|
enemy.dropped_items[1].value += 15
|
735
757
|
if enemy_reacting:
|
736
|
-
return
|
758
|
+
return [enemy, enemy_reacting]
|
737
759
|
|
738
760
|
commands = {
|
739
761
|
'go': handle_go_command,
|
@@ -793,7 +815,7 @@ def handle_wolf(player: PC, wolf: Guard):
|
|
793
815
|
wolf.frendly = True
|
794
816
|
return wolf
|
795
817
|
if enemy_reacting:
|
796
|
-
return
|
818
|
+
return [wolf, enemy_reacting]
|
797
819
|
|
798
820
|
def handle_guard_action(guard):
|
799
821
|
# Dynamically build the function name
|
@@ -898,6 +920,8 @@ must navigate the mansion and uncover the truth behind your captivity, all while
|
|
898
920
|
while True:
|
899
921
|
command()
|
900
922
|
|
923
|
+
enemy_REFs = []
|
924
|
+
|
901
925
|
# Move guards
|
902
926
|
for guard in guards:
|
903
927
|
if isinstance(guard, Guard):
|
@@ -905,62 +929,85 @@ must navigate the mansion and uncover the truth behind your captivity, all while
|
|
905
929
|
|
906
930
|
# Check for detection
|
907
931
|
for guard in guards:
|
908
|
-
|
909
|
-
if
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
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)
|
917
945
|
else:
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
#
|
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
|
924
952
|
if 'creatures stats' in ROOMS[player.CURRENTROOM]:
|
953
|
+
is_reactings = []
|
925
954
|
enemies = ROOMS[player.CURRENTROOM]['creatures stats']
|
926
955
|
if not isinstance(enemies, list):
|
927
956
|
enemies = [enemies] # Ensure enemies is a list even if there's only one creature
|
928
957
|
|
958
|
+
good_guys = []
|
959
|
+
bad_guys = []
|
929
960
|
|
930
961
|
for enemy in enemies:
|
931
962
|
if isinstance(enemy, creature):
|
932
963
|
enemy.type_text_flavor_text()
|
933
964
|
|
965
|
+
# Handle specific creatures
|
934
966
|
if enemy.name == 'hungry bear':
|
935
967
|
enemy_REF = handle_hungry_bear(player, enemy)
|
936
|
-
enemies[enemies.index(enemy)] = enemy_REF
|
937
968
|
elif enemy.name == 'grumpy pig':
|
938
969
|
enemy_REF = handle_grumpy_pig(player, enemy)
|
939
|
-
enemies[enemies.index(enemy)] = enemy_REF
|
940
970
|
elif enemy.name == 'greedy goblin':
|
941
971
|
enemy_REF = handle_greedy_goblin(player, enemy)
|
942
|
-
enemies[enemies.index(enemy)] = enemy_REF
|
943
972
|
else:
|
944
|
-
enemy_REF =
|
945
|
-
|
973
|
+
enemy_REF = enemy
|
974
|
+
|
975
|
+
if isinstance(enemy_REF, list):
|
976
|
+
enemy_REF = enemy_REF[1]
|
977
|
+
is_reacting = 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)
|
946
988
|
|
947
989
|
if all_same_value(enemies, False):
|
948
990
|
del ROOMS[player.CURRENTROOM]['creatures stats']
|
949
991
|
else:
|
950
992
|
ROOMS[player.CURRENTROOM]['creatures stats'] = enemies
|
951
|
-
|
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
|
952
999
|
if 'NPCs' in ROOMS[player.CURRENTROOM]:
|
953
1000
|
for npcname, npcstats in ROOMS[player.CURRENTROOM]['NPCs'].items():
|
954
1001
|
if ask_for_consent("Do you want to interact with this NPC") or npcstats.aggressive:
|
955
|
-
npcstats.interact
|
1002
|
+
npcstats.interact()
|
956
1003
|
if npcstats.aggressive:
|
957
|
-
ROOMS[player.CURRENTROOM]['NPCs'][npcname] = battle(player, npcstats)
|
958
|
-
|
1004
|
+
ROOMS[player.CURRENTROOM]['NPCs'][npcname] = battle(player, [], [npcstats], player.LASTROOM)[1]
|
1005
|
+
|
959
1006
|
player.special_ability.Tick()
|
960
|
-
quest_manager.update_objective(f"Kill {GameState['
|
961
|
-
for
|
962
|
-
if isinstance(
|
963
|
-
quest_manager.update_objective(f"
|
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}")
|
964
1011
|
|
965
1012
|
|
966
1013
|
|
neelthee_mansion/Rooms.py
CHANGED
@@ -160,6 +160,14 @@ ROOMS = {
|
|
160
160
|
'A large 7ft 8 brown bear that looks hungry',
|
161
161
|
'A %*CYAN*%hungry%*RESET*% bear attacks you!',
|
162
162
|
),
|
163
|
+
creature(
|
164
|
+
'hungry bear',
|
165
|
+
7,
|
166
|
+
5,
|
167
|
+
[item('claw')],
|
168
|
+
'A large 7ft 8 brown bear that looks hungry',
|
169
|
+
'A %*CYAN*%hungry%*RESET*% bear attacks you!',
|
170
|
+
),
|
163
171
|
],
|
164
172
|
'info': 'You are in the kitchen, there are several trashed %*RED*%cupboards%*RESET*%, one of them has a knotted cord sticking out, and a fireplace.',
|
165
173
|
'map': '''
|
neelthee_mansion/creatures.py
CHANGED
@@ -106,7 +106,7 @@ class creature(base_character):
|
|
106
106
|
crit_chance (float): The chance of the creature landing a critical hit.
|
107
107
|
"""
|
108
108
|
|
109
|
-
def __init__(self, name: str, hp: int, atpw: int, dropped_items: list[str] = [], description: str = None, flavor_text: str = None, type: creature_type = creature_type('beast'), crit_chance: float = 0.05):
|
109
|
+
def __init__(self, name: str, hp: int, atpw: int, dropped_items: list[str] = [], description: str = None, flavor_text: str = None, type: creature_type = creature_type('beast'), crit_chance: float = 0.05, frendly_text: str = ""):
|
110
110
|
"""
|
111
111
|
Initializes a new creature instance.
|
112
112
|
|
@@ -130,6 +130,8 @@ class creature(base_character):
|
|
130
130
|
self.flavor_text = flavor_text if flavor_text else f'You see a %*CYAN*%{self.name}%*RESET*%!'
|
131
131
|
self.type = type
|
132
132
|
self.crit_chance = crit_chance
|
133
|
+
self.frendly = False
|
134
|
+
self.frendly_text = frendly_text
|
133
135
|
|
134
136
|
def type_text_flavor_text(self):
|
135
137
|
"""
|
@@ -169,12 +171,10 @@ class Guard(creature):
|
|
169
171
|
patrol_route (list[str], optional): The list of rooms the guard patrols through. Defaults to None.
|
170
172
|
patrol_type (str): The type of patrol the guard is doing. Defaults to normal.
|
171
173
|
"""
|
172
|
-
super().__init__(name, hp, atpw, dropped_items, description, flavor_text, type, crit_chance)
|
174
|
+
super().__init__(name, hp, atpw, dropped_items, description, flavor_text, type, crit_chance, frendly_text)
|
173
175
|
self.current_room = current_room
|
174
176
|
self.patrol_route = patrol_route or []
|
175
177
|
self.patrol_type = patrol_type
|
176
|
-
self.frendly = False
|
177
|
-
self.frendly_text = frendly_text
|
178
178
|
|
179
179
|
def move(self, ROOMS, player):
|
180
180
|
"""
|
@@ -1,14 +1,14 @@
|
|
1
|
-
neelthee_mansion/Mansion_of_Amnesia.py,sha256=
|
1
|
+
neelthee_mansion/Mansion_of_Amnesia.py,sha256=IjbDimwtEg41npmefR0UuON09Gq2mQsLXKJ0OH1jicQ,41715
|
2
2
|
neelthee_mansion/Quests.py,sha256=q6VzR3mt9AYe29ACWZuf-suz4yOKrL946aJ493eQRS0,2611
|
3
|
-
neelthee_mansion/Rooms.py,sha256=
|
3
|
+
neelthee_mansion/Rooms.py,sha256=VHvg2FcV5yB54CZM1aNXdjULKtubTYqdHDFenqxxIj4,83126
|
4
4
|
neelthee_mansion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
neelthee_mansion/__main__.py,sha256=OIAWZ04le70DyjtR4hlmK9csHej7EHxeUrMoNnM-Vjc,95
|
6
6
|
neelthee_mansion/all_game_utils.py,sha256=Xfty9uXiYAfmA6iVzJurq852ZBPn7a4gQUcUcaV9yEU,341
|
7
|
-
neelthee_mansion/creatures.py,sha256=
|
7
|
+
neelthee_mansion/creatures.py,sha256=_OhULTc_wvrwn49bMsoq10x3j2TPs11cFFJhyd68MUc,14824
|
8
8
|
neelthee_mansion/items.py,sha256=uzZ9fq6_YK3oQ2lkAsyidWwM6trasVsjdQi2V0JTPfw,2097
|
9
9
|
neelthee_mansion/utils.py,sha256=7JkgDw4Tq3EG11DqX05tjisoGxE0L_Sd7VkqkU8x-jQ,11486
|
10
|
-
neelthee_mansion-2.4.
|
11
|
-
neelthee_mansion-2.4.
|
12
|
-
neelthee_mansion-2.4.
|
13
|
-
neelthee_mansion-2.4.
|
14
|
-
neelthee_mansion-2.4.
|
10
|
+
neelthee_mansion-2.4.3.dist-info/METADATA,sha256=8UcKSwVBA8ttxbhL6qL0d022cozqgsk1ufro267lmjI,1991
|
11
|
+
neelthee_mansion-2.4.3.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
12
|
+
neelthee_mansion-2.4.3.dist-info/entry_points.txt,sha256=j5ScTTyIidFhmT3F6hcX9pnlom4cJdDmfe26BmM6Igo,56
|
13
|
+
neelthee_mansion-2.4.3.dist-info/top_level.txt,sha256=woQImQewylhly5Rb24HwPEGMxPY6do_PaUwGd5BNLOM,17
|
14
|
+
neelthee_mansion-2.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|