neelthee-mansion 3.19.13__py3-none-any.whl → 3.19.15__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.
@@ -1,13 +1,14 @@
1
1
  from .utils import *
2
2
  from re import *
3
3
 
4
+
4
5
  def ask_for_consent(text: str) -> bool:
5
6
  while True:
6
7
  type_text(f"{text}? Y/N")
7
8
  anser = str(input(">")).lower().strip()
8
- if anser == 'y':
9
+ if anser == "y":
9
10
  return True
10
- elif anser == 'n':
11
+ elif anser == "n":
11
12
  return False
12
13
  else:
13
14
  type_text("That wasn't Y or N")
@@ -9,9 +9,10 @@ ValidActions = [
9
9
  "special",
10
10
  ]
11
11
 
12
+
12
13
  class Height:
13
14
  def __init__(self, height_str="0ft 0"):
14
- feet, inches = map(float, height_str.split('ft '))
15
+ feet, inches = map(float, height_str.split("ft "))
15
16
  if inches >= 12:
16
17
  raise ValueError("Inches must be less than 12.")
17
18
  try:
@@ -50,7 +51,9 @@ class base_character:
50
51
  self.hp = self.hp - damage_taken
51
52
  if self.hp < 0:
52
53
  self.hp = 0
53
- type_text(f"{string_beginning}{self.name}%*RESET*% takes {damage_taken} damage and has {self.hp} HP left!")
54
+ type_text(
55
+ f"{string_beginning}{self.name}%*RESET*% takes {damage_taken} damage and has {self.hp} HP left!"
56
+ )
54
57
 
55
58
 
56
59
  class creature_type:
@@ -68,7 +71,7 @@ class creature_type:
68
71
  """
69
72
  self.type = type
70
73
  self.subtype = subtype
71
-
74
+
72
75
  def check_type(self):
73
76
  """
74
77
  Returns the type and subtype of the creature.
@@ -79,7 +82,7 @@ class creature_type:
79
82
  if self.subtype:
80
83
  return self.type, self.subtype
81
84
  return self.type
82
-
85
+
83
86
  def __str__(self) -> str:
84
87
  """
85
88
  Returns a string representation of the creature type.
@@ -91,6 +94,7 @@ class creature_type:
91
94
  return f"{self.type}, {self.subtype}"
92
95
  return f"{self.type}"
93
96
 
97
+
94
98
  class creature(base_character):
95
99
  """
96
100
  A class representing a creature in the game.
@@ -106,7 +110,18 @@ class creature(base_character):
106
110
  crit_chance (float): The chance of the creature landing a critical hit.
107
111
  """
108
112
 
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 = ""):
113
+ def __init__(
114
+ self,
115
+ name: str,
116
+ hp: int,
117
+ atpw: int,
118
+ dropped_items: list[str] = [],
119
+ description: str = None,
120
+ flavor_text: str = None,
121
+ type: creature_type = creature_type("beast"),
122
+ crit_chance: float = 0.05,
123
+ frendly_text: str = "",
124
+ ):
110
125
  """
111
126
  Initializes a new creature instance.
112
127
 
@@ -126,30 +141,34 @@ class creature(base_character):
126
141
  self.difficulty = self.hp / 10 + self.atpw
127
142
  self.dropped_items = dropped_items
128
143
  self.xp = rounding(self.difficulty * 2 + len(self.dropped_items))
129
- self.description = description if description else f'A %*CYAN*%{self.name}%*RESET.'
130
- self.flavor_text = flavor_text if flavor_text else f'You see a %*CYAN*%{self.name}%*RESET*%!'
144
+ self.description = (
145
+ description if description else f"A %*CYAN*%{self.name}%*RESET."
146
+ )
147
+ self.flavor_text = (
148
+ flavor_text if flavor_text else f"You see a %*CYAN*%{self.name}%*RESET*%!"
149
+ )
131
150
  self.type = type
132
151
  self.crit_chance = crit_chance
