-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (38 loc) · 2.54 KB
/
script.js
File metadata and controls
50 lines (38 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const fillers = {
// adventurer: ["My dude", "Bro", "Adventurer", "Traveller", "Fellow", "Citizen", "Ashen One", "Dragonborn", "Cool person", "Tarnished", "$adventurer and $adventurer", "$adventurer, $adventurer, and $adventurer", "Geoff"],
adventurer: ["Eminem", "J. Cole", "Logic", "Kendrick Lamar", "Jack Harlow", "Joyner Lucas", "$adventurer along with $adventurer", "$adventurer and $adventurer", "$adventurer, $adventurer, and $adventurer"],
pre: ["Fra", "Tro", "Gre", "Pan", "Ast", "Ara"],
post: ["gria", "ston", "gott","-on-the-lee", "ora", "Ara", "uwu"],
people: ["kindly", "meek", "brave", "wise", "sacred", "cherished", "honored", "forgotten", "apathetic", "mystic", "orca"],
item: ["axe", "staff", "book", "cloak", "shield", "club", "sword", "magic gloves", "galvel", "fists", "mace", "potato"],
num: ["two", "three", "eleven", "so many", "too many", "an unsatisfying number of", "barely any", "an unspecified amount of", "surely a satisfactory number of"],
looty: ["gleaming", "valuable", "esteemed", "rare", "exalted", "scintillating", "kinda gross but still usefull", "complete garbage"],
loots: ["coins", "chalices", "ingots", "hides", "victory points", "gems","scrolls", "bananas", "noodles", "goblins", "CS Majors", "college credits"],
baddies: ["orcs", "glubs", "fishmen", "cordungles", "mountain trolls", "college professors", "dragon", "evil $adventurer", "agents of chaos"],
message: ["call", "txt", "post", "decree", "shoutz", "tweets", "choiche", "hearkens", "harkening", "harkenening", "harkenenening", "...wait, no! Come back", "Watermelon"],
};
const template = `$adventurer, heed my $message!
I have just come from $pre$post where the $people folk are in desperate need. Their town has been overrun by $baddies. You must venture forth at once, taking my $item, and help them.
It is told that the one who can rescue them will be awarded with $num $looty $loots. Surely this must tempt one such as yourself!
`;
// STUDENTS: You don't need to edit code below this line.
const slotPattern = /\$(\w+)/;
function replacer(match, name) {
let options = fillers[name];
if (options) {
return options[Math.floor(Math.random() * options.length)];
} else {
return `<UNKNOWN:${name}>`;
}
}
function generate() {
let story = template;
while (story.match(slotPattern)) {
story = story.replace(slotPattern, replacer);
}
/* global box */
box.innerText = story;
}
/* global clicker */
clicker.onclick = generate;
generate();