mirror of
https://github.com/rr-/pq-cli.git
synced 2026-11-12 22:40:36 -07:00
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:
38 files changed
+7143
-778
No files matched your search
@@ -8,7 +8,8 @@ import typing as T
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from pqcli import lingo
|
||||
from pqcli.config import CLASSES, PRIME_STATS, RACES
|
||||
from pqcli.config import PRIME_STATS
|
||||
from pqcli.game_data import GameData
|
||||
from pqcli.mechanic import Player, Simulation, StatsBuilder, create_player
|
||||
from pqcli.roster import Roster
|
||||
from pqcli.ui.base import BaseUserInterface
|
||||
@@ -37,8 +38,9 @@ class BasicUserInterface(BaseUserInterface):
|
||||
roster: Roster,
|
||||
player: T.Optional[Player],
|
||||
args: argparse.Namespace,
|
||||
data: GameData,
|
||||
) -> None:
|
||||
super().__init__(roster, player, args)
|
||||
super().__init__(roster, player, args, data)
|
||||
|
||||
def signal_handler(sig: T.Any, frame: T.Any) -> None:
|
||||
logging.info("Quitting")
|
||||
@@ -107,8 +109,10 @@ class BasicUserInterface(BaseUserInterface):
|
||||
print("Cancelled.")
|
||||
return None
|
||||
|
||||
race = self.menu([(race, race.name) for race in RACES])
|
||||
class_ = self.menu([(class_, class_.name) for class_ in CLASSES])
|
||||
race = self.menu([(race, race.name) for race in self.data.races])
|
||||
class_ = self.menu(
|
||||
[(class_, class_.name) for class_ in self.data.classes]
|
||||
)
|
||||
|
||||
stats_builder = StatsBuilder()
|
||||
while True:
|
||||
@@ -131,7 +135,7 @@ class BasicUserInterface(BaseUserInterface):
|
||||
|
||||
def play(self, player: Player) -> None:
|
||||
print(f"Playing as {player.name}")
|
||||
simulation = Simulation(player)
|
||||
simulation = Simulation(player, self.data)
|
||||
last_tick = datetime.now()
|
||||
last_level = 0
|
||||
while True:
|
||||
|
||||
Reference in new issue
Block a user