neelthee-mansion 2.4.0__tar.gz → 2.4.2__tar.gz

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.
Files changed (19) hide show
  1. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/PKG-INFO +3 -2
  2. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/README.md +2 -1
  3. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/Mansion_of_Amnesia.py +123 -74
  4. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/Rooms.py +8 -0
  5. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/creatures.py +4 -4
  6. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/PKG-INFO +3 -2
  7. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/setup.py +1 -1
  8. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/Quests.py +0 -0
  9. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/__init__.py +0 -0
  10. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/__main__.py +0 -0
  11. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/all_game_utils.py +0 -0
  12. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/items.py +0 -0
  13. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion/utils.py +0 -0
  14. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/SOURCES.txt +0 -0
  15. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/dependency_links.txt +0 -0
  16. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/entry_points.txt +0 -0
  17. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/requires.txt +0 -0
  18. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/neelthee_mansion.egg-info/top_level.txt +0 -0
  19. {neelthee_mansion-2.4.0 → neelthee_mansion-2.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neelthee_mansion
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: A text-based adventure game set in Neel-thee’s mansion.
5
5
  Home-page: https://github.com/Flameblade375/neelthee_mansion
6
6
  Author: Alexander.E.F
@@ -31,7 +31,8 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  ## Installation
33
33
 
34
- You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following command (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
34
+ You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following commands. You need wheel installed before you can install **Neel-thee's Mansion of Amnesia**. (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
35
35
 
36
36
  ```bash
37
+ pip install wheel
37
38
  pip install --no-cache-dir neelthee_mansion
@@ -11,7 +11,8 @@
11
11
 
12
12
  ## Installation
13
13
 
14
- You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following command (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
14
+ You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following commands. You need wheel installed before you can install **Neel-thee's Mansion of Amnesia**. (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
15
15
 
16
16
  ```bash
17
+ pip install wheel
17
18
  pip install --no-cache-dir neelthee_mansion
@@ -67,10 +67,12 @@ charactersList = [
67
67
  {'name': 'Lucas', 'age': 28, 'height': Height('5ft 10'), 'weight(LBs)': 170},
68
68
  {'name': 'Ava', 'age': 22, 'height': Height('5ft 5'), 'weight(LBs)': 130},
69
69
  {'name': 'Lily', 'age': 26, 'height': Height('5ft 6'), 'weight(LBs)': 135},
70
- {'name': 'Grace', 'age': 29, 'height': Height('5ft 7'), 'weight(LBs)': 140}
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},
71
73
  ]
72
-
73
-
74
+
75
+
74
76
  evil_mage = PC(
75
77
  'Neel-thee Contozt',
76
78
  19836,
@@ -385,44 +387,53 @@ def display_directions(text):
385
387
 
386
388
  return text
387
389
 
388
- def battle(player: PC, monster: creature, last_room):
390
+ def battle(player: PC, good_guys: list, bad_guys: list, last_room):
389
391
  """
390
- Simulate a battle between the player and a monster.
392
+ Simulate a battle between the player (and allies) and monsters.
391
393
 
392
394
  Args:
393
395
  player (PC): The player character.
394
- monster (creature): The monster to battle.
396
+ good_guys (list): The list of allies to help the player.
397
+ bad_guys (list): The list of monsters to battle the player.
395
398
  last_room: The previous room before the battle.
396
399
 
397
400
  Returns:
398
- The monster if it is still alive, None otherwise.
401
+ None if all bad guys are defeated, else the remaining bad guys.
399
402
  """
400
- while player.hp > 0 and monster.hp > 0:
403
+ while player.hp > 0 and any(monster.hp > 0 for monster in bad_guys):
401
404
  if ask_for_consent("Do you want to run away"):
402
405
  Move(last_room)
403
- return monster
406
+ return None, bad_guys
404
407
 
405
- player_turn(player, monster)
406
-
407
- if monster.hp <= 0:
408
- handle_victory(player, monster)
409
- return None
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)
410
422
 
411
- monster_turn(player, monster)
412
-
413
423
  if player.hp <= 0:
414
- End(f'The %*CYAN*%{monster.name}%*RESET*% defeats you!', win=False)
415
- return monster
424
+ End(f'The monsters defeat you!', win=False)
425
+ return good_guys, bad_guys
426
+
427
+ return good_guys, bad_guys
416
428
 
417
- return monster
418
429
 
419
430
  def player_turn(player: PC, monster: creature):
420
431
  """
421
- Handle the player's turn during the battle.
432
+ Handle a character's turn during the battle.
422
433
 
423
434
  Args:
424
- player (PC): The player character.
425
- monster (creature): The monster to battle.
435
+ player (PC): The player or ally.
436
+ monster (creature): The monster being fought.
426
437
  """
427
438
  player_action = loop_til_valid_input(
428
439
  "Choose your action: (attack/defend/special): ",
@@ -438,57 +449,53 @@ def player_turn(player: PC, monster: creature):
438
449
  elif player_action == "special":
439
450
  use_special_ability(player, monster)
440
451
 
452
+
441
453
  def monster_turn(player: PC, monster: creature):
442
454
  """
443
- Handle the monster's turn during the battle.
455
+ Handle a monster's turn during the battle.
444
456
 
445
457
  Args:
446
- player (PC): The player character.
447
- monster (creature): The monster to battle.
458
+ player (PC): The player or ally.
459
+ monster (creature): The monster attacking.
448
460
  """
449
461
  type_text(f"The %*CYAN*%{monster.name}%*RESET*% attacks!", colorTrue=color_coding)
450
462
  damage = calculate_damage(monster, player)
451
-
452
463
  player.take_damage(damage)
453
464
 
465
+
454
466
  def perform_attack(attacker: PC, defender: creature):
455
- global player
456
467
  """
457
468
  Perform an attack action.
458
469
 
459
470
  Args:
460
471
  attacker (PC): The attacking character.
461
472
  defender (creature): The defending monster.
462
- global player
463
473
  """
464
474
  damage = calculate_damage(attacker, defender)
465
- global player
466
475
  defender.take_damage(damage)
467
- global player
468
476
 
469
- def handle_victory(player: PC, monster: creature):
477
+
478
+ def handle_victory(player: PC, monsters: list):
470
479
  """
471
- Handle the logic when the player defeats the monster.
472
- global player
480
+ Handle the logic when the player and allies defeat all monsters.
473
481
 
474
482
  Args:
475
483
  player (PC): The player character.
476
- monster (creature): The defeated monster.
477
- global player
484
+ monsters (list): The list of defeated monsters.
478
485
  """
479
- type_text(f"You defeat the %*CYAN*%{monster.name}%*RESET*%!", colorTrue=color_coding)
480
- player.inventory_add(monster.dropped_items)
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
+
481
491
 
482
492
  def calculate_damage(attacker, defender) -> int:
483
- global player
484
493
  """
485
494
  Calculate the damage inflicted by the attacker on the defender.
486
- global player
487
495
 
488
496
  Args:
489
497
  attacker: The attacking character.
490
498
  defender: The defending character.
491
- global player
492
499
 
493
500
  Returns:
494
501
  int: The calculated damage.
@@ -507,8 +514,8 @@ def calculate_damage(attacker, defender) -> int:
507
514
 
508
515
  return damage
509
516
 
517
+
510
518
  def calculate_damage_range(atpw: int) -> tuple[int, int]:
511
- global player
512
519
  """
513
520
  Calculate the damage range based on attack power.
514
521
 
@@ -516,7 +523,7 @@ def calculate_damage_range(atpw: int) -> tuple[int, int]:
516
523
  atpw (int): Attack power of the combatant.
517
524
 
518
525
  Returns:
519
- Tuple[int, int]: Minimum and maximum damage range.
526
+ tuple[int, int]: Minimum and maximum damage range.
520
527
  """
521
528
  damage_max_range = randint(1, 3)
522
529
  damage_min_range = randint(1, 3)
@@ -524,6 +531,7 @@ def calculate_damage_range(atpw: int) -> tuple[int, int]:
524
531
  damage_max = atpw + damage_max_range
525
532
  return damage_min, damage_max
526
533
 
534
+
527
535
  def use_special_ability(player: PC, monster: creature):
528
536
  """
529
537
  Allow the player to use a special ability during combat.
@@ -540,6 +548,22 @@ def use_special_ability(player: PC, monster: creature):
540
548
  type_text("Your special ability is not ready yet.", colorTrue=color_coding)
541
549
 
542
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
+
543
567
  def command():
544
568
  global player
545
569
  try:
@@ -693,7 +717,7 @@ def handle_hungry_bear(player: PC, enemy: creature):
693
717
  del player.inventory[player.inventory.index('potion')]
694
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)
695
719
  if enemy_reacting:
696
- return battle(player, enemy, player.LASTROOM)
720
+ return [enemy, enemy_reacting]
697
721
 
698
722
  def handle_grumpy_pig(player: PC, enemy: creature):
699
723
  enemy_reacting = True
@@ -720,7 +744,7 @@ def handle_grumpy_pig(player: PC, enemy: creature):
720
744
  player.xp += 15
721
745
 
722
746
  if enemy_reacting:
723
- return battle(player, enemy, player.LASTROOM)
747
+ return [enemy, enemy_reacting]
724
748
 
725
749
  def handle_greedy_goblin(player: PC, enemy: creature):
726
750
  enemy_reacting = True
@@ -731,7 +755,7 @@ def handle_greedy_goblin(player: PC, enemy: creature):
731
755
  player.money -= 15
732
756
  enemy.dropped_items[1].value += 15
733
757
  if enemy_reacting:
734
- return battle(player, enemy, player.LASTROOM)
758
+ return [enemy, enemy_reacting]
735
759
 
736
760
  commands = {
737
761
  'go': handle_go_command,
@@ -791,7 +815,7 @@ def handle_wolf(player: PC, wolf: Guard):
791
815
  wolf.frendly = True
792
816
  return wolf
793
817
  if enemy_reacting:
794
- return battle(player, wolf, player.LASTROOM)
818
+ return [wolf, enemy_reacting]
795
819
 
796
820
  def handle_guard_action(guard):
797
821
  # Dynamically build the function name
@@ -896,6 +920,8 @@ must navigate the mansion and uncover the truth behind your captivity, all while
896
920
  while True:
897
921
  command()
898
922
 
923
+ enemy_REFs = []
924
+
899
925
  # Move guards
900
926
  for guard in guards:
901
927
  if isinstance(guard, Guard):
@@ -903,62 +929,85 @@ must navigate the mansion and uncover the truth behind your captivity, all while
903
929
 
904
930
  # Check for detection
905
931
  for guard in guards:
906
- #try:
907
- if isinstance(guard, Guard):
908
- if guard.check_detection(player.CURRENTROOM):
909
- guard_handled = handle_guard_action(guard)
910
- if not isinstance(guard_handled, list):
911
- guard_handled = [guard_handled]
912
- if not guard_handled[0]:
913
- guard.type_text_flavor_text()
914
- guards[guards.index(guard)] = battle(player, guard, player.LASTROOM)
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)
915
945
  else:
916
- guards[guards.index(guard)] = guard_handled[1]
917
- #except:
918
- # guard.type_text_flavor_text()
919
- # guards[guards.index(guard)] = battle(player, guard, player.LASTROOM)
920
-
921
- # player loses if they enter a room with a monster, unless they can fight it.
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
922
952
  if 'creatures stats' in ROOMS[player.CURRENTROOM]:
953
+ is_reactings = []
923
954
  enemies = ROOMS[player.CURRENTROOM]['creatures stats']
924
955
  if not isinstance(enemies, list):
925
956
  enemies = [enemies] # Ensure enemies is a list even if there's only one creature
926
957
 
958
+ good_guys = []
959
+ bad_guys = []
927
960
 
928
961
  for enemy in enemies:
929
962
  if isinstance(enemy, creature):
930
963
  enemy.type_text_flavor_text()
931
964
 
965
+ # Handle specific creatures
932
966
  if enemy.name == 'hungry bear':
933
967
  enemy_REF = handle_hungry_bear(player, enemy)
934
- enemies[enemies.index(enemy)] = enemy_REF
935
968
  elif enemy.name == 'grumpy pig':
936
969
  enemy_REF = handle_grumpy_pig(player, enemy)
937
- enemies[enemies.index(enemy)] = enemy_REF
938
970
  elif enemy.name == 'greedy goblin':
939
971
  enemy_REF = handle_greedy_goblin(player, enemy)
940
- enemies[enemies.index(enemy)] = enemy_REF
941
972
  else:
942
- enemy_REF = battle(player, enemy, player.LASTROOM)
943
- enemies[enemies.index(enemy)] = enemy_REF
973
+ enemy_REF = enemy
974
+
975
+ if isinstance(enemy_REF, list):
976
+ enemy_REF = enemy_REF[0]
977
+ is_reacting = enemy_REF[1]
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)
944
988
 
