pqcli-ja 1.1.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.
- pqcli/__init__.py +0 -0
- pqcli/__main__.py +117 -0
- pqcli/config.py +750 -0
- pqcli/i18n.py +71 -0
- pqcli/lingo/__init__.py +140 -0
- pqcli/lingo/en.py +140 -0
- pqcli/locale/ja/LC_MESSAGES/pqcli.mo +0 -0
- pqcli/locale/ja/LC_MESSAGES/pqcli.po +4088 -0
- pqcli/locale/pqcli.pot +4026 -0
- pqcli/mechanic.py +1147 -0
- pqcli/random.py +26 -0
- pqcli/roster.py +40 -0
- pqcli/text.py +83 -0
- pqcli/ui/__init__.py +0 -0
- pqcli/ui/base.py +22 -0
- pqcli/ui/basic/__init__.py +253 -0
- pqcli/ui/curses/__init__.py +204 -0
- pqcli/ui/curses/colors.py +18 -0
- pqcli/ui/curses/event_handler.py +14 -0
- pqcli/ui/curses/util.py +57 -0
- pqcli/ui/curses/views/__init__.py +23 -0
- pqcli/ui/curses/views/base_view.py +18 -0
- pqcli/ui/curses/views/choose_character_view.py +64 -0
- pqcli/ui/curses/views/confirm_view.py +51 -0
- pqcli/ui/curses/views/create_character_view/__init__.py +11 -0
- pqcli/ui/curses/views/create_character_view/choose_character_class_view.py +36 -0
- pqcli/ui/curses/views/create_character_view/choose_character_name_view.py +121 -0
- pqcli/ui/curses/views/create_character_view/choose_character_race_view.py +34 -0
- pqcli/ui/curses/views/create_character_view/choose_character_stats_view.py +112 -0
- pqcli/ui/curses/views/game_view/__init__.py +263 -0
- pqcli/ui/curses/views/game_view/character_sheet_window.py +67 -0
- pqcli/ui/curses/views/game_view/equipment_window.py +69 -0
- pqcli/ui/curses/views/game_view/inventory_window.py +106 -0
- pqcli/ui/curses/views/game_view/plot_window.py +68 -0
- pqcli/ui/curses/views/game_view/progress_bar_window.py +156 -0
- pqcli/ui/curses/views/game_view/quest_book_window.py +66 -0
- pqcli/ui/curses/views/game_view/spell_book_window.py +71 -0
- pqcli/ui/curses/views/game_view/task_progress_window.py +52 -0
- pqcli/ui/curses/views/menu_view.py +41 -0
- pqcli/ui/curses/views/roster_view.py +102 -0
- pqcli/ui/curses/widgets/__init__.py +20 -0
- pqcli/ui/curses/widgets/base.py +41 -0
- pqcli/ui/curses/widgets/data_table.py +86 -0
- pqcli/ui/curses/widgets/focusable.py +42 -0
- pqcli/ui/curses/widgets/label.py +14 -0
- pqcli/ui/curses/widgets/list_box.py +57 -0
- pqcli/ui/curses/widgets/menu.py +104 -0
- pqcli/ui/curses/widgets/progress_bar.py +68 -0
- pqcli/ui/curses/widgets/scrollable.py +116 -0
- pqcli_ja-1.1.0.dist-info/METADATA +253 -0
- pqcli_ja-1.1.0.dist-info/RECORD +54 -0
- pqcli_ja-1.1.0.dist-info/WHEEL +4 -0
- pqcli_ja-1.1.0.dist-info/entry_points.txt +2 -0
- pqcli_ja-1.1.0.dist-info/licenses/LICENSE.md +24 -0
pqcli/__init__.py
ADDED
|
File without changes
|
pqcli/__main__.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import typing as T
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from xdg_base_dirs import xdg_config_home
|
|
7
|
+
|
|
8
|
+
from pqcli.i18n import _
|
|
9
|
+
from pqcli.mechanic import Player
|
|
10
|
+
from pqcli.roster import Roster
|
|
11
|
+
from pqcli.ui.basic import BasicUserInterface
|
|
12
|
+
from pqcli.ui.curses import CursesUserInterface
|
|
13
|
+
|
|
14
|
+
SAVE_PATH = Path(xdg_config_home()) / "pqcli" / "save.dat"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def parse_args() -> argparse.Namespace:
|
|
18
|
+
parser = argparse.ArgumentParser(prog="pqcli")
|
|
19
|
+
|
|
20
|
+
group = parser.add_mutually_exclusive_group()
|
|
21
|
+
group.set_defaults(ui=CursesUserInterface)
|
|
22
|
+
group.add_argument(
|
|
23
|
+
"--basic",
|
|
24
|
+
dest="ui",
|
|
25
|
+
action="store_const",
|
|
26
|
+
const=BasicUserInterface,
|
|
27
|
+
help=_("Use basic user interface (very crude, but uses least CPU)"),
|
|
28
|
+
)
|
|
29
|
+
group.add_argument(
|
|
30
|
+
"--curses",
|
|
31
|
+
dest="ui",
|
|
32
|
+
action="store_const",
|
|
33
|
+
const=CursesUserInterface,
|
|
34
|
+
help=_("Use curses user interface (fast, but no colors output)"),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"--no-colors",
|
|
39
|
+
dest="colors",
|
|
40
|
+
action="store_false",
|
|
41
|
+
help=_("Disable color highlighting in curses interface"),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
"--no-save",
|
|
46
|
+
dest="use_saves",
|
|
47
|
+
action="store_false",
|
|
48
|
+
help=argparse.SUPPRESS,
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument("--cheats", action="store_true", help="???")
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"--list-saves",
|
|
53
|
+
action="store_true",
|
|
54
|
+
help=_("list saved characters and exit"),
|
|
55
|
+
)
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
"--load-save",
|
|
58
|
+
type=int,
|
|
59
|
+
metavar="NUM",
|
|
60
|
+
help=_("play chosen character"),
|
|
61
|
+
)
|
|
62
|
+
return parser.parse_args()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def list_players(roster: Roster, file: T.Optional[T.Any] = None) -> None:
|
|
66
|
+
for i, player in enumerate(roster.players, start=1):
|
|
67
|
+
print(f"{i}. {player.name}", file=file)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def bootstrap_first_run(roster: Roster, args: argparse.Namespace) -> None:
|
|
71
|
+
if roster.players or args.list_saves or args.load_save:
|
|
72
|
+
return
|
|
73
|
+
|
|
74
|
+
print(
|
|
75
|
+
_("No saved characters found. Starting first-run character creation.")
|
|
76
|
+
)
|
|
77
|
+
ui = BasicUserInterface(roster, None, args)
|
|
78
|
+
while not roster.players:
|
|
79
|
+
player = ui.create_player(auto_play=False)
|
|
80
|
+
if player:
|
|
81
|
+
return
|
|
82
|
+
if not ui.confirm(
|
|
83
|
+
_("No character created. Do you want to try again?")
|
|
84
|
+
):
|
|
85
|
+
print(_("A character is required for first run."), file=sys.stderr)
|
|
86
|
+
raise SystemExit(1)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def main() -> None:
|
|
90
|
+
args = parse_args()
|
|
91
|
+
roster = Roster.load(SAVE_PATH)
|
|
92
|
+
|
|
93
|
+
if args.list_saves:
|
|
94
|
+
list_players(roster)
|
|
95
|
+
exit(0)
|
|
96
|
+
|
|
97
|
+
player: T.Optional[Player] = None
|
|
98
|
+
if args.load_save:
|
|
99
|
+
try:
|
|
100
|
+
player = list(roster.players)[args.load_save - 1]
|
|
101
|
+
except IndexError:
|
|
102
|
+
print(_("Invalid player. Available players:"), file=sys.stderr)
|
|
103
|
+
list_players(roster, file=sys.stderr)
|
|
104
|
+
exit(1)
|
|
105
|
+
|
|
106
|
+
bootstrap_first_run(roster, args)
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
ui = args.ui(roster, player, args)
|
|
110
|
+
ui.run()
|
|
111
|
+
finally:
|
|
112
|
+
if args.use_saves:
|
|
113
|
+
roster.save()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
main()
|