adding sand strider npc generator

This commit is contained in:
evilchili 2023-12-16 11:55:58 -08:00
parent 91fa27b86e
commit 2252a98798
3 changed files with 96 additions and 11 deletions

View File

@ -28,7 +28,7 @@
{% set target = article.title.replace(' ', '_') %}
{% if self.is_dm() or article.show_dm_content %}
<div class='location'>
<div class='location statblock'>
<div style='cursor: pointer;'
onclick="document.getElementById('{{target}}').style.display=((document.getElementById('{{ target }}').style.display=='none')?'':'none');" ><h3>{{ article.title }}</h3></div>
<div id="{{ target }}" style='display:none;'>

View File

@ -9,6 +9,7 @@ from rolltable.tables import RollTable
from site_tools.shell.base import BasePrompt, command
from site_tools import campaign
from site_tools import jobs
from site_tools import striders
from reckoning.calendar import TelisaranCalendar
from reckoning.telisaran import Day
@ -19,6 +20,7 @@ import npc
BINDINGS = KeyBindings()
ANCESTRY_PACK, ANCESTRIES = npc.load_ancestry_pack()
ANCESTRIES['strider'] = striders
class DMShell(BasePrompt):
@ -211,16 +213,14 @@ class DMShell(BasePrompt):
"""
Generate an NPC commoner
"""
char = npc.random_npc([parts[0]] if parts else [])
self.console.print(char.ancestry.capitalize())
self.console.print("\n".join([
"",
f"{char.description}",
f"Personality: {char.personality}",
f"Flaw: {char.flaw}",
f"Goal: {char.goal}",
"",
]))
char = npc.random_npc([ANCESTRIES[parts[0]]] if parts else [])
self.console.print(char.description + "\n")
if char.personality:
self.console.print(f"Personality: {char.personality}\n")
if char.flaw:
self.console.print(f"Flaw: {char.flaw}\n")
if char.goal:
self.console.print(f"Goal: {char.goal}\n")
@command(usage="""
[title]QUIT[/title]

View File

@ -0,0 +1,85 @@
import random
import textwrap
from functools import cached_property
import npc
from language import types
from language.languages import lizardfolk
subspecies = [
('black', 'acid'),
('red', 'fire'),
('blue', 'lightning'),
('green', 'poison'),
('white', 'frost')
]
ages = types.WeightedSet(
('wyrmling', 0.2),
('young', 1.0),
('adult', 1.0),
('ancient', 0.5)
)
class SandStriderNameGenerator(types.NameGenerator):
def __init__(self):
super().__init__(
language=lizardfolk.Language,
templates=types.NameSet(
(types.NameTemplate("name,name"), 1.0),
),
)
class NPC(npc.types.NPC):
language = lizardfolk
has_tail = True
has_horns = True
def __init__(self):
super().__init__(self)
self._personality = ''
self._flaw = ''
self._goal = ''
@cached_property
def name(self) -> str:
return str(SandStriderNameGenerator())
@cached_property
def fullname(self) -> str:
return self.name
@cached_property
def age(self) -> str:
return ages.random()
@cached_property
def subspecies(self) -> tuple:
return random.choice(subspecies)
@cached_property
def color(self) -> str:
return self.subspecies[0]
@cached_property
def spit(self) -> str:
return self.subspecies[1]
@property
def description(self) -> str:
return (
f"{self.name} is {npc.types.a_or_an(self.age)} {self.age} {self.color} sand strider "
f"with {self.horns} horns, {npc.types.a_or_an(self.nose)} {self.nose} snout, "
f"{self.body} body, and {self.tail} tail. {self.name} spits {self.spit}."
)
@property
def character_sheet(self) -> str:
return '\n'.join(textwrap.wrap(self.description, width=120))