Add rolltable support, fix regions

This commit is contained in:
evilchili 2022-08-06 21:22:47 -07:00
parent 9e960cb251
commit 24a36e3096
10 changed files with 143 additions and 86 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

@ -12,40 +12,51 @@ region:
terrain: difficult terrain: difficult
description: | description: |
The Blooming Wastes stretch out before you: a mostly flat expanse of hard, cracked earth blanketed by some kind of sandy brown scrub. Small mesas dot the horizon, suggesting the possibility of shelter. As you approach you see that the scrub is covered in thick black thorns sharp enough to pierce boot leather; you will need to tread carefully. The Blooming Wastes stretch out before you: a mostly flat expanse of hard, cracked earth blanketed by some kind of sandy brown scrub. Small mesas dot the horizon, suggesting the possibility of shelter. As you approach you see that the scrub is covered in thick black thorns sharp enough to pierce boot leather; you will need to tread carefully.
travel: skills:
dc: 10 travel:
forage: DC: 10
dc: 10 Notes:
resources: redfoot, moon blossom (night only) forage:
track: DC: 10
dc: 13 Notes: redfoot, moon blossom (night only)
resources: shelter, water track:
evade: DC: 13
dc: 2 Notes: shelter, water
survey: evade:
dc: 13 DC: 2
Notes:
survey:
DC: 13
Notes:
cr: 4 cr: 4
encounters: encounters:
d1-d4: Easy d1-d4:
d5: Dangerous Difficulty: Easy
d6: Deadly d5:
d7-d20: None Difficulty: Dangerous
d6:
Difficulty: Deadly
d7-d20:
Difficulty: No Encounter
regional_effects: regional_effects:
d1: Add 1d6 to radiant damage - Add 1d6 to radiant damage
d2: Nightvision not functional - Nightvision not functional
d3: When a spell attack misses, it hits a random creature within 5 feet instead - When a spell attack misses, it hits a random creature within 5 feet instead
d4: On a spell attack critical hit or miss, roll on the Wild Magic Table - On a spell attack critical hit or miss, roll on the Wild Magic Table
d5: 1d4 piercing damage for every 30ft of movement during the Dash action - 1d4 piercing damage for every 30ft of movement during the Dash action
d6: No Effect
weather: weather:
d1: Scorching Temperatures - 2x water consumption d1-d5:
d2: Hail (no effect - counts as magical water if consumed) Description: Clear Skies
d3: Ghostly Wailing - Disadvantage on concentration checks Effect: No Effect
d4: Low Oxygen - Disadvantage on STR Athletics checks and saves d6:
d5: Extra Gravity - Disadvantage on DEX checks and saves Description: Scorching Temperatures
d6: Hot Metal Storm - Heat Metal spell effects for half-day Effect: 2x water consumption
d7: Bubble Rain - Bubbles rain upwards, obscuring vision; disadvantage on perception checks d7:
d8: Clear Skies (No effect) Description: Hot Metal Storm
Effect: Heat Metal spell effects for half-day
d8:
Description: Bubble Rain
Effect: Bubbles rain upwards, obscuring vision; disadvantage on perception checks
--- ---
A mostly flat expanse of hard-packed earth blanked by redfoot, a hardy, sandy-brown moss covered in sharp thorns. At night glowing clusters of moon blossoms emerge from the earth and open their petals, bathing the entire wasteland in a pale, silvery light. A mostly flat expanse of hard-packed earth blanked by redfoot, a hardy, sandy-brown moss covered in sharp thorns. At night glowing clusters of moon blossoms emerge from the earth and open their petals, bathing the entire wasteland in a pale, silvery light.

View File

