absfuyu 3.2.0__py3-none-any.whl → 3.3.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.
Potentially problematic release.
This version of absfuyu might be problematic. Click here for more details.
- absfuyu/__init__.py +3 -10
- absfuyu/__main__.py +5 -250
- absfuyu/cli/__init__.py +51 -0
- absfuyu/cli/color.py +24 -0
- absfuyu/cli/config_group.py +56 -0
- absfuyu/cli/do_group.py +76 -0
- absfuyu/cli/game_group.py +109 -0
- absfuyu/config/__init__.py +55 -94
- absfuyu/config/config.json +0 -7
- absfuyu/core.py +5 -66
- absfuyu/everything.py +7 -9
- absfuyu/extensions/beautiful.py +30 -23
- absfuyu/extensions/dev/__init__.py +11 -8
- absfuyu/extensions/dev/password_hash.py +4 -2
- absfuyu/extensions/dev/passwordlib.py +7 -5
- absfuyu/extensions/dev/project_starter.py +4 -2
- absfuyu/extensions/dev/shutdownizer.py +148 -0
- absfuyu/extensions/extra/__init__.py +1 -2
- absfuyu/extensions/extra/data_analysis.py +110 -58
- absfuyu/fun/WGS.py +50 -26
- absfuyu/fun/__init__.py +6 -7
- absfuyu/fun/tarot.py +1 -1
- absfuyu/game/__init__.py +75 -81
- absfuyu/game/game_stat.py +36 -0
- absfuyu/game/sudoku.py +41 -48
- absfuyu/game/tictactoe.py +303 -548
- absfuyu/game/wordle.py +56 -47
- absfuyu/general/__init__.py +17 -7
- absfuyu/general/content.py +16 -15
- absfuyu/general/data_extension.py +282 -90
- absfuyu/general/generator.py +67 -67
- absfuyu/general/human.py +74 -78
- absfuyu/logger.py +94 -68
- absfuyu/pkg_data/__init__.py +29 -25
- absfuyu/py.typed +0 -0
- absfuyu/sort.py +61 -47
- absfuyu/tools/__init__.py +0 -1
- absfuyu/tools/converter.py +80 -62
- absfuyu/tools/keygen.py +62 -67
- absfuyu/tools/obfuscator.py +57 -53
- absfuyu/tools/stats.py +24 -24
- absfuyu/tools/web.py +10 -9
- absfuyu/util/__init__.py +38 -40
- absfuyu/util/api.py +53 -43
- absfuyu/util/json_method.py +25 -27
- absfuyu/util/lunar.py +20 -24
- absfuyu/util/path.py +362 -241
- absfuyu/util/performance.py +36 -98
- absfuyu/util/pkl.py +8 -8
- absfuyu/util/zipped.py +17 -19
- absfuyu/version.py +137 -148
- absfuyu-3.3.3.dist-info/METADATA +124 -0
- absfuyu-3.3.3.dist-info/RECORD +59 -0
- {absfuyu-3.2.0.dist-info → absfuyu-3.3.3.dist-info}/WHEEL +1 -2
- {absfuyu-3.2.0.dist-info → absfuyu-3.3.3.dist-info}/entry_points.txt +1 -0
- {absfuyu-3.2.0.dist-info → absfuyu-3.3.3.dist-info/licenses}/LICENSE +1 -1
- absfuyu/extensions/dev/pkglib.py +0 -98
- absfuyu/game/tictactoe2.py +0 -318
- absfuyu-3.2.0.dist-info/METADATA +0 -216
- absfuyu-3.2.0.dist-info/RECORD +0 -55
- absfuyu-3.2.0.dist-info/top_level.txt +0 -1
absfuyu/fun/WGS.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# flake8: noqa
|
|
1
2
|
"""
|
|
2
3
|
Absfuyu: WGS
|
|
3
4
|
------------
|
|
@@ -15,12 +16,9 @@ Usage:
|
|
|
15
16
|
>>> print(test.pixel_art())
|
|
16
17
|
"""
|
|
17
18
|
|
|
18
|
-
|
|
19
19
|
# Module level
|
|
20
20
|
###########################################################################
|
|
21
|
-
__all__ = [
|
|
22
|
-
"WGS"
|
|
23
|
-
]
|
|
21
|
+
__all__ = ["WGS"]
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
# Library
|
|
@@ -40,35 +38,61 @@ class WGS:
|
|
|
40
38
|
- This module is not affiliated with miHoYo/Hoyoverse.
|
|
41
39
|
- Genshin Impact, game content and materials are trademarks and copyrights of miHoYo/Hoyoverse.
|
|
42
40
|
"""
|
|
41
|
+
|
|
43
42
|
def __init__(self) -> None:
|
|
44
43
|
self._text_art_big = "ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLjo9KzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0qKioqKi4gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuPSojKisrCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtIyslKyA6LgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSMjJSsuCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4qIyUqLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IyMlPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IyMjOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArIyUrICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtIyMjLQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9KyAgICA9JSMjLiAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDojIyUrLi4tLT0tIDojIyo9KiMlJT0gICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMlJSUlIyUjIyUlJSUlJSMjIyUlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOj0lJUAlIyMjIyUjJSUlJSUlPS0tOiAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuJSo6JSUjJSUlIyMlJSUlJSUqPSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IyM9KysjJSMjKyolJSMlJSo6ICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDo9KiojIyMjJSMlIyUlJSUlJSUjKyAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC49KyoqIyUlJSMjIyUjIyUlJSUlJSsgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqJSMjIyUjIyMjQCMlIys9LSNAJSUjKz0tICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOisqIyVAJSUjIyUlJSMlIyUjKiouOislJSMjLiAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtKiMjJSVAJSUlJSUlIyUtLis9ICAgICA6Ky0tLiAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0qIyMlQEAlIyVAQCUjJUArIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4tIyUlJUAlJUBAIyUlIyouICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuPSMjJSUlJSUlJSUjJSU9LiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLSojJSUlJSUlQCUlJSMqLSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuOiolJSUlJSUlJSUlIyorLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiojJSUlJSUlJSUlIz06ICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4gLSMjIyMjIyUlJSUlIy0gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IyMjIyUjIyUlIz0qLiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOisjIyMjIyMlJSUqLS0uIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLSojIyMjJSMlJSUqLTouIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9KysqKioqIyMqKj0tLiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLSsqKiorKiojIyMqPTogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSsrKysqIyMrKiMqPS4gIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLjorKiojIyMjIyUjKj0tICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4gOisqIyMjIyMjIyMqPTogIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLiA9KyojKisjIyMjIystIAogICAgICAgICAgICAgICAgICAgICAgICAuIC49KiojKi0qIyMjKj0tICAKICAgICAgICAgICAgICAgICAgICAgICAgOisqKiMrPSojIyMqPToKICAgICAgICAgICAgICAgICAgICAgICAgLSsqKiotPSoqKyorPS4KICAgICAgICAgICAgICAgICAgICAgICAgLj0rKiorLSojKioqKy0uICAKICAgICAgICAgICAgICAgICAgICAuOi09KyoqLT0jIyoqKz06IAogICAgICAgICAgICAgICAgICAgIDotPSsrKiotKyMqKiorLSAKICAgICAgICAgICAgICAgICAgICA6PSsrKyAgOioqKis9OiAgICAKICAgICAgICAgICAgICAgIDo9KyoqLS09KioqKz06IAogICAgICAgICAgICAgICAgLT0rKiotKysrKz06LiAgCiAgICAgICAgICAgICAgICA6PT0rKis6PT06LiAgCiAgICAgICAgICAgIDo9KysqLQogICAgICAgICAgICAuLT0rKy0uIAogICAgICAgIC46PS06LiAgICAKICAgICAgICAuOjouICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAK"
|
|
45
44
|
self._text_art_small = "CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuKiorCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLiojLi4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDojKwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPSM6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uICAqKgogICAgICAgICAgICAgICAgICAgICAgICAgICAgPSUrPSsrIyMqIyoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArKiUjJSMlJSM9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyoqIyMjJSUlPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsjIyUjIyMqKiUjOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLisjJSUlJSUrKjogLSotCiAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IyUlJSUlKy4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIC49IyUlJSUjPQogICAgICAgICAgICAgICAgICAgICAgICAuKiUlJSUlKy4KICAgICAgICAgICAgICAgICAgICAgICAgLiojJSUlIy0KICAgICAgICAgICAgICAgICAgICAgICAgLSMjIyUjPS4KICAgICAgICAgICAgICAgICAgICAuPSoqKiMqOgogICAgICAgICAgICAgICAgICAgIDorKiMjKisuCiAgICAgICAgICAgICAgICAgICAgLSoqIyMjLQogICAgICAgICAgICAgICAgLj0qKyojKjoKICAgICAgICAgICAgICAgIDorKisqKj0uCiAgICAgICAgICAgICAgICAuLSsrKyoqLQogICAgICAgICAgICAuPSotLSorOgogICAgICAgICAgICAuPSs9PS0uCiAgICAgICAgICAgIDorPQogICAgICAgIC46Lgo="
|
|
46
45
|
self._pixel_art_wgs = [
|
|
47
46
|
# Art Credit: https://www.reddit.com/r/PixelArt/comments/n6xyrb/wolfs_gravestone_genshin_impact/
|
|
48
|
-
"51w",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
47
|
+
"51w",
|
|
48
|
+
"46w3b1w",
|
|
49
|
+
"43w2b1w1b1R1b1w",
|
|
50
|
+
"43w1b1R1b1R2b1w",
|
|
51
|
+
"43w2b1r1b3w",
|
|
52
|
+
"41w3b1r1b1r1b2w",
|
|
53
|
+
"28w3b10w1b1g5b2w",
|
|
54
|
+
"28w1b1r1b9w1b3g1b5w",
|
|
55
|
+
"28w2b1R1b1w2b4w1b3g2b5w",
|
|
56
|
+
"30w1b1m1b1g1b1w1b1w1b3g1b7w",
|
|
57
|
+
"30w3b2g3b3g1b8w",
|
|
58
|
+
"29w1b2g1b5g1b1g1b9w",
|
|
59
|
+
"29w1b1g2b1g4b1g1b10w",
|
|
60
|
+
"29w1b3g2b1R2b1g2b9w",
|
|
61
|
+
"27w7b3r1b1g1b10w",
|
|
62
|
+
"27w1b5g1b1r1w2b2g2b8w",
|
|
63
|
+
"26w2b3g6b4g1b8w",
|
|
64
|
+
"26w1b2g2b2R1b1g1b1g4b9w",
|
|
65
|
+
"25w1b2g1b2R2r1b1g1b1g1b1g1b1m1b8w",
|
|
56
66
|
"24w1b1w1m1g1b3r1b2g1b3g2b1R2b6w",
|
|
57
67
|
"21w3b2w1m1b3r1w1b2g4b2w1b1r1b6w",
|
|
58
|
-
"21w1b2w3m1b1r1w2b3g1b5w3b6w",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
68
|
+
"21w1b2w3m1b1r1w2b3g1b5w3b6w",
|
|
69
|
+
"21w1b1w3m1b1r2b3g3b14w",
|
|
70
|
+
"20w1b1w2R1m1b1r1b3m1g2b16w",
|
|
71
|
+
"19w1b1w3R1b1r1b2m2w1b18w",
|
|
72
|
+
"18w1b1w3R1b1r1b3m1w1b19w",
|
|
73
|
+
"17w1b1r3R1b1w1b2R1m1w1b20w",
|
|
74
|
+
"16w1b1w1R1r1R1b1r1b3R2w1b20w",
|
|
75
|
+
"15w1b1w1r1R1y1R2b3R1w3b20w",
|
|
76
|
+
"14w1b3r1y1R2r4y1b23w",
|
|
77
|
+
"13w1b1w3r4y2R1w1b24w",
|
|
78
|
+
"12w1b1w2r2R3r1R2y1b25w",
|
|
79
|
+
"10w2b1w2r1R2b1R3r1w1b26w",
|
|
80
|
+
"9w1b2w2r1R1b1w1b1R2r1w1b27w",
|
|
81
|
+
"9w1b1w2r1R1b1w1b1R2r1y1b28w",
|
|
82
|
+
"8w1b1w1r2R1b1w1b2r1y1w1b29w",
|
|
83
|
+
"7w1b1w1r1R2b1w1b4y1b30w",
|
|
84
|
+
"6w1b1w1r1R1b2w1b1R2r1w1b31w",
|
|
85
|
+
"5w1b1w2r1R1b2w1b1R1r2w1b31w",
|
|
86
|
+
"4w1b1w2r1R1b1w2b2r1w2b32w",
|
|
87
|
+
"3w1b1w1r1y1R1b1w1b3y1w1b34w",
|
|
88
|
+
"2w1b1w1r2y1b1w6b35w",
|
|
89
|
+
"1w6b43w",
|
|
90
|
+
"50w",
|
|
69
91
|
]
|
|
92
|
+
|
|
70
93
|
def __str__(self) -> str:
|
|
71
94
|
return f"{self.__class__.__name__}()"
|
|
95
|
+
|
|
72
96
|
def __repr__(self) -> str:
|
|
73
97
|
return self.__str__()
|
|
74
98
|
|
|
@@ -97,8 +121,8 @@ class WGS:
|
|
|
97
121
|
"""
|
|
98
122
|
# Make data
|
|
99
123
|
out = "1N".join(self._pixel_art_wgs)
|
|
100
|
-
out = out.replace("y", "r")
|
|
101
|
-
out = out.replace("m", "R")
|
|
124
|
+
out = out.replace("y", "r") # Convert yellow into red
|
|
125
|
+
out = out.replace("m", "R") # Convert magenta into dark red
|
|
102
126
|
return Str2Pixel(out).convert()
|
|
103
127
|
|
|
104
128
|
|
|
@@ -107,4 +131,4 @@ class WGS:
|
|
|
107
131
|
if __name__ == "__main__":
|
|
108
132
|
logger.setLevel(10)
|
|
109
133
|
test = WGS()
|
|
110
|
-
print(test.pixel_art())
|
|
134
|
+
print(test.pixel_art())
|
absfuyu/fun/__init__.py
CHANGED
|
@@ -3,16 +3,15 @@ Absfuyu: Fun
|
|
|
3
3
|
------------
|
|
4
4
|
Some fun or weird stuff
|
|
5
5
|
|
|
6
|
-
Version: 1.0.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 1.0.6
|
|
7
|
+
Date updated: 05/04/2023 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
# Library
|
|
12
11
|
###########################################################################
|
|
13
|
-
from datetime import date
|
|
14
12
|
import subprocess
|
|
15
13
|
import sys
|
|
14
|
+
from datetime import date
|
|
16
15
|
|
|
17
16
|
from absfuyu.logger import logger
|
|
18
17
|
from absfuyu.util.api import APIRequest
|
|
@@ -55,7 +54,7 @@ def zodiac_sign(
|
|
|
55
54
|
0 < month < 13,
|
|
56
55
|
]
|
|
57
56
|
if not all(conditions):
|
|
58
|
-
raise
|
|
57
|
+
raise ValueError("Value out of range")
|
|
59
58
|
|
|
60
59
|
zodiac = {
|
|
61
60
|
"Aquarius": any(
|
|
@@ -148,8 +147,8 @@ def im_bored() -> str:
|
|
|
148
147
|
"""
|
|
149
148
|
try:
|
|
150
149
|
api = APIRequest("https://www.boredapi.com/api/activity")
|
|
151
|
-
return api.fetch_data_only().json()["activity"]
|
|
152
|
-
except:
|
|
150
|
+
return api.fetch_data_only().json()["activity"] # type: ignore
|
|
151
|
+
except Exception:
|
|
153
152
|
return "FAILED"
|
|
154
153
|
|
|
155
154
|
|
absfuyu/fun/tarot.py
CHANGED
absfuyu/game/__init__.py
CHANGED
|
@@ -3,65 +3,66 @@ Absfuyu: Game
|
|
|
3
3
|
-------------
|
|
4
4
|
Contain some game that can be played on terminal
|
|
5
5
|
|
|
6
|
-
Version: 1.0
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 1.1.0
|
|
7
|
+
Date updated: 14/04/2024 (mm/dd/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
# Module Package
|
|
12
|
-
###########################################################################
|
|
13
10
|
__all__ = [
|
|
14
|
-
"game_escapeLoop",
|
|
11
|
+
"game_escapeLoop",
|
|
12
|
+
"game_RockPaperScissors",
|
|
15
13
|
]
|
|
16
14
|
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import random
|
|
17
|
+
import time
|
|
18
|
+
|
|
19
|
+
from .game_stat import GameStats
|
|
20
|
+
|
|
21
|
+
# Escape loop
|
|
22
|
+
_ESCAPE_LOOP_GAME_MSG = """\
|
|
23
|
+
Are you sure about this?
|
|
24
|
+
Don't leave me =((
|
|
25
|
+
I can't believe you did this to me!
|
|
26
|
+
Are you very much sure?
|
|
27
|
+
I'll be sad. Pick again please.
|
|
28
|
+
I still don't believe you.
|
|
29
|
+
Choose again.
|
|
30
|
+
You actually have to answer the correct keyword
|
|
31
|
+
I think you need to choose again.
|
|
32
|
+
Last chance!
|
|
33
|
+
Okay okay, i believe you ;)
|
|
34
|
+
Almost there.
|
|
35
|
+
I can do this all day
|
|
36
|
+
So close!
|
|
37
|
+
You can't escape from me.
|
|
38
|
+
How are you still here, just to suffer?
|
|
39
|
+
Never gonna give you up
|
|
40
|
+
Never gonna let you down
|
|
41
|
+
"""
|
|
21
42
|
|
|
22
43
|
|
|
23
|
-
# Default games
|
|
24
|
-
###########################################################################
|
|
25
44
|
def game_escapeLoop() -> None:
|
|
26
45
|
"""Try to escape the infinite loop"""
|
|
27
|
-
|
|
46
|
+
|
|
28
47
|
init = True
|
|
29
48
|
welcome_messages = [
|
|
30
49
|
"Congrats! You are now stuck inside an infinite loop.",
|
|
31
|
-
"Do you want to escape this loop?"
|
|
50
|
+
"Do you want to escape this loop?",
|
|
32
51
|
]
|
|
33
52
|
|
|
34
|
-
num1 =
|
|
35
|
-
num2 =
|
|
53
|
+
num1 = random.choice(range(2, 13))
|
|
54
|
+
num2 = random.choice(range(2, 13))
|
|
36
55
|
hidden_answer = str(num1 * num2)
|
|
37
56
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"Don't leave me =((",
|
|
41
|
-
"I can't believe you did this to me!",
|
|
42
|
-
"Are you very much sure?",
|
|
43
|
-
"I'll be sad. Pick again please.",
|
|
44
|
-
"I still don't believe you.",
|
|
45
|
-
"Choose again.",
|
|
46
|
-
"You actually have to answer the correct keyword",
|
|
47
|
-
"I think you need to choose again.",
|
|
48
|
-
"Last chance!",
|
|
49
|
-
"Okay okay, i believe you ;)",
|
|
50
|
-
"Almost there.",
|
|
51
|
-
"I can do this all day",
|
|
52
|
-
"So close!",
|
|
53
|
-
"You can't escape from me.",
|
|
54
|
-
"How are you still here, just to suffer?",
|
|
55
|
-
"Never gonna give you up",
|
|
56
|
-
"Never gonna let you down",
|
|
57
|
+
gm_msg = {x for x in _ESCAPE_LOOP_GAME_MSG.splitlines() if len(x) > 0}
|
|
58
|
+
game_messages = list(gm_msg) + [
|
|
57
59
|
f"Hint 01: The keyword is: {num1}",
|
|
58
|
-
f"Hint 02:
|
|
60
|
+
f"Hint 02: {num2}",
|
|
59
61
|
]
|
|
60
62
|
|
|
61
|
-
congrats_messages = [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
congrats_messages = ["Congratulation! You've escaped."]
|
|
64
|
+
|
|
65
|
+
start_time = time.time()
|
|
65
66
|
while True:
|
|
66
67
|
# Welcome
|
|
67
68
|
if init:
|
|
@@ -69,9 +70,9 @@ def game_escapeLoop() -> None:
|
|
|
69
70
|
print(x)
|
|
70
71
|
answer = str(input())
|
|
71
72
|
init = False
|
|
72
|
-
|
|
73
|
+
|
|
73
74
|
# Random text
|
|
74
|
-
mess =
|
|
75
|
+
mess = random.choice(game_messages)
|
|
75
76
|
print(mess)
|
|
76
77
|
|
|
77
78
|
# Condition check
|
|
@@ -79,24 +80,22 @@ def game_escapeLoop() -> None:
|
|
|
79
80
|
if answer == hidden_answer:
|
|
80
81
|
for x in congrats_messages:
|
|
81
82
|
print(x)
|
|
83
|
+
stop_time = time.time()
|
|
82
84
|
break
|
|
83
|
-
|
|
85
|
+
print(f"= Escaped in {stop_time-start_time:,.2f}s =")
|
|
84
86
|
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
# Rock Paper Scissors
|
|
89
|
+
def game_RockPaperScissors(hard_mode: bool = False) -> GameStats:
|
|
87
90
|
"""
|
|
88
91
|
Rock Paper Scissors
|
|
89
|
-
|
|
92
|
+
|
|
90
93
|
:param hard_mode: The bot only win or draw (Default: ``False``)
|
|
91
94
|
:type hard_mode: bool
|
|
92
95
|
"""
|
|
93
|
-
|
|
94
|
-
state_dict = {
|
|
95
|
-
|
|
96
|
-
1: "paper",
|
|
97
|
-
2: "scissors"
|
|
98
|
-
}
|
|
99
|
-
|
|
96
|
+
|
|
97
|
+
state_dict = {"0": "rock", "1": "paper", "2": "scissors"}
|
|
98
|
+
|
|
100
99
|
init = True
|
|
101
100
|
|
|
102
101
|
end_message = "end"
|
|
@@ -108,67 +107,62 @@ def game_RockPaperScissors(hard_mode=False):
|
|
|
108
107
|
|
|
109
108
|
game_messages = [
|
|
110
109
|
"Pick one option to begin:",
|
|
110
|
+
" ".join([f"{k}={v}" for k, v in state_dict.items()]),
|
|
111
111
|
]
|
|
112
112
|
|
|
113
|
-
game_summary =
|
|
114
|
-
|
|
115
|
-
"Draw": 0,
|
|
116
|
-
"Lose": 0
|
|
117
|
-
}
|
|
118
|
-
|
|
113
|
+
game_summary = GameStats()
|
|
114
|
+
|
|
119
115
|
while True:
|
|
120
116
|
# Welcome
|
|
121
117
|
if init:
|
|
122
118
|
for x in welcome_messages:
|
|
123
119
|
print(x)
|
|
124
120
|
init = False
|
|
125
|
-
|
|
121
|
+
|
|
126
122
|
# Game start
|
|
127
123
|
print("")
|
|
128
124
|
for x in game_messages:
|
|
129
125
|
print(x)
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
|
|
132
127
|
# Player's choice
|
|
133
|
-
answer = input()
|
|
128
|
+
answer = input().strip().lower()
|
|
134
129
|
|
|
135
130
|
# Condition check
|
|
136
131
|
if answer == end_message:
|
|
137
132
|
print(game_summary)
|
|
138
133
|
break
|
|
139
|
-
|
|
140
|
-
elif answer not in ["0","1","2"]:
|
|
134
|
+
|
|
135
|
+
elif answer not in ["0", "1", "2"]:
|
|
141
136
|
print("Invalid option. Choose again!")
|
|
142
|
-
|
|
137
|
+
|
|
143
138
|
else:
|
|
144
139
|
# Calculation
|
|
145
|
-
answer = int(answer)
|
|
146
140
|
if hard_mode:
|
|
147
|
-
if answer == 0:
|
|
148
|
-
game_choice =
|
|
149
|
-
if answer == 1:
|
|
150
|
-
game_choice =
|
|
151
|
-
if answer == 2:
|
|
152
|
-
game_choice =
|
|
141
|
+
if answer == "0":
|
|
142
|
+
game_choice = random.choice(["0", "1"])
|
|
143
|
+
if answer == "1":
|
|
144
|
+
game_choice = random.choice(["1", "2"])
|
|
145
|
+
if answer == "2":
|
|
146
|
+
game_choice = random.choice(["0", "2"])
|
|
153
147
|
else:
|
|
154
|
-
game_choice =
|
|
148
|
+
game_choice = random.choice(["0", "1", "2"])
|
|
155
149
|
print(f"You picked: {state_dict[answer]}")
|
|
156
150
|
print(f"BOT picked: {state_dict[game_choice]}")
|
|
157
|
-
|
|
158
|
-
if answer == 2 and game_choice == 0:
|
|
151
|
+
|
|
152
|
+
if answer == "2" and game_choice == "0":
|
|
159
153
|
print("You Lose!")
|
|
160
|
-
game_summary
|
|
161
|
-
elif answer == 0 and game_choice == 2:
|
|
154
|
+
game_summary.update_score("lose")
|
|
155
|
+
elif answer == "0" and game_choice == "2":
|
|
162
156
|
print("You Win!")
|
|
163
|
-
game_summary
|
|
157
|
+
game_summary.update_score("win")
|
|
164
158
|
elif answer == game_choice:
|
|
165
159
|
print("Draw Match!")
|
|
166
|
-
game_summary
|
|
160
|
+
game_summary.update_score("draw")
|
|
167
161
|
elif answer > game_choice:
|
|
168
162
|
print("You Win!")
|
|
169
|
-
game_summary
|
|
163
|
+
game_summary.update_score("win")
|
|
170
164
|
else:
|
|
171
165
|
print("You Lose!")
|
|
172
|
-
game_summary
|
|
166
|
+
game_summary.update_score("lose")
|
|
173
167
|
|
|
174
|
-
return game_summary
|
|
168
|
+
return game_summary
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Game: Game Stat
|
|
3
|
+
|
|
4
|
+
Version: 1.0.0
|
|
5
|
+
Date updated: 14/04/2024 (dd/mm/yyyy)
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__all__ = ["GameStats"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from typing import Literal
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class GameStats:
|
|
17
|
+
win: int = field(default=0)
|
|
18
|
+
draw: int = field(default=0)
|
|
19
|
+
lose: int = field(default=0)
|
|
20
|
+
win_rate: str = field(init=False)
|
|
21
|
+
_win_rate: float = field(init=False, repr=False)
|
|
22
|
+
|
|
23
|
+
def __post_init__(self) -> None:
|
|
24
|
+
self._update_win_rate()
|
|
25
|
+
|
|
26
|
+
def _update_win_rate(self) -> None:
|
|
27
|
+
try:
|
|
28
|
+
self._win_rate = self.win / (self.win + self.draw + self.lose)
|
|
29
|
+
self.win_rate = f"{self._win_rate*100:,.2f}%"
|
|
30
|
+
except ZeroDivisionError:
|
|
31
|
+
self._win_rate = 0
|
|
32
|
+
self.win_rate = "N/A"
|
|
33
|
+
|
|
34
|
+
def update_score(self, option: Literal["win", "draw", "lose"]) -> None:
|
|
35
|
+
self.__setattr__(option, self.__getattribute__(option) + 1)
|
|
36
|
+
self._update_win_rate()
|