mechanic: move word lists to data files

The word lists (monsters, spells, equipment, races, classes, titles and
so on) now live in pqcli/data/*.json instead of pqcli/config.py. A
GameData object loaded at startup is passed to the simulation and UIs.

Users can replace any list by putting NAME.json in
$XDG_CONFIG_HOME/pqcli/data/ or a directory given with --data-dir.
--dump-data DIR copies the built-in files out for editing. Malformed
files are reported and pqcli exits before starting the UI.

Combat task descriptions come from the new combat_verbs list, with
{target} standing for the enemy. The built-in list holds only "Executing
{target}", and a single verb consumes no random roll, so stock gameplay
is unchanged. Recorded traces in tests/fixtures pin this down.

Monster, Race and Class stay in pqcli.config so existing saves still
load.

Resolves #3
This commit is contained in:
Dash committed 2026-10-17 15:55:41 +02:00
1 parent 5337d94f82
commit c0c6c8aeba
38 files changed
+7143 -778

No files matched your search

@@ -1,22 +1,25 @@
import functools
import typing as T
from pqcli.config import CLASSES, Class
from pqcli.config import Class
from pqcli.ui.curses.util import KEYS_CANCEL, Choice
from pqcli.ui.curses.views.menu_view import MenuView
class ChooseCharacterClassView(MenuView):
def __init__(
self, screen: T.Any, class_: T.Optional[Class] = None
self,
screen: T.Any,
classes: T.Sequence[Class],
class_: T.Optional[Class] = None,
) -> None:
super().__init__(
screen,
"Choose character class",
CLASSES.index(class_) if class_ is not None else 0,
classes.index(class_) if class_ is not None else 0,
)
for y, class_ in enumerate(CLASSES, 1):
for y, class_ in enumerate(classes, 1):
key: T.Optional[str] = str(y % 10) if y <= 10 else None
self._choices.append(
Choice(
@@ -1,20 +1,25 @@
import functools
import typing as T
from pqcli.config import RACES, Race
from pqcli.config import Race
from pqcli.ui.curses.util import KEYS_CANCEL, Choice
from pqcli.ui.curses.views.menu_view import MenuView
class ChooseCharacterRaceView(MenuView):
def __init__(self, screen: T.Any, race: T.Optional[Race] = None) -> None:
def __init__(
self,
screen: T.Any,
races: T.Sequence[Race],
race: T.Optional[Race] = None,
) -> None:
super().__init__(
screen,
"Choose character race",
RACES.index(race) if race is not None else 0,
races.index(race) if race is not None else 0,
)
for y, race in enumerate(RACES, 1):
for y, race in enumerate(races, 1):
key: T.Optional[str] = str(y % 10) if y <= 10 else None
self._choices.append(
Choice(
+3 -1
View File
@@ -3,6 +3,7 @@ import curses
import datetime
import typing as T
from pqcli.game_data import GameData
from pqcli.mechanic import Player, SignalMixin, Simulation
from pqcli.roster import Roster
from pqcli.ui.curses.event_handler import EventHandler
@@ -33,6 +34,7 @@ class GameView(BaseView):
roster: Roster,
player: Player,
args: argparse.Namespace,
data: GameData,
) -> None:
super().__init__(screen)
self.on_exit = EventHandler()
@@ -41,7 +43,7 @@ class GameView(BaseView):
self._player = player
self._args = args
self._simulation = Simulation(player)
self._simulation = Simulation(player, data)
self._last_tick = datetime.datetime.now()
def keypress(self, key: int) -> None: