From 08aa49d727b88f1e7cfb91194829f3667fe7d55a Mon Sep 17 00:00:00 2001 From: Russell Champoux Date: Sat, 24 Jul 2021 21:55:53 -0400 Subject: [PATCH] Add kingdom, place, and region rollers --- src/App.svelte | 10 ++++-- .../KingdomRoller.svelte} | 0 src/rollers/PlaceRoller.svelte | 30 ++++++++++++++++++ src/rollers/RegionRoller.svelte | 30 ++++++++++++++++++ src/{ => rollers}/data.ts | 31 +++++++++++++++++++ src/rollers/utils.ts | 14 +++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) rename src/{Roller.svelte => rollers/KingdomRoller.svelte} (100%) create mode 100644 src/rollers/PlaceRoller.svelte create mode 100644 src/rollers/RegionRoller.svelte rename src/{ => rollers}/data.ts (66%) create mode 100644 src/rollers/utils.ts diff --git a/src/App.svelte b/src/App.svelte index 60ad9d1..8e54572 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,10 +1,16 @@

Sup world?

- + +
+ +
+
diff --git a/src/rollers/RegionRoller.svelte b/src/rollers/RegionRoller.svelte new file mode 100644 index 0000000..c2ab4a6 --- /dev/null +++ b/src/rollers/RegionRoller.svelte @@ -0,0 +1,30 @@ + + +
+

Random Regions

+ + + {#each rollResults as result} +

{result.timestamp}: {result.value}

+ {/each} +
+ + diff --git a/src/data.ts b/src/rollers/data.ts similarity index 66% rename from src/data.ts rename to src/rollers/data.ts index 3466217..de63a72 100644 --- a/src/data.ts +++ b/src/rollers/data.ts @@ -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)',] }, }; + +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. +}; diff --git a/src/rollers/utils.ts b/src/rollers/utils.ts new file mode 100644 index 0000000..a5b2c89 --- /dev/null +++ b/src/rollers/utils.ts @@ -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; + }); +} \ No newline at end of file