133
152
  self.frendly = False
134
153
  self.frendly_text = frendly_text
135
-
154
+
136
155
  def type_text_flavor_text(self):
137
156
  """
138
157
  Prints the flavor text associated with encountering the creature.
139
158
  """
140
159
  type_text(self.flavor_text)
141
-
160
+
142
161
  def type_text_description(self):
143
162
  """
144
163
  Prints the description of the creature.
145
164
  """
146
165
  type_text(self.description)
147
166
  curent_holiday = get_holiday()
148
- if curent_holiday == 'christmas':
167
+ if curent_holiday == "christmas":
149
168
  type_text(f"The {self.name} also has a santa hat.")
150
- elif curent_holiday == 'easter':
169
+ elif curent_holiday == "easter":
151
170
  type_text(f"The {self.name} also has bunny ears.")
152
- elif curent_holiday == 'halloween':
171
+ elif curent_holiday == "halloween":
153
172
  if random < 0.2:
154
173
  type_text(f"The {self.name} also has a pumkin on it's head.")
155
174
 
@@ -163,7 +182,21 @@ class Guard(creature):
163
182
  patrol_route (list[str]): The list of rooms the guard patrols through.
164
183
  """
165
184
 
166
- 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('humanoid'), crit_chance: float = 0.05, current_room: str = None, patrol_route: list[str] = None, patrol_type: str = 'normal', frendly_text: str = ""):
185
+ def __init__(
186
+ self,
187
+ name: str,
188
+ hp: int,
189
+ atpw: int,
190
+ dropped_items: list[str] = [],
191
+ description: str = None,
192
+ flavor_text: str = None,
193
+ type: creature_type = creature_type("humanoid"),
194
+ crit_chance: float = 0.05,
195
+ current_room: str = None,
196
+ patrol_route: list[str] = None,
197
+ patrol_type: str = "normal",
198
+ frendly_text: str = "",
199
+ ):
167
200
  """
168
201
  Initializes a new guard instance.
169
202
 
@@ -180,7 +213,17 @@ class Guard(creature):
180
213
  patrol_route (list[str], optional): The list of rooms the guard patrols through. Defaults to None.
181
214
  patrol_type (str): The type of patrol the guard is doing. Defaults to normal.
182
215
  """
183
- super().__init__(name, hp, atpw, dropped_items, description, flavor_text, type, crit_chance, frendly_text)
216
+ super().__init__(
217
+ name,
218
+ hp,
219
+ atpw,
220
+ dropped_items,
221
+ description,
222
+ flavor_text,
223
+ type,
224
+ crit_chance,
225
+ frendly_text,
226
+ )
184
227
  self.current_room = current_room
185
228
  self.patrol_route = patrol_route or []
186
229
  self.patrol_type = patrol_type
@@ -190,21 +233,21 @@ class Guard(creature):
190
233
  Moves the guard depending on his patrol type.
191
234
  """
192
235
 
193
- if self.patrol_type == 'normal':
236
+ if self.patrol_type == "normal":
194
237
  if self.patrol_route:
195
238
  current_index = self.patrol_route.index(self.current_room)
196
239
  next_index = (current_index + 1) % len(self.patrol_route)
197
240
  self.current_room = self.patrol_route[next_index]
198
- elif self.patrol_type == 'random':
241
+ elif self.patrol_type == "random":
199
242
  rooms = []
200
- for direction, room in ROOMS[self.current_room]['directions'].items():
243
+ for direction, room in ROOMS[self.current_room]["directions"].items():
201
244
  rooms.append(room)
202
- if hasattr(room, 'GetRoom'):
245
+ if hasattr(room, "GetRoom"):
203
246
  self.current_room = choice(rooms).GetRoom(self.current_room)
204
247
  return
205
248
  self.current_room = choice(rooms)
