From b96e46b67d055d757096abe87610167f91422498 Mon Sep 17 00:00:00 2001 From: evilchili Date: Tue, 4 Jul 2023 12:14:23 -0700 Subject: [PATCH] adding NPC generator --- deadsands/pyproject.toml | 4 +- .../site_tools/shell/interactive_shell.py | 58 ++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/deadsands/pyproject.toml b/deadsands/pyproject.toml index 6f8ce26..ba3bcc5 100644 --- a/deadsands/pyproject.toml +++ b/deadsands/pyproject.toml @@ -26,7 +26,9 @@ pelican-sitemap = "^1.0.2" pelican-yaml-metadata = { git = "https://github.com/pR0Ps/pelican-yaml-metadata.git", branch = "cdc1b9708916410e455e8e258e3d39a9d575c7b5" } # local wotsits -dnd-npcs = { git = "https://github.com/evilchili/dnd-npcs", branch = 'main' } +#dnd-npcs = { git = "https://github.com/evilchili/dnd-npcs", branch = 'main' } +#dnd-npcs = { path = "../../dnd-npcs" } +dnd-npcs = { file = "../../dnd-npcs/dist/dnd_npcs-0.2.0-py3-none-any.whl" } elethis-cipher= { git = "https://github.com/evilchili/elethis-cipher", branch = 'main' } #dnd-rolltable = { git = "https://github.com/evilchili/dnd-rolltable", branch = 'main' } dnd-rolltable = { file = "../../dnd-rolltable/dist/dnd_rolltable-1.1.9-py3-none-any.whl" } diff --git a/deadsands/site_tools/shell/interactive_shell.py b/deadsands/site_tools/shell/interactive_shell.py index 2881c13..cdb0cb1 100644 --- a/deadsands/site_tools/shell/interactive_shell.py +++ b/deadsands/site_tools/shell/interactive_shell.py @@ -8,6 +8,8 @@ from rolltable.tables import RollTable from site_tools.shell.base import BasePrompt, command +from npc.generator.base import generate_npc + BINDINGS = KeyBindings() @@ -26,6 +28,7 @@ class DMShell(BasePrompt): [ ("", " [?] Help "), ("", " [F2] Wild Magic Table "), + ("", " [F3] NPC"), ("", " [^Q] Quit "), ] ) @@ -44,6 +47,50 @@ class DMShell(BasePrompt): def wmt(event): self.wmt() + @self.key_bindings.add("f3") + def npc(event): + self.npc() + + @command(usage=""" + [title]NPC[/title] + + Generate a randomized NPC commoner. + + [title]USAGE[/title] + + [link]> npc \\[ANCESTRY\\][/link] + + [title]CLI[/title] + + [link]npc --ancestry ANCESTRY[/link] + """, completer=WordCompleter( + [ + 'human', + 'dragon', + 'drow', + 'dwarf', + 'elf', + 'highelf', + 'halfling', + 'halforc', + 'tiefling', + 'hightiefling', + ] + )) + def npc(self, parts=[]): + """ + Generate an NPC commoner + """ + c = generate_npc(ancestry=parts[0] if parts else None) + self.console.print("\n".join([ + "", + f"{c.description}", + f"Personality: {c.personality}", + f"Flaw: {c.flaw}", + f"Goal: {c.goal}", + "", + ])) + @command(usage=""" [title]QUIT[/title] @@ -104,7 +151,14 @@ class DMShell(BasePrompt): [link]loc LOCATION[/link] """, - completer=WordCompleter(["The Blooming Wastes", "Dust River Canyon", "Gopher Gulch", "Calamity Ridge"]), + completer=WordCompleter( + [ + "The Blooming Wastes", + "Dust River Canyon", + "Gopher Gulch", + "Calamity Ridge" + ] + ), ) def loc(self, parts=[]): """ @@ -144,7 +198,7 @@ class DMShell(BasePrompt): sources/sahwat_magic_table.yaml \\ --frequency default --die 20[/link] """) - def wmt(self, *parts, source="sahwat_magic_table.yaml"): + def wmt(self, parts=[], source="sahwat_magic_table.yaml"): """ Generate a Wild Magic Table for resolving spell effects. """