From 280949c9e722230ba600df13a1003537b20a4d63 Mon Sep 17 00:00:00 2001 From: evilchili Date: Sat, 6 Jan 2024 12:23:05 -0800 Subject: [PATCH] updating rolltable interface --- deadsands/site_tools/cli.py | 2 +- deadsands/site_tools/jobs.py | 2 +- deadsands/site_tools/shell/interactive_shell.py | 11 +++-------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/deadsands/site_tools/cli.py b/deadsands/site_tools/cli.py index 1d44ae2..e728cc1 100644 --- a/deadsands/site_tools/cli.py +++ b/deadsands/site_tools/cli.py @@ -6,7 +6,7 @@ from pathlib import Path import click import typer -from rolltable.tables import RollTable +from rolltable.types import RollTable from typing_extensions import Annotated from site_tools.content_manager import create diff --git a/deadsands/site_tools/jobs.py b/deadsands/site_tools/jobs.py index dfc74d6..851149c 100644 --- a/deadsands/site_tools/jobs.py +++ b/deadsands/site_tools/jobs.py @@ -2,7 +2,7 @@ import random import collections from pathlib import Path -from rolltable.tables import RollTable +from rolltable.types import RollTable from npc import random_npc Crime = collections.namedtuple('Crime', ['name', 'min_bounty', 'max_bounty']) diff --git a/deadsands/site_tools/shell/interactive_shell.py b/deadsands/site_tools/shell/interactive_shell.py index 4b15694..5a57d99 100644 --- a/deadsands/site_tools/shell/interactive_shell.py +++ b/deadsands/site_tools/shell/interactive_shell.py @@ -3,8 +3,7 @@ from pathlib import Path from prompt_toolkit.application import get_app from prompt_toolkit.completion import WordCompleter from prompt_toolkit.key_binding import KeyBindings -from rich.table import Table -from rolltable.tables import RollTable +from rolltable.types import RollTable from site_tools.shell.base import BasePrompt, command from site_tools import campaign @@ -115,15 +114,11 @@ class DMShell(BasePrompt): return self.date() def _rolltable(self, source, frequency='default', die=20): - rt = RollTable( + return RollTable( [Path(f"{self.cache['table_sources_path']}/{source}").read_text()], frequency=frequency, die=die - ) - table = Table(*rt.rows[0]) - for row in rt.rows[1:]: - table.add_row(*row) - return table + ).as_table() @command(usage=""" [title]DATE[/title]