Add kingdom, place, and region rollers

This commit is contained in:
RussellChamp committed 2021-07-24 21:55:53 -04:00
1 parent 749986c5c2
commit 08aa49d727
6 files changed
+113 -2

No files matched your search

+8 -2
View File
@@ -1,10 +1,16 @@
<script lang="ts"> <script lang="ts">
import Roller from "./Roller.svelte"; import KingdomRoller from "./rollers/KingdomRoller.svelte";
import RegionRoller from "./rollers/RegionRoller.svelte";
import PlaceRoller from "./rollers/PlaceRoller.svelte";
</script> </script>
<main> <main>
<h1>Sup world?</h1> <h1>Sup world?</h1>
<Roller /> <KingdomRoller />
<hr />
<RegionRoller />
<hr />
<PlaceRoller />
</main> </main>
<style> <style>
File renamed without changes.
+30
View File
@@ -0,0 +1,30 @@
<script lang="ts">
import { places } from "./data";
import * as _ from "lodash";
import { format as formatDate } from "date-fns";
import { bodgeString } from "./utils";
export let rollResults: { value: string; timestamp: string }[] = [];
function addResult(result: string) {
rollResults = [{ value: result, timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
}
function roll(event: Event) {
let template = _.sample(places.templates);
addResult(bodgeString(template, places));
}
</script>
<main>
<h1>Random Places</h1>
<button type="button" class="btn btn-primary" on:click={roll}>Roll Region</button>
{#each rollResults as result}
<h3>{result.timestamp}: {result.value}</h3>
{/each}
</main>
<style>
</style>
+30
View File
@@ -0,0 +1,30 @@
<script lang="ts">
import { regions } from "./data";
import * as _ from "lodash";
import { format as formatDate } from "date-fns";
import { bodgeString } from "./utils";
export let rollResults: { value: string; timestamp: string }[] = [];
function addResult(result: string) {
rollResults = [{ value: result, timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
}
function roll(event: Event) {
let template = _.sample(regions.templates);
addResult(bodgeString(template, regions));
}
</script>
<main>
<h1>Random Regions</h1>
<button type="button" class="btn btn-primary" on:click={roll}>Roll Region</button>
{#each rollResults as result}
<h3>{result.timestamp}: {result.value}</h3>
{/each}
</main>
<style>
</style>
+31
View File
@@ -36,3 +36,34 @@ export const kingdoms = {
mount: ['Anginu (North Wind)', 'Api (Blaze)', 'Bakat (Felicity)', 'Bakti (Loyal)', 'Beruntung (Lucky)', 'Bilah (Blade)', 'Biru (Blue)', 'Gemetar (Quiver)', 'Guntur (Thunder)', 'Hidungi (Black Nose)', 'Janda (Widow)', 'Kakicerah (Bright Foot)', 'Kakiring (Light Foot)', 'Keriangan (Sunshine)', 'Kunang (Firefly)', 'Lapar (Hungry)', 'Murni (Pure)', 'Paruh (Bill)', 'Penebus (Avenger)', 'Penyelemat (Savior)', 'Prajurit (Warrior)', 'Rusak (Broken)', 'Satucep (Fast One)', 'Setia (True Heart)', 'Tahanla (Durable)',] mount: ['Anginu (North Wind)', 'Api (Blaze)', 'Bakat (Felicity)', 'Bakti (Loyal)', 'Beruntung (Lucky)', 'Bilah (Blade)', 'Biru (Blue)', 'Gemetar (Quiver)', 'Guntur (Thunder)', 'Hidungi (Black Nose)', 'Janda (Widow)', 'Kakicerah (Bright Foot)', 'Kakiring (Light Foot)', 'Keriangan (Sunshine)', 'Kunang (Firefly)', 'Lapar (Hungry)', 'Murni (Pure)', 'Paruh (Bill)', 'Penebus (Avenger)', 'Penyelemat (Savior)', 'Prajurit (Warrior)', 'Rusak (Broken)', 'Satucep (Fast One)', 'Setia (True Heart)', 'Tahanla (Durable)',]
}, },
}; };
export const regions = {
templates: [
'[ADJECTIVE] [TERRAIN]',
'[TERRAIN] of (the) [NOUN]',
'The [TERRAIN] [ADJECTIVE]',
'[NOUN] [TERRAIN]',
'[NOUN]\'s [ADJECTIVE] [TERRAIN]',
'[ADJECTIVE] [TERRAIN] of (the) [NOUN]'
],
terrain: ['Bay', 'Bluffs', 'Bog', 'Cliffs', 'Desert', 'Downs', 'Dunes', 'Expanse', 'Fells', 'Fen', 'Flats', 'Foothills', 'Forest', 'Groves', 'Heath', 'Heights', 'Hills', 'Hollows', 'Jungle', 'Lake', 'Lowland', 'March', 'Marsh', 'Meadows', 'Moor', 'Morass', 'Mounds', 'Mountains', 'Peaks', 'Plains', 'Prairie', 'Quagmire', 'Range', 'Reach', 'Sands', 'Savanna', 'Scarps', 'Sea', 'Slough', 'Sound', 'Steppe', 'Swamp', 'Sweep', 'Teeth', 'Thicket', 'Upland', 'Wall', 'Waste', 'Wasteland', 'Woods',],
adjective: ['Ageless', 'Ashen', 'Black', 'Blessed', 'Blighted', 'Blue', 'Broken', 'Burning', 'Cold', 'Cursed', 'Dark', 'Dead', 'Deadly', 'Deep', 'Desolate', 'Diamond', 'Dim', 'Dismal', 'Dun', 'Eerie', 'Endless', 'Fallen', 'Far', 'Fell', 'Flaming', 'Forgotten', 'Forsaken', 'Frozen', 'Glittering', 'Golden', 'Green', 'Grim', 'Holy', 'Impassable', 'Jagged', 'Light', 'Long', 'Misty', 'Perilous', 'Purple', 'Red', 'Savage', 'Shadowy', 'Shattered', 'Shifting', 'Shining', 'Silver', 'White', 'Wicked', 'Yellow',],
noun: ['[NAME]', 'Ash', 'Bone', 'Darkness', 'Dead', 'Death', 'Desolation', 'Despair', 'Devil', 'Doom', 'Dragon', 'Fate', 'Fear', 'Fire', 'Fury', 'Ghost', 'Giant', 'God', 'Gold', 'Heaven', 'Hell', 'Honor', 'Hope', 'Horror', 'King', 'Life', 'Light', 'Lord', 'Mist', 'Peril', 'Queen', 'Rain', 'Refuge', 'Regret', 'Savior', 'Shadow', 'Silver', 'Skull', 'Sky', 'Smoke', 'Snake', 'Sorrow', 'Storm', 'Sun', 'Thorn', 'Thunder', 'Traitor', 'Troll', 'Victory', 'Witch',]
// * Choose a name appropriate to your setting; or, if you have a name list, roll one up. Dw THE MAP
};
export const places = {
templates: [
'The [PLACE]',
'The [ADJECTIVE] [PLACE]',
'The [PLACE] of (the) [NOUN]',
'(The) [NOUN]\'s [PLACE]',
'[PLACE] of the [ADJECTIVE] [NOUN]',
'The [ADJECTIVE] [NOUN]'
],
place: ['Barrier', 'Beach', 'Bowl', 'Camp', 'Cave', 'Circle', 'City', 'Cliff', 'Crater', 'Crossing', 'Crypt', 'Den', 'Ditch', 'Falls', 'Fence', 'Field', 'Fort', 'Gate', 'Grove', 'Hill', 'Hole', 'Hut', 'Keep', 'Lake', 'Marsh', 'Meadow', 'Mountain', 'Pit', 'Post', 'Ridge', 'Ring', 'Rise', 'Road', 'Rock', 'Ruin', 'Shrine', 'Spire', 'Spring', 'Stone', 'Tangle', 'Thmple', 'Throne', 'Tomb', 'Tower', 'Town', 'Tree', 'Vale', 'Valley', 'Village', 'Wall',],
adjective: ['Ancient', 'Ashen', 'Black', 'Bloody', 'Blue', 'Bright', 'Broken', 'Burning', 'Clouded', 'Copper', 'Cracked', 'Dark', 'Dead', 'Doomed', 'Endless', 'Fallen', 'Far', 'Fearsome', 'Floating', 'Forbidden', 'Frozen', 'Ghostly', 'Gloomy', 'Golden', 'Grim', 'Hidden', 'High', 'Iron', 'Jagged', 'Lonely', 'Lost', 'Low', 'Near', 'Petrified', 'Red', 'Screaming', 'Sharp', 'Shattered', 'Shifting', 'Shining', 'Shivering', 'Shrouded', 'Silver', 'Stalwart', 'Stoney', 'Sunken', 'Thorny', 'Thundering', 'White', 'Withered',],
noun: ['[Name]', 'Arm', 'Ash', 'Blood', 'Child', 'Cinder', 'Corpse', 'Crystal', 'Dagger', 'Death', 'Demon', 'Devil', 'Doom', 'Eye', 'Fear', 'Finger', 'Fire', 'Foot', 'Ghost', 'Giant', 'Goblin', 'God', 'Gold', 'Hand', 'Head', 'Heart', 'Hero', 'Hope', 'King', 'Knave', 'Knight', 'Muck', 'Mud', 'Priest', 'Queen', 'Sailor', 'Silver', 'Skull', 'Smoke', 'Souls', 'Spear', 'Spirit', 'Stone', 'Sword', 'Thief', 'Troll', 'Warrior', 'Water', 'Witch', 'Wizard',],
// * Choose a name appropriate to your setting; or, if you have a name list, roll one up.
};
+14
View File
@@ -0,0 +1,14 @@
import { sample } from 'lodash';
export function bodgeString(template: string, dict: Object) {
// The template string will look like "The [FOO] [BAR]"
// and we will replace "FOO" and "BAR" with options in dict
// like dict.foo and dict.bar
const tagMatcher = /\[([A-Z]+)\]/g;
return String(template).replace(tagMatcher, (match, key) => {
key = String(key).toLocaleLowerCase();
let replacement = dict.hasOwnProperty(key) && Array.isArray(dict[key]) ? sample(dict[key]) : match;
return replacement;
});
}