1 /* The person who associated a work with this deed has dedicated the
2 work to the public domain by waiving all of his or her rights to
3 the work worldwide under copyright law, including all related and
4 neighboring rights, to the extent allowed by law.
6 You can copy, modify, distribute and perform the work, even for
7 commercial purposes, all without asking permission.
9 See https://creativecommons.org/publicdomain/zero/1.0/ for details.
15 { name
: "The Greenskins are mobilized.",
16 effect
: "Greenskins gain a bonus of +1 Strength." },
17 { name
: "Big eye is watching you.",
18 effect
: "Bubbleyes gain a bonus of +1 Strength.",
19 requires
: ["bubbleyes"] },
20 { name
: "General invocation.",
21 effect
: "Demons gain a bonus of +1 Strength.",
22 requires
: ["demons"] },
23 { name
: "Stronger than ever.",
24 effect
: "Undead gain a bonus of +1 Strength.",
25 requires
: ["undead"] },
26 { name
: "Encounter with Abunakkashi.",
27 effect
: "Abunakkashii and his offspring gain a bonus of +2 Strength.",
28 requires
: ["abunakkashii"],
30 { name
: "The start of a legend.",
31 effect
: "Abunakkashii and his offspring gain a bonus of +1 Strength.",
32 requires
: ["abunakkashii"],
34 { name
: "Technological prowess.",
35 effect
: "Traps gain a bonus of +1 Strength.",
36 requires
: ["traps"] },
38 { name
: "Mental combat.",
39 effect
: "Psi monsters gain a bonus of +1 Strength.", },
40 { name
: "A cry in the night.",
41 action
: "An adventurer of your choice loses 1 Mana." },
43 action
: "Lose all your Mana tokens." },
44 { name
: "It's an ambush!",
45 action
: "Place a Tenacity token on each monster that does not have one." },
46 { name
: "The alarm is sounded.",
47 action
: "Place a Tenacity token on the weakest monster or monsters that do not already have one." },
48 { name
: "Flank attack.",
49 effect
: "Cards on either side corridor gain a bonus of +1 Strength.",
51 { name
: "Battle formation.",
52 effect
: "Cards in the central corridor(s) gain a bonus of +1 Strength.",
54 { name
: "Last bastion.",
55 effect
: "All cards gain a bonus of +1 Strength.",
58 { name
: "Destruction.",
59 action
: "All of your weapons and armor are destroyed.",
61 { name
: "Epic combat.",
62 effect
: "The Final Monster gains a bonus of +3 Strength.",
64 { name
: "Red herring.",
65 action
: "Shuffle the remaining corridors together and redistribute the cards as if you were setting up the game." },
66 { name
: "The torch has gone out.",
67 action
: "The next dungeon card is placed face-down.", },
69 { name
: "Anti-psi zone.",
70 effect
: "You do not gain Mana tokens for the next three creatures you defeat, even if they have a Mana icon.",
73 { name
: "Necromancy.",
74 action
: "Return a random defeated dungeon card to the lowest corridor and shuffle it." },
75 { name
: "Reanimation.",
76 action
: "Return a random defeated dungeon card to the highest corridor and shuffle it." },
78 { name
: "Malediction.",
79 action
: "Discard a quest or a magic object." },
81 { name
: "False brethren.",
82 effect
: "All Demons gain Immunity 5 and Immunity 7.",
86 { name
: "Psi assault.",
87 effect
: "You cannot use ultimate powers.",
90 { name
: "Entering an anti-magic zone.",
91 effect
: "You cannot use ultimate powers.",
94 later
: { name
: "Leaving the anti-magic zone.",
95 effect
: "You may use ultimate powers again.",
96 clear
: ["ultimates"] }
99 // Events from Sean Allen's random scenario generator.
100 // http://boardgamegeek.com/filepage/57107/random-scenario-generator
101 { name
: "Fire from above.",
102 effect
: "Dragons gain a bonus of +1 Strength.",
103 requires
: ["dragons", "noncanonical"],
105 { name
: "Overwhelming fear.",
106 action
: "Lose 1 extra Courage token. (The dungeon does not gain another Fear token.)",
107 requires
: ["noncanonical"],
109 { name
: "Backs against the wall.",
110 effect
: "Any monster with a Tenacity token is also <strong>Fierce</strong>.",
111 requires
: ["noncanonical"],
113 { name
: "The tide has turned.",
114 effect
: "All monsters have <strong>Supremacy</strong>.",
115 requires
: ["noncanonical"],
117 { name
: "Into the darkness.",
118 effect
: "Choose one corridor. Its cards are now always placed face-down.",
119 requires
: ["noncanonical"] },
121 // Events of my own devising.
122 { name
: "Unwanted attention.",
123 effect
: "Unique monsters gain a bonus of +1 Strength.",
124 requires
: ["noncanonical"],
126 { name
: "Spiked the punch.",
127 effect
: "Greenskins have 1d8 Strength.",
128 requires
: ["noncanonical"],
130 { name
: "Twisty passages.",
131 effect
: "After defeating a card, roll a die. On an odd number its replacement is placed face-down.",
132 requires
: ["noncanonical"],
134 { name
: "Closer than you think.",
135 action
: "The dungeon gains another Fear token, and a new event occurs.",
136 requires
: ["noncanonical"],
137 another
: true, unique
: true },
138 { name
: "I thought you had it.",
139 action
: "Randomly discard four of your defeated dungeon cards.",
140 requires
: ["noncanonical"] },
141 { name
: "Adamantine armor.",
142 effect
: "All monsters gain <strong>Immunity 1</strong>.",
143 requires
: ["noncanonical"],
145 { name
: "Normative assumptions.",
146 effect
: "Effects concerning ♂ instead concern ♀, and vice versa.",
147 requires
: ["noncanonical"],
149 { name
: "Infighting.",
150 effect
: "Greenskins have <strong>Undead +1</strong>, <strong>Demons -1</strong>. Demons have <strong>Greenskins +1</strong>, <strong>Undead -1</strong>. Undead have <strong>Demons +1</strong>, <strong>Greenskins -1</strong>.",
151 requires
: ["noncanonical", "demons", "undead"],
154 effect
: "Demons have <strong>Shrouded</strong>.",
155 requires
: ["noncanonical", "demons"],
157 { name
: "Camouflage.",
158 effect
: "Greenskins have <strong>Shrouded</strong>.",
159 requires
: ["noncanonical"],
161 { name
: "Cryptic shades.",
162 effect
: "Undead have <strong>Shrouded</strong>.",
163 requires
: ["noncanonical", "undead"],
165 { name
: "Lingering smoke.",
166 effect
: "Dragons have <strong>Shrouded</strong>.",
167 requires
: ["noncanonical", "dragons"],
169 { name
: "Hypnotizing gaze.",
170 effect
: "Bubbleyes have <strong>Shrouded</strong>.",
171 requires
: ["noncanonical", "bubbleyes"],
173 { name
: "Leeched power.",
174 action
: "A random adventurer loses a Mana token.",
175 requires
: ["noncanonical"] },
180 { name
: "Nothing happens." },
181 { name
: "A draft blows down the hallway.",
182 unique
: true, requires
: ["noncanonical"] },
183 { name
: "You sneeze.",
184 unique
: true, requires
: ["noncanonical"] },
185 { name
: "There's a skittering in the distance.",
186 unique
: true, requires
: ["noncanonical"] },
187 { name
: "The torch flickers.",
188 unique
: true, requires
: ["noncanonical"] },
189 { name
: "Shadows dance across the walls.",
190 unique
: true, requires
: ["noncanonical"] },
194 { name
: "It cuts both ways.",
195 action
: "Next time you roll a 1, put a Tenacity token on all face-up monsters and roll again.",
196 requires
: ["helpful"] },
197 { name
: "Breached their defense.",
198 action
: "Gain 2 Courage tokens and the dungeon gains 1 Fear token and the Fate Chart advances; <em>or</em> gain 1 Mana token.",
199 requires
: ["helpful"], unique
: true },
200 { name
: "Mana ritual.",
201 action
: "Discard up to 2 Mana tokens. For each one discarded, gain 1 Courage token.",
202 requires
: ["helpful"] }
205 var LOSE
= { name
: "Your adventuring party is defeated!" };
207 function randrange (a
, b
) {
208 return a
+ (Math
.random() * (b
- a
)) | 0;
211 function generate (flags
, events
, nop
) {
219 function pend (event
, i
) {
220 while (pending
[i
]) ++i
224 function canStillHappen (event
) {
225 return issubset(event
.requires
|| [], flags
)
226 && !(event
.unique
&& contains
.call(chosen
, event
))
227 && !(event
.lock
&& intersects(event
.lock
|| [], locks
));
230 for (i
= 0; i
< events
; ++i
) {
231 event
= pending
.shift()
232 || choice(EVENTS
.filter(canStillHappen
));
235 pend(event
.later
, (Math
.random() * chosen
[i
].duration
) | 0);
236 locks
= locks
.concat(event
.lock
|| [])
237 .filter(not(contains
), event
.clear
|| []);
240 for (i
= 0; i
< pending
.length
; ++i
)
242 chosen
.push(pending
[i
]);
245 for (i
= 0; i
< nop
/ 2; ++i
) {
246 var helpful
= HELPFUL
.filter(canStillHappen
);
247 var neutral
= NOP
.filter(canStillHappen
);
249 randrange(0, chosen
.length
), 0,
250 choice(helpful
.length
? helpful
: neutral
));
253 for (;i
< nop
; ++i
) {
254 var neutral
= NOP
.filter(canStillHappen
);
255 chosen
.splice(randrange(0, chosen
.length
), 0, choice(neutral
));
263 function toHTML (event
) {
264 return ["<span class=fate-name>" + event
.name
+ "</span>",
266 ? "<span class=fate-action>" + event
.action
+ "</span>"
269 ? "<span class=fate-effect>" + event
.effect
+ "</span>"
274 var THEME
= ("h1 { color: hsl(XXX, 25%, 75%); }\n\
275 h2, .button, select { border-color: hsl(XXX, 30%, 85%); }\n\
277 a:link, a:visited, a:active {\n\
278 color: hsl(XXX, 25%, 50%);\n\
281 select, .button, tbody tr:nth-last-child(odd) {\n\
282 background-color: hsl(XXX, 30%, 85%);\n\
286 select:hover, select:focus,\n\
287 .button:hover, .button:focus {\n\
288 border-color: hsl(XXX, 25%, 50%);\n\
291 function randomizeName () {
292 var name
= generateName();
293 document
.getElementById("name").textContent
= name
;
294 document
.title
= document
.title
.replace(/[^-]*-/, name
+ " -");
295 document
.head
.lastChild
.textContent
= THEME
.replace(
296 /XXX/g, (Math
.random() * 256) | 0);
302 function generateScenario () {
303 var parts
= location
.hash
.slice(1).split(',');
304 events
= generate(parts
, parts
.shift() | 0, parts
.shift() | 0);
305 style
= document
.createElement("style");
306 document
.head
.appendChild(style
);
310 function getEvents (matcher
) {
311 return EVENTS
.filter(matcher
);
314 function wrapRow (row
) {
315 return "<tr><td>" + row
+ "</td></tr>";
318 function iscanonical (event
) {
319 return !isnoncanonical(event
);
321 function isnoncanonical (event
) {
322 return ~(event
.requires
|| []).indexOf('noncanonical');
325 function canonicalToHTML (sender
) {
326 sender
.innerHTML
= EVENTS
.filter(iscanonical
)
327 .map(toHTML
).sort().map(wrapRow
).join('');
330 function noncanonicalToHTML (sender
) {
331 sender
.innerHTML
= EVENTS
.filter(isnoncanonical
)
332 .map(toHTML
).sort().map(wrapRow
).join('');
335 function nextEvent (sender
) {
336 if (!events
.length
) {
341 var event
= events
.shift();
342 var body
= document
.querySelector("#fate tbody");
343 var fate
= body
.children
.length
+ 1;
344 var tr
= document
.createElement('tr');
345 tr
.innerHTML
= "<td><div>" + fate
+ "</div></td>"
346 + "<td><div>" + toHTML(event
) + "</div></td>";
347 body
.insertBefore(tr
, body
.firstChild
);
349 if (events
.length
=== 0) {
350 sender
.textContent
= "Try Again ▲";
354 setTimeout(function () { nextEvent(sender
); }, 333);