neelthee-mansion 2.4.4__tar.gz → 3.1.0__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.4 → neelthee_mansion-3.1.0}/PKG-INFO +1 -1
  2. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/Mansion_of_Amnesia.py +29 -7
  3. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/Rooms.py +0 -8
  4. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/creatures.py +1 -1
  5. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/utils.py +16 -2
  6. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/PKG-INFO +1 -1
  7. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/setup.py +1 -1
  8. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/README.md +0 -0
  9. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/Quests.py +0 -0
  10. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/__init__.py +0 -0
  11. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/__main__.py +0 -0
  12. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/all_game_utils.py +0 -0
  13. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion/items.py +0 -0
  14. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/SOURCES.txt +0 -0
  15. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/dependency_links.txt +0 -0
  16. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/entry_points.txt +0 -0
  17. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/requires.txt +0 -0
  18. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/neelthee_mansion.egg-info/top_level.txt +0 -0
  19. {neelthee_mansion-2.4.4 → neelthee_mansion-3.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neelthee_mansion
3
- Version: 2.4.4
3
+ Version: 3.1.0
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
@@ -403,7 +403,7 @@ def battle(player: PC, good_guys: list, bad_guys: list, last_room):
403
403
  while player.hp > 0 and any(monster.hp > 0 for monster in bad_guys):
404
404
  if ask_for_consent("Do you want to run away"):
405
405
  Move(last_room)
406
- return None, bad_guys
406
+ return good_guys, bad_guys
407
407
 
408
408
  # Player and good guys' turn
409
409
  for ally in [player] + good_guys:
@@ -411,7 +411,7 @@ def battle(player: PC, good_guys: list, bad_guys: list, last_room):
411
411
  handle_victory(player, bad_guys)
412
412
  return good_guys, None
413
413
 
414
- target = select_target(bad_guys)
414
+ target = select_target(ally, bad_guys)
415
415
  player_turn(ally, target)
416
416
 
417
417
  # Bad guys' turn
@@ -548,20 +548,42 @@ def use_special_ability(player: PC, monster: creature):
548
548
  type_text("Your special ability is not ready yet.", colorTrue=color_coding)
549
549
 
550
550
 
551
- def select_target(targets: list):
551
+ def select_target(chooser, targets: list):
552
552
  """
553
553
  Select a target from a list of characters.
554
554
 
555
555
  Args:
556
+ chooser: The entity (e.g., player or AI) selecting the target.
556
557
  targets (list): List of characters to select from.
557
558
 
558
559
  Returns:
559
560
  The selected target.
560
561
  """
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
562
+ if chooser == player:
563
+ valid_targets = []
564
+ type_text("Who do you want to attack? The options:")
565
+ # Enumerate through the targets to get both the index and the enemy.
566
+ for index, enemy in enumerate(targets):
567
+ if enemy.hp > 0:
568
+ type_text(f"{index + 1}: {enemy.name} ({enemy.hp} HP)")
569
+ valid_targets.append(index)
570
+
571
+ # Prompt the player to select a target
572
+ while True:
573
+ try:
574
+ choice = int(input("Enter the number of the target: ")) - 1
575
+ if choice in valid_targets:
576
+ return targets[choice]
577
+ else:
578
+ type_text("Invalid choice. Please select a valid target.")
579
+ except ValueError:
580
+ type_text("Invalid input. Please enter a number.")
581
+ else:
582
+ # AI or other logic for non-player chooser
583
+ for target in targets:
584
+ if target.hp > 0:
585
+ return target
586
+
565
587
 
566
588
 
567
589
  def command():
@@ -160,14 +160,6 @@ 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
- ),
171
163
  ],
172
164
  '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.',
173
165
  'map': '''
@@ -229,7 +229,7 @@ class base_ability:
229
229
 
230
230
  def Tick(self):
231
231
  self.current_cooldown += 1
232
- self.check_cooldown
232
+ self.check_cooldown()
233
233
 
234
234
  def check_cooldown(self):
235
235
  if self.current_cooldown >= self.cooldown_time:
@@ -18,6 +18,8 @@ try:
18
18
  import inspect
19
19
  import threading
20
20
  import json
21
+ import ast
22
+ import builtins
21
23
  import requests
22
24
  import keyboard
23
25
  import pandas as pd
@@ -234,10 +236,22 @@ def clamp(value, min = 0, max = 0):
234
236
  return value
235
237
 
236
238
  def is_executable(code_str):
239
+ code_str = code_str.strip()
240
+ if not code_str: # Check for empty or whitespace-only string
241
+ return False
237
242
  try:
238
- compile(code_str, '<string>')
243
+ # Parse the code to ensure it is syntactically correct
244
+ tree = ast.parse(code_str, mode='exec')
245
+
246
+ # Walk through the AST to find undefined names
247
+ for node in ast.walk(tree):
248
+ if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load):
249
+ # Check if the name is a built-in, defined locally in code, or globally available
250
+ if node.id not in dir(builtins) and node.id not in globals() and node.id not in locals():
251
+ return False # Name is not defined
252
+
239
253
  return True
240
- except SyntaxError:
254
+ except (SyntaxError, TypeError):
241
255
  return False
242
256
 
243
257
  def play_sound(sound_file):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neelthee-mansion
3
- Version: 2.4.4
3
+ Version: 3.1.0
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
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neelthee_mansion',
5
- version='2.4.4',
5
+ version='3.1.0',
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',