@ -678,6 +678,10 @@ a.disabled:hover {
.statblock table tr td:first-of-type { .statblock table tr td:first-of-type {
font-weight: bold; font-weight: bold;
} }
.statblock table tr td:first-child:nth-last-child(1) {
font-weight: normal;
}
.statblock table tr:last-child, .statblock table tr:last-child,
.statblock table tr:last-child { .statblock table tr:last-child {
padding-right: 1em; padding-right: 1em;

View File

@ -6,11 +6,21 @@
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro rolltable(t) %} {% macro list_to_cols(l, headers) %}
{% if l is mapping %}
{% for key in l if key in headers%}
{{ list_to_cols(l[key], headers) }}
{% endfor %}
{% else %}
<td>{{ l if l else "" }}</td>
{% endif %}
{% endmacro %}
{% macro table(t, headers=[]) %}
<table> <table>
<tr><th>Roll</th><th>Effect</th></tr> <tr>{% for h in headers %}{% if h %}<th>{{ h }}</th>{% endif %}{% endfor %}</tr>
{% for die in t %} {% for key in t %}
<tr><td>{{ die }}</td><td>{{ t[die] }}</td></tr> <tr><td>{{ key }}</td>{{ list_to_cols(t[key], headers) }}</tr>
{% endfor %} {% endfor %}
</table> </table>
{% endmacro %} {% endmacro %}

View File

@ -30,29 +30,13 @@
<dl> <dl>
<dt>Size</dt><dd>{{ r.size }} sq. miles </dd> <dt>Size</dt><dd>{{ r.size }} sq. miles </dd>
<dt>Terrain</dt><dd>{{ r.terrain }} (walking: {{ r.size / 10 if r.terrain == 'difficult' else 20 |round }} days)</dd> <dt>Terrain</dt><dd>{{ r.terrain }} (walking: {{ r.size / 10 if r.terrain == 'difficult' else 20 |round }} days)</dd>
<dt>Skill Challenges</dt><dd> <dt>Regional Effects</dt><dd>{{ macros.table(r.regional_effects) }}</dd>
<table> <dt>Skill Challenges</dt><dd>{{ macros.table(r.skills, ['Skills', 'DC', 'Notes']) }}</dd>
<tr> <dt>Encounters (CR {{r.cr}})</dt><dd>{{ macros.table(r.encounters, ['Roll', 'Difficulty']) }}</dd>
<th>Skill</td> <dt>Weather Effects</dt><dd>{{ macros.table(r.weather, ['Roll', None, 'Description', 'Effect']) }}</dd>
<th style='text-align: right;'>DC</th>
<th>Resources</th>
</tr>
{% for (k, v) in [ ('Travel', r.travel), ('Forage', r.forage), ('Track', r.track), ('Evade', r.evade), ('Survey', r.survey) ] %}
<tr>
<td>{{ k }}</td>
<td style='text-align: right;'>{{ v.dc or ""}}</td>
<td>{{ v.resources or ""}}</td>
</tr>
{% endfor %}
</table>
</dd>
<dt>Encounters (CR {{r.cr}})</dt><dd>{{ macros.rolltable(r.encounters) }}</dd>
<dt>Regional Effects</dt><dd>{{ macros.rolltable(r.regional_effects) }}</dd>
<dt>Weather Effects</dt><dd>{{ macros.rolltable(r.weather) }}</dd>
</dl> </dl>
</div> </div>
</div> </div>
<hr> <hr>
{% include "bottom-nav.html" %} {% include "bottom-nav.html" %}
</div> </div>

View File

@ -3,53 +3,45 @@
title: {{ title }} title: {{ title }}
author: {{ author if author else 'evilchili' }} author: {{ author if author else 'evilchili' }}
tags: {{ tags }} tags: {{ tags or 'region'}}
{% if date %} {% if date %}
date: {{ date }} date: {{ date }}
{% endif %} {% endif %}
category: regions
template: region template: region
{% if summary %} {% if summary %}
summary: {{summary}} summary: {{summary}}
{% endif %} {% endif %}
region: region:
name: {{ title }} name: {{ title }}
size: 10 size: 10
terrain: difficult terrain: difficult
shelter: none description: |
water_source: none description
skills:
travel: travel:
dc: 10 dc: 10
critical_success: notes:
critical_fail:
forage: forage:
dc: 10 dc: 10
critical_success: notes:
critical_fail:
track: track:
dc: 10 dc: 10
critical_success: notes:
critical_fail:
evade: evade:
dc: 10 dc: 10
critical_success: notes:
critical_fail:
survey: survey:
dc: 10 dc: 10
critical_success: notes:
critical_fail: cr: 4
encounter_chance: 5 encounters:
special: {% rolltable ['encounters'], indent=4 %}
weather: weather:
d1: {% rolltable ['weather'], indent=4 %}
d2: regional_effects:
d3: -
d4: -
d5:
d6:
d7:
d8:
status: {{ status if status else 'draft' }} status: {{ status if status else 'draft' }}
--- ---
Region description goes here. DM's region notes goes here.

View File

@ -16,6 +16,7 @@ typer = "latest"
rich = "latest" rich = "latest"
pyyaml = "latest" pyyaml = "latest"
livereload = "latest" livereload = "latest"
jinja2-simple-tags = "latest"
# static website # static website
pelican = "^4.7.2" pelican = "^4.7.2"
@ -24,9 +25,10 @@ pelican-sitemap = "^1.0.2"
pelican-yaml-metadata = { git = "https://github.com/pR0Ps/pelican-yaml-metadata.git", branch = "cdc1b9708916410e455e8e258e3d39a9d575c7b5" } pelican-yaml-metadata = { git = "https://github.com/pR0Ps/pelican-yaml-metadata.git", branch = "cdc1b9708916410e455e8e258e3d39a9d575c7b5" }
# local wotsits # local wotsits
dnd-rolltable = { git = "https://github.com/evilchili/dnd-rolltable", branch = 'main' }
dnd-npcs = { git = "https://github.com/evilchili/dnd-npcs", branch = 'main' } dnd-npcs = { git = "https://github.com/evilchili/dnd-npcs", branch = 'main' }
elethis-cipher= { git = "https://github.com/evilchili/elethis-cipher", branch = 'main' } 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.3-py3-none-any.whl" }
[tool.poetry.scripts] [tool.poetry.scripts]
site = "site_tools.cli:app" site = "site_tools.cli:app"

View File

@ -21,10 +21,12 @@ def create(content_type: str, title: str, template_dir: str,
if not (template_path / template_name).exists(): if not (template_path / template_name).exists():
template_name = 'default.md' template_name = 'default.md'
print("Not found. Using default markdown template.") print("Not found. Using default markdown template.")
template_source = Environment( env = Environment(
loader=FileSystemLoader(template_path), loader=FileSystemLoader(template_path),
trim_blocks=True, trim_blocks=True,
).get_template(template_name) )
env.add_extension('site_tools.extensions.RollTable')
template_source = env.get_template(template_name)
target_filename = _slugify(title) + '.md' target_filename = _slugify(title) + '.md'

View File

@ -0,0 +1,13 @@
import textwrap
from rolltable.tables import RollTable as _RT
from jinja2_simple_tags import StandaloneTag
from pathlib import Path
class RollTable(StandaloneTag):
tags = {"rolltable"}
def render(self, sources, frequency='default', die=8, indent=0, **kwargs):
rt = _RT([Path(f'sources/{s}.yaml').read_text() for s in sources],
frequency=frequency, die=die)
return textwrap.indent(rt.as_yaml(), ' ' * indent)

View File

@ -0,0 +1,39 @@
metadata:
headers:
- Difficulty
frequencies:
default:
None: 0.7
Easy: 0.1
Difficult: 0.1
Dangerous: 0.05
Deadly: 0.05
easy:
None: 0.5
Easy: 0.3
Difficult: 0.1
Dangerous: 0.05
Deadly: 0.05
difficult:
None: 0.5
Easy: 0.1
Difficult: 0.3
Dangerous: 0.05
Deadly: 0.05
dangerous:
None: 0.5
Easy: 0.05
Difficult: 0.1
Dangerous: 0.3
Deadly: 0.05
deadly:
None: 0.5
Easy: 0.05
Difficult: 0.05
Dangerous: 0.1
Deadly: 0.3
None:
Easy:
Difficult:
Dangerous:
Deadly: