bcsfe-wrapper-python 0.1.1__py3-none-any.whl → 0.1.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.
Files changed (206) hide show
  1. bcsfe_wrapper/__init__.py +9 -0
  2. bcsfe_wrapper/bcsfe/__init__.py +12 -0
  3. bcsfe_wrapper/bcsfe/__main__.py +80 -0
  4. bcsfe_wrapper/bcsfe/cli/__init__.py +23 -0
  5. bcsfe_wrapper/bcsfe/cli/color.py +179 -0
  6. bcsfe_wrapper/bcsfe/cli/dialog_creator.py +721 -0
  7. bcsfe_wrapper/bcsfe/cli/edits/__init__.py +27 -0
  8. bcsfe_wrapper/bcsfe/cli/edits/aku_realm.py +11 -0
  9. bcsfe_wrapper/bcsfe/cli/edits/basic_items.py +414 -0
  10. bcsfe_wrapper/bcsfe/cli/edits/cat_editor.py +789 -0
  11. bcsfe_wrapper/bcsfe/cli/edits/clear_tutorial.py +11 -0
  12. bcsfe_wrapper/bcsfe/cli/edits/enemy_editor.py +192 -0
  13. bcsfe_wrapper/bcsfe/cli/edits/event_tickets.py +148 -0
  14. bcsfe_wrapper/bcsfe/cli/edits/fixes.py +43 -0
  15. bcsfe_wrapper/bcsfe/cli/edits/map.py +544 -0
  16. bcsfe_wrapper/bcsfe/cli/edits/max_all.py +146 -0
  17. bcsfe_wrapper/bcsfe/cli/edits/rare_ticket_trade.py +45 -0
  18. bcsfe_wrapper/bcsfe/cli/edits/storage.py +214 -0
  19. bcsfe_wrapper/bcsfe/cli/feature_handler.py +291 -0
  20. bcsfe_wrapper/bcsfe/cli/file_dialog.py +154 -0
  21. bcsfe_wrapper/bcsfe/cli/main.py +362 -0
  22. bcsfe_wrapper/bcsfe/cli/recent_saves.py +144 -0
  23. bcsfe_wrapper/bcsfe/cli/save_management.py +644 -0
  24. bcsfe_wrapper/bcsfe/cli/server_cli.py +77 -0
  25. bcsfe_wrapper/bcsfe/core/__init__.py +422 -0
  26. bcsfe_wrapper/bcsfe/core/country_code.py +104 -0
  27. bcsfe_wrapper/bcsfe/core/crypto.py +164 -0
  28. bcsfe_wrapper/bcsfe/core/game/__init__.py +3 -0
  29. bcsfe_wrapper/bcsfe/core/game/battle/__init__.py +3 -0
  30. bcsfe_wrapper/bcsfe/core/game/battle/battle_items.py +300 -0
  31. bcsfe_wrapper/bcsfe/core/game/battle/cleared_slots.py +306 -0
  32. bcsfe_wrapper/bcsfe/core/game/battle/enemy.py +132 -0
  33. bcsfe_wrapper/bcsfe/core/game/battle/slots.py +200 -0
  34. bcsfe_wrapper/bcsfe/core/game/catbase/__init__.py +51 -0
  35. bcsfe_wrapper/bcsfe/core/game/catbase/beacon_base.py +67 -0
  36. bcsfe_wrapper/bcsfe/core/game/catbase/cat.py +1250 -0
  37. bcsfe_wrapper/bcsfe/core/game/catbase/drop_chara.py +74 -0
  38. bcsfe_wrapper/bcsfe/core/game/catbase/gambling.py +111 -0
  39. bcsfe_wrapper/bcsfe/core/game/catbase/gatya.py +436 -0
  40. bcsfe_wrapper/bcsfe/core/game/catbase/gatya_item.py +155 -0
  41. bcsfe_wrapper/bcsfe/core/game/catbase/item_pack.py +190 -0
  42. bcsfe_wrapper/bcsfe/core/game/catbase/login_bonuses.py +185 -0
  43. bcsfe_wrapper/bcsfe/core/game/catbase/matatabi.py +69 -0
  44. bcsfe_wrapper/bcsfe/core/game/catbase/medals.py +171 -0
  45. bcsfe_wrapper/bcsfe/core/game/catbase/mission.py +321 -0
  46. bcsfe_wrapper/bcsfe/core/game/catbase/my_sale.py +58 -0
  47. bcsfe_wrapper/bcsfe/core/game/catbase/nyanko_club.py +254 -0
  48. bcsfe_wrapper/bcsfe/core/game/catbase/officer_pass.py +79 -0
  49. bcsfe_wrapper/bcsfe/core/game/catbase/playtime.py +97 -0
  50. bcsfe_wrapper/bcsfe/core/game/catbase/powerup.py +179 -0
  51. bcsfe_wrapper/bcsfe/core/game/catbase/scheme_items.py +193 -0
  52. bcsfe_wrapper/bcsfe/core/game/catbase/special_skill.py +327 -0
  53. bcsfe_wrapper/bcsfe/core/game/catbase/stamp.py +58 -0
  54. bcsfe_wrapper/bcsfe/core/game/catbase/talent_orbs.py +710 -0
  55. bcsfe_wrapper/bcsfe/core/game/catbase/unlock_popups.py +163 -0
  56. bcsfe_wrapper/bcsfe/core/game/catbase/upgrade.py +196 -0
  57. bcsfe_wrapper/bcsfe/core/game/catbase/user_rank_rewards.py +276 -0
  58. bcsfe_wrapper/bcsfe/core/game/gamoto/__init__.py +9 -0
  59. bcsfe_wrapper/bcsfe/core/game/gamoto/base_materials.py +90 -0
  60. bcsfe_wrapper/bcsfe/core/game/gamoto/cat_shrine.py +216 -0
  61. bcsfe_wrapper/bcsfe/core/game/gamoto/catamins.py +59 -0
  62. bcsfe_wrapper/bcsfe/core/game/gamoto/gamatoto.py +496 -0
  63. bcsfe_wrapper/bcsfe/core/game/gamoto/ototo.py +660 -0
  64. bcsfe_wrapper/bcsfe/core/game/localizable.py +31 -0
  65. bcsfe_wrapper/bcsfe/core/game/map/__init__.py +43 -0
  66. bcsfe_wrapper/bcsfe/core/game/map/aku.py +229 -0
  67. bcsfe_wrapper/bcsfe/core/game/map/challenge.py +73 -0
  68. bcsfe_wrapper/bcsfe/core/game/map/chapters.py +372 -0
  69. bcsfe_wrapper/bcsfe/core/game/map/dojo.py +360 -0
  70. bcsfe_wrapper/bcsfe/core/game/map/enigma.py +224 -0
  71. bcsfe_wrapper/bcsfe/core/game/map/event.py +966 -0
  72. bcsfe_wrapper/bcsfe/core/game/map/ex_stage.py +102 -0
  73. bcsfe_wrapper/bcsfe/core/game/map/gauntlets.py +362 -0
  74. bcsfe_wrapper/bcsfe/core/game/map/item_reward_stage.py +416 -0
  75. bcsfe_wrapper/bcsfe/core/game/map/legend_quest.py +389 -0
  76. bcsfe_wrapper/bcsfe/core/game/map/map_names.py +112 -0
  77. bcsfe_wrapper/bcsfe/core/game/map/map_option.py +79 -0
  78. bcsfe_wrapper/bcsfe/core/game/map/map_reset.py +116 -0
  79. bcsfe_wrapper/bcsfe/core/game/map/outbreaks.py +256 -0
  80. bcsfe_wrapper/bcsfe/core/game/map/story.py +1167 -0
  81. bcsfe_wrapper/bcsfe/core/game/map/timed_score.py +193 -0
  82. bcsfe_wrapper/bcsfe/core/game/map/tower.py +68 -0
  83. bcsfe_wrapper/bcsfe/core/game/map/uncanny.py +104 -0
  84. bcsfe_wrapper/bcsfe/core/game/map/zero_legends.py +315 -0
  85. bcsfe_wrapper/bcsfe/core/game_version.py +244 -0
  86. bcsfe_wrapper/bcsfe/core/io/__init__.py +31 -0
  87. bcsfe_wrapper/bcsfe/core/io/adb_handler.py +181 -0
  88. bcsfe_wrapper/bcsfe/core/io/bc_csv.py +263 -0
  89. bcsfe_wrapper/bcsfe/core/io/command.py +50 -0
  90. bcsfe_wrapper/bcsfe/core/io/config.py +474 -0
  91. bcsfe_wrapper/bcsfe/core/io/data.py +647 -0
  92. bcsfe_wrapper/bcsfe/core/io/git_handler.py +90 -0
  93. bcsfe_wrapper/bcsfe/core/io/json_file.py +45 -0
  94. bcsfe_wrapper/bcsfe/core/io/path.py +299 -0
  95. bcsfe_wrapper/bcsfe/core/io/root_handler.py +112 -0
  96. bcsfe_wrapper/bcsfe/core/io/save.py +3594 -0
  97. bcsfe_wrapper/bcsfe/core/io/thread_helper.py +76 -0
  98. bcsfe_wrapper/bcsfe/core/io/waydroid.py +124 -0
  99. bcsfe_wrapper/bcsfe/core/io/yaml.py +67 -0
  100. bcsfe_wrapper/bcsfe/core/locale_handler.py +713 -0
  101. bcsfe_wrapper/bcsfe/core/log.py +126 -0
  102. bcsfe_wrapper/bcsfe/core/max_value_helper.py +70 -0
  103. bcsfe_wrapper/bcsfe/core/server/__init__.py +21 -0
  104. bcsfe_wrapper/bcsfe/core/server/client_info.py +34 -0
  105. bcsfe_wrapper/bcsfe/core/server/event_data.py +377 -0
  106. bcsfe_wrapper/bcsfe/core/server/game_data_getter.py +352 -0
  107. bcsfe_wrapper/bcsfe/core/server/headers.py +29 -0
  108. bcsfe_wrapper/bcsfe/core/server/managed_item.py +203 -0
  109. bcsfe_wrapper/bcsfe/core/server/request.py +115 -0
  110. bcsfe_wrapper/bcsfe/core/server/server_handler.py +649 -0
  111. bcsfe_wrapper/bcsfe/core/server/updater.py +85 -0
  112. bcsfe_wrapper/bcsfe/core/theme_handler.py +300 -0
  113. bcsfe_wrapper/bcsfe/files/locales/en/core/config.properties +96 -0
  114. bcsfe_wrapper/bcsfe/files/locales/en/core/files.properties +9 -0
  115. bcsfe_wrapper/bcsfe/files/locales/en/core/input.properties +31 -0
  116. bcsfe_wrapper/bcsfe/files/locales/en/core/locale.properties +33 -0
  117. bcsfe_wrapper/bcsfe/files/locales/en/core/main.properties +111 -0
  118. bcsfe_wrapper/bcsfe/files/locales/en/core/save.properties +117 -0
  119. bcsfe_wrapper/bcsfe/files/locales/en/core/server.properties +58 -0
  120. bcsfe_wrapper/bcsfe/files/locales/en/core/theme.properties +24 -0
  121. bcsfe_wrapper/bcsfe/files/locales/en/core/updater.properties +19 -0
  122. bcsfe_wrapper/bcsfe/files/locales/en/edits/bannable_items.properties +30 -0
  123. bcsfe_wrapper/bcsfe/files/locales/en/edits/cats.properties +160 -0
  124. bcsfe_wrapper/bcsfe/files/locales/en/edits/enemy.properties +17 -0
  125. bcsfe_wrapper/bcsfe/files/locales/en/edits/fixes.properties +13 -0
  126. bcsfe_wrapper/bcsfe/files/locales/en/edits/gambling.properties +3 -0
  127. bcsfe_wrapper/bcsfe/files/locales/en/edits/gamototo.properties +56 -0
  128. bcsfe_wrapper/bcsfe/files/locales/en/edits/gatya.properties +8 -0
  129. bcsfe_wrapper/bcsfe/files/locales/en/edits/gold_pass.properties +6 -0
  130. bcsfe_wrapper/bcsfe/files/locales/en/edits/items.properties +64 -0
  131. bcsfe_wrapper/bcsfe/files/locales/en/edits/map.properties +178 -0
  132. bcsfe_wrapper/bcsfe/files/locales/en/edits/medals.properties +8 -0
  133. bcsfe_wrapper/bcsfe/files/locales/en/edits/missions.properties +7 -0
  134. bcsfe_wrapper/bcsfe/files/locales/en/edits/playtime.properties +7 -0
  135. bcsfe_wrapper/bcsfe/files/locales/en/edits/scheme_items.properties +6 -0
  136. bcsfe_wrapper/bcsfe/files/locales/en/edits/special_skills.properties +10 -0
  137. bcsfe_wrapper/bcsfe/files/locales/en/edits/talent_orbs.properties +26 -0
  138. bcsfe_wrapper/bcsfe/files/locales/en/edits/treasures.properties +24 -0
  139. bcsfe_wrapper/bcsfe/files/locales/en/edits/user_rank.properties +9 -0
  140. bcsfe_wrapper/bcsfe/files/locales/tw/core/config.properties +95 -0
  141. bcsfe_wrapper/bcsfe/files/locales/tw/core/files.properties +9 -0
  142. bcsfe_wrapper/bcsfe/files/locales/tw/core/input.properties +31 -0
  143. bcsfe_wrapper/bcsfe/files/locales/tw/core/locale.properties +33 -0
  144. bcsfe_wrapper/bcsfe/files/locales/tw/core/main.properties +111 -0
  145. bcsfe_wrapper/bcsfe/files/locales/tw/core/save.properties +117 -0
  146. bcsfe_wrapper/bcsfe/files/locales/tw/core/server.properties +58 -0
  147. bcsfe_wrapper/bcsfe/files/locales/tw/core/theme.properties +24 -0
  148. bcsfe_wrapper/bcsfe/files/locales/tw/core/updater.properties +19 -0
  149. bcsfe_wrapper/bcsfe/files/locales/tw/edits/bannable_items.properties +30 -0
  150. bcsfe_wrapper/bcsfe/files/locales/tw/edits/cats.properties +160 -0
  151. bcsfe_wrapper/bcsfe/files/locales/tw/edits/enemy.properties +17 -0
  152. bcsfe_wrapper/bcsfe/files/locales/tw/edits/fixes.properties +13 -0
  153. bcsfe_wrapper/bcsfe/files/locales/tw/edits/gambling.properties +3 -0
  154. bcsfe_wrapper/bcsfe/files/locales/tw/edits/gamototo.properties +56 -0
  155. bcsfe_wrapper/bcsfe/files/locales/tw/edits/gatya.properties +8 -0
  156. bcsfe_wrapper/bcsfe/files/locales/tw/edits/gold_pass.properties +6 -0
  157. bcsfe_wrapper/bcsfe/files/locales/tw/edits/items.properties +64 -0
  158. bcsfe_wrapper/bcsfe/files/locales/tw/edits/map.properties +178 -0
  159. bcsfe_wrapper/bcsfe/files/locales/tw/edits/medals.properties +8 -0
  160. bcsfe_wrapper/bcsfe/files/locales/tw/edits/missions.properties +7 -0
  161. bcsfe_wrapper/bcsfe/files/locales/tw/edits/playtime.properties +7 -0
  162. bcsfe_wrapper/bcsfe/files/locales/tw/edits/scheme_items.properties +6 -0
  163. bcsfe_wrapper/bcsfe/files/locales/tw/edits/special_skills.properties +10 -0
  164. bcsfe_wrapper/bcsfe/files/locales/tw/edits/talent_orbs.properties +26 -0
  165. bcsfe_wrapper/bcsfe/files/locales/tw/edits/treasures.properties +24 -0
  166. bcsfe_wrapper/bcsfe/files/locales/tw/edits/user_rank.properties +9 -0
  167. bcsfe_wrapper/bcsfe/files/locales/tw/metadata.json +4 -0
  168. bcsfe_wrapper/bcsfe/files/locales/vi/core/config.properties +95 -0
  169. bcsfe_wrapper/bcsfe/files/locales/vi/core/files.properties +10 -0
  170. bcsfe_wrapper/bcsfe/files/locales/vi/core/input.properties +33 -0
  171. bcsfe_wrapper/bcsfe/files/locales/vi/core/locale.properties +118 -0
  172. bcsfe_wrapper/bcsfe/files/locales/vi/core/main.properties +75 -0
  173. bcsfe_wrapper/bcsfe/files/locales/vi/core/save.properties +84 -0
  174. bcsfe_wrapper/bcsfe/files/locales/vi/core/server.properties +31 -0
  175. bcsfe_wrapper/bcsfe/files/locales/vi/core/theme.properties +24 -0
  176. bcsfe_wrapper/bcsfe/files/locales/vi/core/updater.properties +20 -0
  177. bcsfe_wrapper/bcsfe/files/locales/vi/edits/bannable_items.properties +31 -0
  178. bcsfe_wrapper/bcsfe/files/locales/vi/edits/cats.properties +154 -0
  179. bcsfe_wrapper/bcsfe/files/locales/vi/edits/enemy.properties +18 -0
  180. bcsfe_wrapper/bcsfe/files/locales/vi/edits/fixes.properties +13 -0
  181. bcsfe_wrapper/bcsfe/files/locales/vi/edits/gambling.properties +4 -0
  182. bcsfe_wrapper/bcsfe/files/locales/vi/edits/gamototo.properties +56 -0
  183. bcsfe_wrapper/bcsfe/files/locales/vi/edits/gatya.properties +9 -0
  184. bcsfe_wrapper/bcsfe/files/locales/vi/edits/gold_pass.properties +7 -0
  185. bcsfe_wrapper/bcsfe/files/locales/vi/edits/items.properties +65 -0
  186. bcsfe_wrapper/bcsfe/files/locales/vi/edits/map.properties +177 -0
  187. bcsfe_wrapper/bcsfe/files/locales/vi/edits/medals.properties +9 -0
  188. bcsfe_wrapper/bcsfe/files/locales/vi/edits/missions.properties +8 -0
  189. bcsfe_wrapper/bcsfe/files/locales/vi/edits/playtime.properties +8 -0
  190. bcsfe_wrapper/bcsfe/files/locales/vi/edits/scheme_items.properties +7 -0
  191. bcsfe_wrapper/bcsfe/files/locales/vi/edits/special_skills.properties +11 -0
  192. bcsfe_wrapper/bcsfe/files/locales/vi/edits/talent_orbs.properties +24 -0
  193. bcsfe_wrapper/bcsfe/files/locales/vi/edits/treasures.properties +25 -0
  194. bcsfe_wrapper/bcsfe/files/locales/vi/edits/user_rank.properties +10 -0
  195. bcsfe_wrapper/bcsfe/files/locales/vi/metadata.json +4 -0
  196. bcsfe_wrapper/bcsfe/files/max_values.json +26 -0
  197. bcsfe_wrapper/bcsfe/files/themes/default.json +16 -0
  198. bcsfe_wrapper/bcsfe/files/themes/discord.json +16 -0
  199. bcsfe_wrapper/bcsfe/py.typed +0 -0
  200. bcsfe_wrapper/wrapper.py +102 -0
  201. {bcsfe_wrapper_python-0.1.1.dist-info → bcsfe_wrapper_python-0.1.3.dist-info}/METADATA +1 -1
  202. bcsfe_wrapper_python-0.1.3.dist-info/RECORD +204 -0
  203. bcsfe_wrapper_python-0.1.3.dist-info/top_level.txt +1 -0
  204. bcsfe_wrapper_python-0.1.1.dist-info/RECORD +0 -4
  205. bcsfe_wrapper_python-0.1.1.dist-info/top_level.txt +0 -1
  206. {bcsfe_wrapper_python-0.1.1.dist-info → bcsfe_wrapper_python-0.1.3.dist-info}/WHEEL +0 -0
