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,388 @@
|
|
1
|
+
try:
|
2
|
+
# Importing everything with wildcards
|
3
|
+
from random import *
|
4
|
+
from sys import *
|
5
|
+
from time import *
|
6
|
+
from datetime import *
|
7
|
+
from pickle import *
|
8
|
+
from string import *
|
9
|
+
from socket import *
|
10
|
+
from re import *
|
11
|
+
from platform import *
|
12
|
+
from psutil import *
|
13
|
+
from playsound import *
|
14
|
+
|
15
|
+
|
16
|
+
# Importing the whole module
|
17
|
+
import pickle as pk
|
18
|
+
import inspect
|
19
|
+
import threading
|
20
|
+
import json
|
21
|
+
import requests
|
22
|
+
import keyboard
|
23
|
+
import pandas as pd
|
24
|
+
except ImportError as e:
|
25
|
+
print(f"ImportError: {e}")
|
26
|
+
except Exception as e:
|
27
|
+
print(f"Unexpected error: {e}")
|
28
|
+
|
29
|
+
"""
|
30
|
+
This module, named 'utils', provides a collection of utility functions and classes to streamline common programming tasks and enhance code readability. It includes functionalities for system
|
31
|
+
interaction, text formatting, file operations, internet connectivity checks, logging, and more.
|
32
|
+
|
33
|
+
The module imports various standard and third-party libraries to access diverse functionalities, such as keyboard interactions, random number generation, date and time manipulation, HTTP
|
34
|
+
requests, and audio playback.
|
35
|
+
|
36
|
+
Key components include:
|
37
|
+
- Utility functions for tasks like executing Python code from strings, playing sound files, truncating text, downloading files from URLs, checking internet connectivity, generating unique
|
38
|
+
identifiers, and formatting dates.
|
39
|
+
- Utility classes for managing text formatting, converting input strings to boolean values, and logging messages with timestamps.
|
40
|
+
- A message log class for handling and persisting log data to files.
|
41
|
+
- A decorator to log function calls with timestamps.
|
42
|
+
|
43
|
+
These utilities aim to simplify development processes, promote code reuse, and improve the efficiency of Python applications.
|
44
|
+
"""
|
45
|
+
|
46
|
+
def perform_action_on_matches(input_list, target, action):
|
47
|
+
"""
|
48
|
+
Perform an action on all items in the list that are the same as the target.
|
49
|
+
|
50
|
+
:param input_list: List of items
|
51
|
+
:param target: The target item to match
|
52
|
+
:param action: A function that defines the action to perform on matched items
|
53
|
+
:return: The updated list
|
54
|
+
"""
|
55
|
+
matches = get_all_matches(input_list, target)
|
56
|
+
for i in range(len(input_list)):
|
57
|
+
if input_list[i] in matches:
|
58
|
+
input_list[i] = action(input_list[i])
|
59
|
+
return input_list
|
60
|
+
|
61
|
+
def get_all_matches(input_list, target):
|
62
|
+
"""
|
63
|
+
Return a list of all items in the list that are the same as the target.
|
64
|
+
|
65
|
+
:param input_list: List of items
|
66
|
+
:param target: The target item to match
|
67
|
+
:return: List of matched items
|
68
|
+
"""
|
69
|
+
return [item for item in input_list if item == target]
|
70
|
+
|
71
|
+
def last_index(lst):
|
72
|
+
if isinstance(lst, list):
|
73
|
+
if lst:
|
74
|
+
return len(lst) - 1
|
75
|
+
return None
|
76
|
+
|
77
|
+
def has_named_arg(func, arg_name):
|
78
|
+
"""
|
79
|
+
Check if the function 'func' has an argument named 'arg_name'.
|
80
|
+
|
81
|
+
:param func: Function to inspect
|
82
|
+
:param arg_name: Name of the argument to check
|
83
|
+
:return: True if the argument exists, False otherwise
|
84
|
+
"""
|
85
|
+
signature = inspect.signature(func)
|
86
|
+
return arg_name in signature.parameters
|
87
|
+
|
88
|
+
def get_random_string(length=10):
|
89
|
+
return ''.join(choice(ascii_letters + digits) for _ in range(length))
|
90
|
+
|
91
|
+
def retry_on_exception(func, retries=3):
|
92
|
+
for _ in range(retries):
|
93
|
+
try:
|
94
|
+
return func()
|
95
|
+
except Exception as e:
|
96
|
+
print(f"Retry due to: {e}")
|
97
|
+
print("Max retries exceeded")
|
98
|
+
|
99
|
+
def measure_execution_time(func):
|
100
|
+
start_time = time()
|
101
|
+
result = func()
|
102
|
+
end_time = time()
|
103
|
+
print(f"Execution time: {end_time - start_time} seconds")
|
104
|
+
return result
|
105
|
+
|
106
|
+
def int_to_binary(n):
|
107
|
+
return bin(n)[2:]
|
108
|
+
|
109
|
+
def binary_to_int(b):
|
110
|
+
return int(b, 2)
|
111
|
+
|
112
|
+
def str_to_base64(s):
|
113
|
+
import base64
|
114
|
+
return base64.b64encode(s.encode()).decode()
|
115
|
+
|
116
|
+
def base64_to_str(b64):
|
117
|
+
import base64
|
118
|
+
return base64.b64decode(b64.encode()).decode()
|
119
|
+
|
120
|
+
def get_memory_usage():
|
121
|
+
memory_info = virtual_memory()
|
122
|
+
return memory_info.percent
|
123
|
+
|
124
|
+
def get_os_info():
|
125
|
+
return system(), release()
|
126
|
+
|
127
|
+
def get_process_list():
|
128
|
+
return [(p.pid, p.info['name']) for p in process_iter(['name'])]
|
129
|
+
|
130
|
+
def get_ip_address():
|
131
|
+
return gethostbyname(gethostname())
|
132
|
+
|
133
|
+
def download_content(url):
|
134
|
+
response = requests.get(url)
|
135
|
+
if response.status_code == 200:
|
136
|
+
return response.content
|
137
|
+
else:
|
138
|
+
return None
|
139
|
+
|
140
|
+
def get_host_name():
|
141
|
+
return gethostname()
|
142
|
+
|
143
|
+
def reverse_string(s):
|
144
|
+
return s[::-1]
|
145
|
+
|
146
|
+
def is_palindrome(s):
|
147
|
+
cleaned = ''.join(c.lower() for c in s if c.isalnum())
|
148
|
+
return cleaned == reverse_string(cleaned)
|
149
|
+
|
150
|
+
def add_days(date, days):
|
151
|
+
return date + timedelta(days=days)
|
152
|
+
|
153
|
+
def get_days_between_dates(date1, date2):
|
154
|
+
delta = date2 - date1
|
155
|
+
return delta.days
|
156
|
+
|
157
|
+
def get_weekday(date):
|
158
|
+
return date.strftime("%A")
|
159
|
+
|
160
|
+
def word_count(s):
|
161
|
+
from collections import Counter
|
162
|
+
words = s.split()
|
163
|
+
return Counter(words)
|
164
|
+
|
165
|
+
def get_cpu_usage():
|
166
|
+
return cpu_percent(interval=1)
|
167
|
+
|
168
|
+
def get_disk_space():
|
169
|
+
usage = disk_usage('/')
|
170
|
+
return usage.free / (1024 ** 3) # Free space in GB
|
171
|
+
|
172
|
+
def get_system_uptime():
|
173
|
+
return time() - boot_time()
|
174
|
+
|
175
|
+
def is_valid_email(email):
|
176
|
+
pattern = r'^[\w\.-]+@[\w\.-]+\.\w+$'
|
177
|
+
return match(pattern, email) is not None
|
178
|
+
|
179
|
+
def is_valid_url(url):
|
180
|
+
import validators
|
181
|
+
return validators.url(url)
|
182
|
+
|
183
|
+
def is_valid_ip(ip):
|
184
|
+
import ipaddress
|
185
|
+
try:
|
186
|
+
ipaddress.ip_address(ip)
|
187
|
+
return True
|
188
|
+
except ValueError:
|
189
|
+
return False
|
190
|
+
|
191
|
+
def celsius_fahrenheit_conversion(Temp, IsCelsius = True):
|
192
|
+
if IsCelsius:
|
193
|
+
return (Temp * 9/5) + 32
|
194
|
+
else:
|
195
|
+
return 5 / 9*(Temp - 32)
|
196
|
+
|
197
|
+
def json_to_xml(json_data):
|
198
|
+
import json
|
199
|
+
import dicttoxml
|
200
|
+
return dicttoxml.dicttoxml(json.loads(json_data))
|
201
|
+
|
202
|
+
def flatten_list(nested_list):
|
203
|
+
import itertools
|
204
|
+
return list(itertools.chain(*nested_list))
|
205
|
+
|
206
|
+
def merge_dicts(*dicts):
|
207
|
+
result = {}
|
208
|
+
for d in dicts:
|
209
|
+
result.update(d)
|
210
|
+
return result
|
211
|
+
|
212
|
+
def shuffle_list(lst):
|
213
|
+
import random
|
214
|
+
shuffle(lst)
|
215
|
+
return lst
|
216
|
+
|
217
|
+
def date_difference(date1, date2):
|
218
|
+
delta = date2 - date1
|
219
|
+
return delta.days
|
220
|
+
|
221
|
+
def is_leap_year(year):
|
222
|
+
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
|
223
|
+
|
224
|
+
def get_current_time_in_timezone(timezone_str):
|
225
|
+
import pytz
|
226
|
+
tz = pytz.timezone(timezone_str)
|
227
|
+
return datetime.now(tz)
|
228
|
+
|
229
|
+
def clamp(value, min = 0, max = 0):
|
230
|
+
if value < min:
|
231
|
+
value = min
|
232
|
+
if value > max:
|
233
|
+
value = max
|
234
|
+
return value
|
235
|
+
|
236
|
+
def is_executable(code_str):
|
237
|
+
try:
|
238
|
+
compile(code_str, '<string>')
|
239
|
+
return True
|
240
|
+
except SyntaxError:
|
241
|
+
return False
|
242
|
+
|
243
|
+
def play_sound(sound_file):
|
244
|
+
playsound(sound_file)
|
245
|
+
|
246
|
+
def truncate_text(text: str, max_length: int = 234):
|
247
|
+
return text[:max_length] + '...' if len(text) > max_length else text
|
248
|
+
|
249
|
+
def download_file(url, filename):
|
250
|
+
response = requests.get(url)
|
251
|
+
if response.status_code == 200:
|
252
|
+
with open(filename, 'wb') as file:
|
253
|
+
file.write(response.content)
|
254
|
+
|
255
|
+
def check_internet_connection():
|
256
|
+
try:
|
257
|
+
create_connection(("www.google.com", 80))
|
258
|
+
return True
|
259
|
+
except OSError:
|
260
|
+
return False
|
261
|
+
|
262
|
+
def get_current_timestamp():
|
263
|
+
return datetime.now().timestamp()
|
264
|
+
|
265
|
+
def format_date(date: datetime):
|
266
|
+
return date.strftime("%Y-%m-%d %H:%M:%S")
|
267
|
+
|
268
|
+
def delay(seconds):
|
269
|
+
sleep(seconds)
|
270
|
+
|
271
|
+
# All classes:
|
272
|
+
class TextEdits:
|
273
|
+
# Text colors
|
274
|
+
BLACK = '\033[30m' # Black
|
275
|
+
RED = '\033[31m' # Red
|
276
|
+
GREEN = '\033[32m' # Green
|
277
|
+
YELLOW = '\033[33m' # Yellow
|
278
|
+
BLUE = '\033[34m' # Blue
|
279
|
+
MAGENTA = '\033[35m' # Magenta
|
280
|
+
CYAN = '\033[36m' # Cyan
|
281
|
+
WHITE = '\033[37m' # White
|
282
|
+
|
283
|
+
# Custom colors (adjusted for more contrast)
|
284
|
+
PINK = '\033[38;5;205m' # Brighter Pink (ANSI 256-color code)
|
285
|
+
PURPLE = '\033[38;5;53m' # Darker Purple (ANSI 256-color code)
|
286
|
+
ORANGE = '\033[38;5;208m' # Orange (ANSI 256-color code)
|
287
|
+
BROWN = '\033[38;5;94m' # Brown (ANSI 256-color code)
|
288
|
+
|
289
|
+
# Background colors
|
290
|
+
BLACK_BG = '\033[40m' # Black background
|
291
|
+
RED_BG = '\033[41m' # Red background
|
292
|
+
GREEN_BG = '\033[42m' # Green background
|
293
|
+
YELLOW_BG = '\033[43m' # Yellow background
|
294
|
+
BLUE_BG = '\033[44m' # Blue background
|
295
|
+
MAGENTA_BG = '\033[45m' # Magenta background
|
296
|
+
CYAN_BG = '\033[46m' # Cyan background
|
297
|
+
WHITE_BG = '\033[47m' # White background
|
298
|
+
|
299
|
+
# Text styles
|
300
|
+
BOLD = '\033[1m' # Bold text
|
301
|
+
UNDERLINE = '\033[4m' # Underlined text
|
302
|
+
BLINK = '\033[5m' # Blinking text, nonworking
|
303
|
+
REVERSE = '\033[7m' # Reversed (invert the foreground and background colors)
|
304
|
+
HIDDEN = '\033[8m' # Hidden (invisible) text
|
305
|
+
LINETHROUGH = '\033[9m' # Strikethrough (linethrough) text
|
306
|
+
ITALIC = '\033[3m'
|
307
|
+
|
308
|
+
# Reset all formatting
|
309
|
+
RESET = '\033[0m'
|
310
|
+
|
311
|
+
class Y_N:
|
312
|
+
def __init__(self, Value: str) -> None:
|
313
|
+
Value = Value.lower()
|
314
|
+
if Value == 'y':
|
315
|
+
Value = True
|
316
|
+
elif Value == 'n':
|
317
|
+
Value = False
|
318
|
+
else:
|
319
|
+
raise ValueError("That wasn't Y or N")
|
320
|
+
self.value = Value
|
321
|
+
|
322
|
+
def all_same_value(lst, value):
|
323
|
+
return all(x == value for x in lst)
|
324
|
+
|
325
|
+
def generate_id(start_str: str = "ObjectName_ObjectDetals", length: int = 32):
|
326
|
+
characters = ascii_letters + digits
|
327
|
+
random_part = ''.join(choice(characters) for _ in range(length - len(start_str)))
|
328
|
+
return start_str + "_" + random_part
|
329
|
+
|
330
|
+
def type_text(text: str, newline: bool = True, delay: float = 0.075, colorTrue: bool = True):
|
331
|
+
"""
|
332
|
+
Function to type text with optional color formatting.
|
333
|
+
|
334
|
+
Arguments:
|
335
|
+
text -- the text to be typed out
|
336
|
+
newline -- whether to print a newline at the end (default: True)
|
337
|
+
delay -- delay between each character in seconds (default: 0.075)
|
338
|
+
"""
|
339
|
+
color_start = '%*'
|
340
|
+
color_end = '*%'
|
341
|
+
|
342
|
+
key_pressed = False
|
343
|
+
|
344
|
+
def on_key_event(e):
|
345
|
+
nonlocal key_pressed
|
346
|
+
key_pressed = True
|
347
|
+
|
348
|
+
keyboard.hook(on_key_event)
|
349
|
+
|
350
|
+
i = 0
|
351
|
+
while i < len(text):
|
352
|
+
if key_pressed:
|
353
|
+
delay = 0
|
354
|
+
|
355
|
+
if text[i:i+len(color_start)] == color_start:
|
356
|
+
color_end_index = text.find(color_end, i)
|
357
|
+
if color_end_index != -1:
|
358
|
+
color_code = text[i+len(color_start):color_end_index]
|
359
|
+
color = getattr(TextEdits, color_code, TextEdits.RESET)
|
360
|
+
if colorTrue:
|
361
|
+
stdout.write(color)
|
362
|
+
i = color_end_index + len(color_end)
|
363
|
+
continue # Skip to the next iteration
|
364
|
+
|
365
|
+
stdout.write(text[i])
|
366
|
+
i += 1
|
367
|
+
stdout.flush()
|
368
|
+
sleep(delay)
|
369
|
+
|
370
|
+
stdout.write(TextEdits.RESET) # Reset color
|
371
|
+
stdout.flush()
|
372
|
+
if newline:
|
373
|
+
print()
|
374
|
+
|
375
|
+
keyboard.unhook(on_key_event)
|
376
|
+
|
377
|
+
def rounding(x: int, base: int = 5):
|
378
|
+
return int(base * round(x/base))
|
379
|
+
|
380
|
+
def loop_til_valid_input(input_text: str, bad_text: str, Class: classmethod, delay: int = 0.075, input_method: str = '>'):
|
381
|
+
while True:
|
382
|
+
try:
|
383
|
+
type_text(input_text, delay=delay)
|
384
|
+
value = Class(input(input_method))
|
385
|
+
break
|
386
|
+
except ValueError:
|
387
|
+
type_text(bad_text)
|
388
|
+
return value
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: neelthee-mansion
|
3
|
+
Version: 0.3.0.0
|
4
|
+
Summary: A text-based adventure game set in Neel-thee’s mansion.
|
5
|
+
Home-page: https://github.com/Flameblade375/neelthee_mansion
|
6
|
+
Author: Alexander.E.F
|
7
|
+
Author-email: alexander@xandy.rocks
|
8
|
+
License: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: Programming Language :: Python :: 3.6
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
17
|
+
Classifier: Operating System :: OS Independent
|
18
|
+
Requires-Python: >=3.6
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
Requires-Dist: wheel
|
21
|
+
Requires-Dist: psutil
|
22
|
+
Requires-Dist: playsound
|
23
|
+
Requires-Dist: requests
|
24
|
+
Requires-Dist: keyboard
|
25
|
+
Requires-Dist: pandas
|
26
|
+
Requires-Dist: validators
|
27
|
+
Requires-Dist: dicttoxml
|
28
|
+
Requires-Dist: pytz
|
29
|
+
|
30
|
+
# Neel-thee's Mansion of Amnesia
|
31
|
+
|
32
|
+
**Neel-thee's Mansion of Amnesia** is a text-based adventure game where players explore a mysterious mansion, interact with objects and creatures, and strive to escape while uncovering their lost identity.
|
33
|
+
|
34
|
+
## Features
|
35
|
+
|
36
|
+
- Explore a richly detailed mansion with various rooms and interactable objects.
|
37
|
+
- Encounter and interact with different creatures.
|
38
|
+
- Collect and use items throughout the game.
|
39
|
+
- Navigate through quests that drive the narrative forward.
|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
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):
|
44
|
+
|
45
|
+
```bash
|
46
|
+
pip install wheel
|
47
|
+
pip install --no-cache-dir neelthee_mansion
|
@@ -0,0 +1,14 @@
|
|
1
|
+
neelthee_mansion/Mansion_of_Amnesia.py,sha256=O0z408O70MMEjCGcE6FDuSutHJC_GFmmjCqjpfpQu88,41715
|
2
|
+
neelthee_mansion/Quests.py,sha256=q6VzR3mt9AYe29ACWZuf-suz4yOKrL946aJ493eQRS0,2611
|
3
|
+
neelthee_mansion/Rooms.py,sha256=G4UBk2QEpr17PoUBnMLTCffDgKPFE1S2GyKB5f11KNI,82780
|
4
|
+
neelthee_mansion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
neelthee_mansion/__main__.py,sha256=OIAWZ04le70DyjtR4hlmK9csHej7EHxeUrMoNnM-Vjc,95
|
6
|
+
neelthee_mansion/all_game_utils.py,sha256=Xfty9uXiYAfmA6iVzJurq852ZBPn7a4gQUcUcaV9yEU,341
|
7
|
+
neelthee_mansion/creatures.py,sha256=_OhULTc_wvrwn49bMsoq10x3j2TPs11cFFJhyd68MUc,14824
|
8
|
+
neelthee_mansion/items.py,sha256=uzZ9fq6_YK3oQ2lkAsyidWwM6trasVsjdQi2V0JTPfw,2097
|
9
|
+
neelthee_mansion/utils.py,sha256=7JkgDw4Tq3EG11DqX05tjisoGxE0L_Sd7VkqkU8x-jQ,11486
|
10
|
+
neelthee_mansion-0.3.0.0.dist-info/METADATA,sha256=mltHuJ_8gOVh9lGKZLRaVcRt89xh9fE_Ml9oNW0i8Qw,1993
|
11
|
+
neelthee_mansion-0.3.0.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
12
|
+
neelthee_mansion-0.3.0.0.dist-info/entry_points.txt,sha256=j5ScTTyIidFhmT3F6hcX9pnlom4cJdDmfe26BmM6Igo,56
|
13
|
+
neelthee_mansion-0.3.0.0.dist-info/top_level.txt,sha256=woQImQewylhly5Rb24HwPEGMxPY6do_PaUwGd5BNLOM,17
|
14
|
+
neelthee_mansion-0.3.0.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
neelthee_mansion
|