206
- elif self.patrol_type == 'follow':
207
- for direction, room in ROOMS[self.current_room]['directions'].items():
249
+ elif self.patrol_type == "follow":
250
+ for direction, room in ROOMS[self.current_room]["directions"].items():
208
251
  if room.GetRoom(self.current_room) == player.CURRENTROOM:
209
252
  self.current_room = room.GetRoom(self.current_room)
210
253
  return
@@ -220,70 +263,75 @@ class Guard(creature):
220
263
  bool: True if the player is detected, False otherwise.
221
264
  """
222
265
  if self.current_room == player_room and not self.frendly:
223
- type_text(f"You have been caught by {self.name} in the {self.current_room}!")
266
+ type_text(
267
+ f"You have been caught by {self.name} in the {self.current_room}!"
268
+ )
224
269
  return True
225
270
  elif self.current_room == player_room and self.frendly:
226
271
  if random() <= 0.015:
227
272
  type_text(self.frendly_text)
228
273
  return False
229
274
 
275
+
230
276
  class base_ability:
231
277
  def __init__(self, name, cooldown_time) -> None:
232
278
  self.ready = True
233
279
  self.name = name
234
280
  self.cooldown_time = cooldown_time
235
281
  self.current_cooldown = 0
236
-
282
+
237
283
  def activate(self, target: creature, damage: int = 5):
238
284
  self.ready = False
239
285
  self.current_cooldown = 0
240
286
  print(f"Ability {self.name} will be ready after {self.cooldown_time} commands.")
241
-
287
+
242
288
  def Tick(self):
243
289
  self.current_cooldown += 1
244
290
  self.check_cooldown()
245
-
291
+
246
292
  def check_cooldown(self):
247
293
  if self.current_cooldown >= self.cooldown_time and not self.ready:
248
294
  type_text(f"\nAbility {self.name} is ready to use again. ")
249
295
  self.ready = True
250
296
 
297
+
251
298
  class supercrit_ability(base_ability):
252
299
  def __init__(self) -> None:
253
300
  super().__init__("Super Crit", 5)
254
-
301
+
255
302
  def activate(self, target: base_character, damage: int = 5):
256
- target.take_damage(damage*5)
303
+ target.take_damage(damage * 5)
257
304
  super().activate(target, damage)
258
305
 
306
+
259
307
  class PC(base_character):
260
308
 
261
309
  def __init__(
262
- self,
263
- Name: str,
264
- Age: int,
265
- Class: str,
266
- Level: int,
267
- Background: str,
268
- Height: Height,
269
- Weight: int,
270
- Notes: list = [],
271
- special_ability: base_ability = supercrit_ability(),
272
- NOTES: list = [],
273
- xp: int = None,
274
- inventory: inv = None,
275
- money: int = 0,
276
- weapons_atpws: list = [],
277
- backstory: str = "",
278
- CURRENTROOM: str = "",
279
- LASTROOM: str = None,
280
- Skills: list[str] = None
281
- ):
310
+ self,
311
+ Name: str,
312
+ Age: int,
313
+ Class: str,
314
+ Level: int,
315
+ Background: str,
316
+ Height: Height,
317
+ Weight: int,
318
+ Notes: list = [],
319
+ special_ability: base_ability = supercrit_ability(),
320
+ NOTES: list = [],
321
+ xp: int = None,
322
+ inventory: inv = None,
323
+ money: int = 0,
324
+ weapons_atpws: list = [],
325
+ backstory: str = "",
326
+ CURRENTROOM: str = "",
327
+ LASTROOM: str = None,
328
+ Skills: list[str] = None,
329
+ ):
282
330
  if not xp:
283
331
  if Level == 1:
284
332
  xp = 0
285
333
  else:
286
- xp = Level*25
334
+ xp = Level * 25
287
335
  if not LASTROOM:
288
336
  LASTROOM = CURRENTROOM
289
337
  self.name = Name
@@ -299,7 +347,9 @@ class PC(base_character):
299
347
  self.hp = self.maxhp
300
348
  self.atpw = rounding(self.Level * 1.5 + 3, 1)
301
349
  self.xp = xp
302
- self.inventory = inventory if inventory is not None else inv() # Initialize an inv if inventory is None
350
+ self.inventory = (
351
+ inventory if inventory is not None else inv()
352
+ ) # Initialize an inv if inventory is None
303
353
  self.money = money
304
354
  self.weapons_atpws = weapons_atpws
305
355
  self.crit_chance = 0.075
@@ -319,7 +369,7 @@ class PC(base_character):
319
369
  self.atpw = self.Level * 2 + 3 + self.weapons_atpws[weapon_index]
320
370
 
321
371
  def check_xp(self):
322
- self.level = rounding(self.xp/25, 1)
372
+ self.level = rounding(self.xp / 25, 1)
323
373
 
324
374
  def add_xp(self, xp_added: int = 5):
325
375
  self.xp += xp_added
@@ -335,7 +385,7 @@ class PC(base_character):
335
385
  self.inventory.append(item_to_add)
336
386
 
337
387
  # Check if the added item is a weapon and update player's weapon if needed
338
- if item_to_add.type == 'weapon':
388
+ if item_to_add.type == "weapon":
339
389
  self.get_change_weapon(item_to_add.value)
340
390
  else:
341
391
  # Print an error message if the item is not an instance of Item class
@@ -343,64 +393,66 @@ class PC(base_character):
343
393
  except Exception as e:
344
394
  # Print the full traceback if an exception occurs
345
395
  type_text(f"Error: {e}")
346
-
396
+
347
397
  def heal(self, value):
348
398
  self.hp = clamp(value, 0, self.maxhp)
349
399
 
400
+
350
401
  class NPC(PC):
351
402
  def __init__(
352
- self,
353
- Name: str,
354
- Age: int,
355
- Class: str,
356
- Level: int,
357
- Background: str,
358
- Height: Height,
359
- Weight: int,
360
- Notes: list = [],
361
- special_ability: base_ability = supercrit_ability(),
362
- NOTES: list = [],
363
- xp: int = None,
364
- inventory: inv = None,
365
- money: int = 0,
366
- weapons_atpws: list = [],
367
- npc_role: str = "generic", # New attribute for NPC role (e.g., merchant, enemy, etc.)
368
- aggressive: bool = False # New attribute to determine if NPC is aggressive
369
- ):
403
+ self,
404
+ Name: str,
405
+ Age: int,
406
+ Class: str,
407
+ Level: int,
408
+ Background: str,
409
+ Height: Height,
410
+ Weight: int,
411
+ Notes: list = [],
412
+ special_ability: base_ability = supercrit_ability(),
413
+ NOTES: list = [],
414
+ xp: int = None,
415
+ inventory: inv = None,
416
+ money: int = 0,
417
+ weapons_atpws: list = [],
418
+ npc_role: str = "generic", # New attribute for NPC role (e.g., merchant, enemy, etc.)
419
+ aggressive: bool = False, # New attribute to determine if NPC is aggressive
420
+ ):
370
421
  super().__init__(
371
- Name=Name,
372
- Age=Age,
373
- Class=Class,
374
- Level=Level,
375
- Background=Background,
376
- Height=Height,
377
- Weight=Weight,
378
- Notes=Notes,
422
+ Name=Name,
423
+ Age=Age,
424
+ Class=Class,
425
+ Level=Level,
426
+ Background=Background,
427
+ Height=Height,
428
+ Weight=Weight,
429
+ Notes=Notes,
379
430
  special_ability=special_ability,
380
- NOTES=NOTES,
381
- xp=xp,
382
- inventory=inventory,
383
- money=money,
384
- weapons_atpws=weapons_atpws
431
+ NOTES=NOTES,
432
+ xp=xp,
433
+ inventory=inventory,
434
+ money=money,
435
+ weapons_atpws=weapons_atpws,
385
436
  )
386
437
  self.npc_role = npc_role
387
438
  self.aggressive = aggressive
388
-
439
+
389
440
  def interact(self):
390
441
  if self.aggressive:
391
442
  return f"{self.name} looks hostile and prepares for a fight!"
392
443
  else:
393
444
  return f"{self.name} has nothing to say to you."
394
-
445
+
395
446
  def npc_info(self):
396
447
  return f"Name: {self.name}, Age: {self.Age}, Class: {self.Class}, Level: {self.Level}, Role: {self.npc_role}, Aggressive: {self.aggressive}"
397
448
 
449
+
398
450
  class PC_action:
399
451
  def __init__(self, value) -> None:
400
452
  if not value in ValidActions:
401
453
  raise ValueError
402
454
  self.value = value
403
-
455
+
404
456
  def __eq__(self, value: object) -> bool:
405
457
  if isinstance(value, PC_action):
406
458
  return self.value == value.value
neelthee_mansion/items.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from .utils import *
2
2
 
3
+
3
4
  class item:
4
5
 
5
6
  def __init__(self, name: str = "", type: str = "miscellaneous", value: int = 0):
@@ -8,46 +9,50 @@ class item:
8
9
  self.value = value
9
10
 
10
11
  def sell(self, seller) -> bool:
11
- if self.type.lower() == 'valuable':
12
+ if self.type.lower() == "valuable":
12
13
  seller.money += self.value
13
14
  return True
14
15
  else:
15
16
  return False
16
17
 
18
+
17
19
  class Lock:
18
20
  def __init__(self, key_code: str = None):
19
21
  self.key_code = key_code if key_code else get_random_string(10)
20
22
  self.is_locked = True
21
-
23
+
22
24
  def unlock(self, key, player):
23
25
  if not self.is_locked:
24
26
  do_lock = loop_til_valid_input(
25
27
  "The lock is not locked, do you want to lock it again? Y/N",
26
28
  "You didn't entor Y or N",
27
- Y_N
29
+ Y_N,
28
30
  ).value
29
31
  if do_lock:
30
32
  type_text("You relock the lock")
31
33
  return False
32
-
34
+
33
35
  elif key.GetKeyCode() == self.key_code:
34
36
  type_text("The lock clicks open!")
35
37
  self.is_locked = False
36
38
  if key.KeyDels:
37
39
  player.inventory.remove(key)
38
- type_text(f"The {key.name} was used and has been removed from your inventory.")
40
+ type_text(
41
+ f"The {key.name} was used and has been removed from your inventory."
42
+ )
39
43
  return True
40
-
44
+
41
45
  else:
42
46
  type_text("The lock holds fast!")
43
47
  return False
44
-
48
+
45
49
  def __str__(self) -> str:
46
50
  return self.key_code
47
51
 
52
+
48
53
  class Key(item):
49
- def __init__(self, name: str = '', KeyCode: str = None, KeyDels: bool = False):
50
- super().__init__(name, 'key', KeyCode if KeyCode else get_random_string(10))
54
+ def __init__(self, name: str = "", KeyCode: str = None, KeyDels: bool = False):
55
+ super().__init__(name, "key", KeyCode if KeyCode else get_random_string(10))
51
56
  self.KeyDels = KeyDels
52
57
  self.reveal_count = 0
53
58
  self.CurentRevealStr = "=" * len(self.value)
@@ -55,18 +60,21 @@ class Key(item):
55
60
  def GetKeyCode(self):
56
61
  return self.value
57
62
 
63
+
58
64
  class KeyRevealer:
59
65
  def __init__(self, max_reveals=2):
60
66
  self.max_reveals = max_reveals
61
-
67
+
62
68
  def reveal_key_code(self, obj: Key, mask_char="="):
63
69
  if hasattr(obj, "reveal_count"):
64
70
  if obj.reveal_count >= self.max_reveals:
65
71
  type_text(f"You can only reveal a Key Code {self.max_reveals} times.")
66
- type_text(f"Here is what you already know about this lock: {obj.CurentRevealStr}")
72
+ type_text(
73
+ f"Here is what you already know about this lock: {obj.CurentRevealStr}"
74
+ )
67
75
  return
68
76
 
69
- if not hasattr(obj, 'lock'):
77
+ if not hasattr(obj, "lock"):
70
78
  key_code = obj.value
71
79
  else:
72
80
  key_code = obj.lock.key_code
@@ -74,7 +82,9 @@ class KeyRevealer:
74
82
  one_third_length = len(key_code) // 3
75
83
 
76
84
  # Keep track of already revealed indices
77
- revealed_indices = {i for i, char in enumerate(obj.CurentRevealStr) if char != mask_char}
85
+ revealed_indices = {
86
+ i for i, char in enumerate(obj.CurentRevealStr) if char != mask_char
87
+ }
78
88
 
79
89
  # Get new indices to reveal
80
90
  new_indices = set(sample(range(len(key_code)), one_third_length))
@@ -89,10 +99,11 @@ class KeyRevealer:
89
99
  ]
90
100
 
91
101
  obj.reveal_count += 1
92
- obj.CurentRevealStr = ''.join(result)
102
+ obj.CurentRevealStr = "".join(result)
93
103
  type_text("".join(result))
94
104
  return True
95
105
 
106
+
96
107
  class ShopItem:
97
108
  def __init__(self, item: item, price: int):
98
109
  self.item = item
@@ -112,6 +123,7 @@ class ShopItem:
112
123
  else:
113
124
  return False
114
125
 
126
+
115
127
  class inv(list):
116
128
  def __contains__(self, item_name) -> bool:
117
129
  for item_ in self:
@@ -120,25 +132,25 @@ class inv(list):
120
132
  elif item_ == item_name:
121
133
  return True
122
134
  return False
123
-
135
+
124
136
  def index(self, value, start=0, end=None):
125
137
  if end is None:
126
138
  end = len(self)
127
-
139
+
128
140
  # Custom implementation of index method
129
141
  for i in range(start, end):
130
142
  if isinstance(self[i], item):
131
143
  if self[i].name == value:
132
144
  return i
133
145
  return None
134
-
146
+
135
147
  def remove(self, value):
136
148
  if isinstance(value, item):
137
149
  if value in self:
138
150
  del self[self.index(value.name)]
139
151
  return
140
152
  del self[self.index(value)]
141
-
153
+
142
154
  def keys(self) -> list[Key]:
143
155
  keys = []
144
156
  for key in self:
@@ -146,14 +158,19 @@ class inv(list):
146
158
  keys = keys + [key]
147
159
  return keys
148
160
 
161
+
149
162
  class container:
150
- def __init__(self, contents: list[item], secret: bool = False, KeyCode=None) -> None:
163
+ def __init__(
164
+ self, contents: list[item], secret: bool = False, KeyCode=None
165
+ ) -> None:
151
166
  self.contents = contents
152
167
  self.secret = secret
153
168
  self.lock = Lock(KeyCode) if KeyCode else None
154
169
  self.RevealCount = 0
155
- self.CurentRevealStr = "=" * len(self.lock.key_code) if isinstance(self.lock, Lock) else ""
156
-
170
+ self.CurentRevealStr = (
171
+ "=" * len(self.lock.key_code) if isinstance(self.lock, Lock) else ""
172
+ )
173
+
157
174
  def take_contents(self, geter=None):
158
175
  if isinstance(self.lock, Lock) and self.lock.is_locked:
159
176
  type_text("The container is locked and won't budge.")
@@ -166,9 +183,9 @@ class container:
166
183
  pass
167
184
  finally:
168
185
  self.contents = []
169
-
186
+
170
187
  def Unlock(self, key: Key, player):
171
188
  return self.lock.unlock(key, player)
172
-
189
+
173
190
  def __str__(self) -> str:
174
191
  return self.CurentRevealStr