@@ -0,0 +1,9 @@
1
+ import os
2
+ import sys
3
+
4
+ # パッケージ内のbcsfeをインポート可能にするためのパス調整
5
+ _current_dir = os.path.dirname(os.path.abspath(__file__))
6
+ if _current_dir not in sys.path:
7
+ sys.path.insert(0, _current_dir)
8
+
9
+ from .wrapper import BCSFEWrapper
@@ -0,0 +1,12 @@
1
+ __version__ = "3.3.0"
2
+
3
+ from bcsfe import core, cli
4
+
5
+
6
+ __all__ = ["core", "cli"]
7
+
8
+
9
+ def run():
10
+ from bcsfe import __main__
11
+
12
+ __main__.main()
@@ -0,0 +1,80 @@
1
+ from __future__ import annotations
2
+ import traceback
3
+
4
+ from bcsfe import cli
5
+
6
+ from bcsfe import core
7
+
8
+ import bcsfe
9
+ import argparse
10
+
11
+
12
+ def main():
13
+ parser = argparse.ArgumentParser("bcsfe")
14
+
15
+ parser.add_argument(
16
+ "--version", "-v", action="store_true", help="display the version and exit"
17
+ )
18
+ parser.add_argument(
19
+ "--input-path", "-i", type=str, help="input path to save file to edit"
20
+ )
21
+ parser.add_argument(
22
+ "--game-data-dir", "-g", type=str, help="path to store the game data to"
23
+ )
24
+ parser.add_argument(
25
+ "--transfer-backup-path",
26
+ type=str,
27
+ help="path to save the backup SAVE_DATA after transfering to",
28
+ )
29
+ parser.add_argument(
30
+ "--config-path",
31
+ "-c",
32
+ type=str,
33
+ default=None,
34
+ help=f"path to the config file. If unspecified defaults to {core.Config.get_config_path()}",
35
+ )
36
+ parser.add_argument(
37
+ "--log-path",
38
+ "-l",
39
+ type=str,
40
+ default=None,
41
+ help=f"path to the log file. If unspecified defaults to {core.Logger.get_log_path()}",
42
+ )
43
+
44
+ args = parser.parse_args()
45
+ if args.version:
46
+ print(bcsfe.__version__)
47
+ exit()
48
+
49
+ if args.config_path is not None:
50
+ core.set_config_path(core.Path(args.config_path))
51
+
52
+ if args.log_path is not None:
53
+ core.set_log_path(core.Path(args.log_path))
54
+
55
+ if args.transfer_backup_path is not None:
56
+ core.set_transfer_backup_path(core.Path(args.transfer_backup_path))
57
+
58
+ if args.game_data_dir is not None:
59
+ core.set_game_data_path(core.Path(args.game_data_dir))
60
+
61
+ core.core_data.init_data()
62
+
63
+ try:
64
+ cli.main.Main().main(args.input_path)
65
+ except KeyboardInterrupt:
66
+ cli.main.Main.leave()
67
+ except Exception as e:
68
+ tb = traceback.format_exc()
69
+ cli.color.ColoredText.localize(
70
+ "error", error=e, version=bcsfe.__version__, traceback=tb
71
+ )
72
+ try:
73
+ cli.main.Main.exit_editor()
74
+ except Exception:
75
+ pass
76
+ except KeyboardInterrupt:
77
+ pass
78
+
79
+
80
+ main()
@@ -0,0 +1,23 @@
1
+ from bcsfe.cli import (
2
+ color,
3
+ dialog_creator,
4
+ main,
5
+ file_dialog,
6
+ feature_handler,
7
+ save_management,
8
+ server_cli,
9
+ edits,
10
+ recent_saves,
11
+ )
12
+
13
+ __all__ = [
14
+ "color",
15
+ "dialog_creator",
16
+ "main",
17
+ "file_dialog",
18
+ "feature_handler",
19
+ "save_management",
20
+ "server_cli",
21
+ "edits",
22
+ "recent_saves",
23
+ ]
@@ -0,0 +1,179 @@
1
+ from __future__ import annotations
2
+ from typing import Any
3
+ from aenum import NamedConstant # type: ignore
4
+ import colored # type: ignore
5
+ from bcsfe import core
6
+
7
+
8
+ class ColorHex(NamedConstant):
9
+ GREEN = "#008000"
10
+ G = GREEN
11
+ RED = "#FF0000"
12
+ R = RED
13
+ DARK_YELLOW = "#D7C32A"
14
+ DY = DARK_YELLOW
15
+ BLACK = "#000000"
16
+ BL = BLACK
17
+ WHITE = "#FFFFFF"
18
+ W = WHITE
19
+ CYAN = "#00FFFF"
20
+ C = CYAN
21
+ DARK_GREY = "#A9A9A9"
22
+ DG = DARK_GREY
23
+ BLUE = "#0000FF"
24
+ B = BLUE
25
+ YELLOW = "#FFFF00"
26
+ Y = YELLOW
27
+ MAGENTA = "#FF00FF"
28
+ M = MAGENTA
29
+ DARK_BLUE = "#00008B"
30
+ DB = DARK_BLUE
31
+ DARK_CYAN = "#008B8B"
32
+ DC = DARK_CYAN
33
+ DARK_MAGENTA = "#8B008B"
34
+ DM = DARK_MAGENTA
35
+ DARK_RED = "#8B0000"
36
+ DR = DARK_RED
37
+ DARK_GREEN = "#006400"
38
+ DGN = DARK_GREEN
39
+ LIGHT_GREY = "#D3D3D3"
40
+ LG = LIGHT_GREY
41
+ ORANGE = "#FFA500"
42
+ O = ORANGE
43
+
44
+ @staticmethod
45
+ def from_name(name: str) -> str:
46
+ if name == "":
47
+ return ""
48
+ return getattr(ColorHex, name.upper())
49
+
50
+
51
+ class ColorHelper:
52
+ def __init__(self):
53
+ self.theme_handler = core.core_data.theme_manager
54
+
55
+ def get_color(self, color_name: str) -> str:
56
+ try:
57
+ first_char = color_name[0]
58
+ except IndexError:
59
+ return ""
60
+ if first_char == "#":
61
+ return color_name
62
+ if first_char == "@":
63
+ try:
64
+ second_char = color_name[1]
65
+ except IndexError:
66
+ return ""
67
+ try:
68
+ third_char = color_name[2]
69
+ except IndexError:
70
+ third_char = ""
71
+ if second_char == "p":
72
+ return self.theme_handler.get_primary_color()
73
+ if second_char == "s" and third_char != "u":
74
+ return self.theme_handler.get_secondary_color()
75
+ if second_char == "t":
76
+ return self.theme_handler.get_tertiary_color()
77
+ if second_char == "q":
78
+ return self.theme_handler.get_quaternary_color()
79
+ if second_char == "e":
80
+ return self.theme_handler.get_error_color()
81
+ if second_char == "w":
82
+ return self.theme_handler.get_warning_color()
83
+ if second_char == "s" and third_char == "u":
84
+ return self.theme_handler.get_success_color()
85
+ return self.theme_handler.get_theme_color(color_name[1:])
86
+ try:
87
+ return ColorHex.from_name(color_name)
88
+ except AttributeError:
89
+ return ""
90
+
91
+
92
+ class ColoredText:
93
+ def __init__(self, string: str, end: str = "\n") -> None:
94
+ string = string.replace("\\n", "\n")
95
+ self.string = string
96
+ self.end = end
97
+ self.color_helper = ColorHelper()
98
+ self.display(string)
99
+
100
+ def display(self, string: str) -> None:
101
+ text_data = self.parse(string)
102
+ for i, (text, color) in enumerate(text_data):
103
+ if i == len(text_data) - 1:
104
+ text += self.end
105
+ if color == "":
106
+ print(text, end="")
107
+ else:
108
+ try:
109
+ fg = colored.fg(color) # type: ignore
110
+ except Exception:
111
+ print(text, end="")
112
+ continue
113
+ print(colored.stylize(text, fg), end="") # type: ignore
114
+
115
+ @staticmethod
116
+ def localize(string: str, escape: bool = True, **kwargs: Any) -> ColoredText:
117
+ return ColoredText(
118
+ core.core_data.local_manager.get_key(string, escape=escape, **kwargs)
119
+ )
120
+
121
+ def parse(self, txt: str) -> list[tuple[str, str]]:
122
+ txt = "<@p>" + txt + "</>"
123
+ output: list[tuple[str, str]] = []
124
+ i = 0
125
+ tags: list[str] = []
126
+ inside_tag = False
127
+ in_closing_tag = False
128
+ tag_text = ""
129
+ text = ""
130
+ special_chars = core.LocalManager.get_special_chars()
131
+ while i < len(txt):
132
+ char = txt[i]
133
+ if char == "\\" and i + 1 < len(txt) and txt[i + 1] in special_chars:
134
+ i += 1
135
+ char = txt[i]
136
+ text += char
137
+ i += 1
138
+ continue
139
+ if tags:
140
+ tag = tags[-1]
141
+ else:
142
+ tag = ""
143
+ if char == ">" and inside_tag:
144
+ inside_tag = False
145
+ if not in_closing_tag:
146
+ tags.append(tag_text)
147
+ if in_closing_tag:
148
+ in_closing_tag = False
149
+ tag_text = ""
150
+ if char == "<" and not inside_tag:
151
+ inside_tag = True
152
+ if text:
153
+ color = self.color_helper.get_color(tag)
154
+ output.append((text, color))
155
+ text = ""
156
+ tag_text = ""
157
+ if char == "/" and inside_tag:
158
+ in_closing_tag = True
159
+ if tags:
160
+ tags.pop()
161
+ if not inside_tag and char != ">" and char != "<":
162
+ text += char
163
+ if inside_tag and char != "<" and char != ">":
164
+ tag_text += char
165
+ i += 1
166
+ return output
167
+
168
+
169
+ class ColoredInput:
170
+ def __init__(self, end: str = "") -> None:
171
+ self.end = end
172
+
173
+ def get(self, display_string: str) -> str:
174
+ ColoredText(display_string, end=self.end)
175
+ return input()
176
+
177
+ def localize(self, string: str, escape: bool = True, **kwargs: Any) -> str:
178
+ text = core.core_data.local_manager.get_key(string, escape=escape, **kwargs)
179
+ return self.get(text)