945
989
  if all_same_value(enemies, False):
946
990
  del ROOMS[player.CURRENTROOM]['creatures stats']
947
991
  else:
948
992
  ROOMS[player.CURRENTROOM]['creatures stats'] = enemies
949
-
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
950
999
  if 'NPCs' in ROOMS[player.CURRENTROOM]:
951
1000
  for npcname, npcstats in ROOMS[player.CURRENTROOM]['NPCs'].items():
952
1001
  if ask_for_consent("Do you want to interact with this NPC") or npcstats.aggressive:
953
- npcstats.interact
1002
+ npcstats.interact()
954
1003
  if npcstats.aggressive:
955
- ROOMS[player.CURRENTROOM]['NPCs'][npcname] = battle(player, npcstats)
956
-
1004
+ ROOMS[player.CURRENTROOM]['NPCs'][npcname] = battle(player, [], [npcstats], player.LASTROOM)[1]
1005
+
957
1006
  player.special_ability.Tick()
958
- quest_manager.update_objective(f"Kill {GameState['Enemys killed']} creatures")
959
- for ___ in GameState['collected items']:
960
- if isinstance(___, item):
961
- quest_manager.update_objective(f"Colect {___.name}")
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}")
962
1011
 
963
1012
 
964
1013
 
@@ -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': '''
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neelthee-mansion
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: A text-based adventure game set in Neel-thee’s mansion.
5
5
  Home-page: https://github.com/Flameblade375/neelthee_mansion
6
6
  Author: Alexander.E.F
@@ -31,7 +31,8 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  ## Installation
33
33
 
34
- You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following command (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
34
+ You can install **Neel-thee's Mansion of Amnesia** using `pip` from the Python Package Index (PyPI). Run the following commands. You need wheel installed before you can install **Neel-thee's Mansion of Amnesia**. (worning! make sure you are using command line and even then sometimes it doesn't work. Please use Visual Studio Code or have turned off colour coding or it will brake):
35
35
 
36
36
  ```bash
37
+ pip install wheel
37
38
  pip install --no-cache-dir neelthee_mansion
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neelthee_mansion',
5
- version='2.4.0',
5
+ version='2.4.2',
6
6
  packages=find_packages(), # Automatically finds all packages and modules
7
7
  install_requires=[
8
8
  'wheel', 'psutil', 'playsound', 'requests', 'keyboard', 'pandas', 'validators', 'dicttoxml', 'pytz',