X-Git-Url: https://git.yukkurigames.com/?p=heroik.git;a=blobdiff_plain;f=scenarios.js;h=25baf66889cd6ff431c2fe18050b10e54bf5f6ed;hp=315cba82f1e38e5ab05b393f8aeee9c8ad70781e;hb=12e70756fab6e3745aa153e7e2a9230e08df278f;hpb=2f71b2af4b70b31aeb4ff014d28b95449db0efc3 diff --git a/scenarios.js b/scenarios.js index 315cba8..25baf66 100644 --- a/scenarios.js +++ b/scenarios.js @@ -59,7 +59,7 @@ var EVENTS = [ // Events from Sean Allen's random scenario generator. // http://boardgamegeek.com/filepage/57107/random-scenario-generator { name: "Fire from above.", - effect: "Dragons gains a bonus of +1 Strength.", + effect: "Dragons gain a bonus of +1 Strength.", requires: ["dragons", "noncanonical"], unique: true }, { name: "Bad dreams.", @@ -67,14 +67,14 @@ var EVENTS = [ requires: ["noncanonical"], unique: true }, { name: "Backs against the wall.", - effect: "Any monster with a Tenacity token is also Fierce.", + effect: "Any monster with a Tenacity token is also Fierce.", requires: ["noncanonical"], unique: true }, { name: "Dead end.", action: "Shuffle the remaining corridors together and redistribute the cards as if you were setting up the game.", requires: ["noncanonical"] }, { name: "Surrounded.", - effect: "All monsters have Supremacy.", + effect: "All monsters have Supremacy.", requires: ["noncanonical"], unique: true }, @@ -115,7 +115,7 @@ var EVENTS = [ action: "Randomly discard four of your defeated dungeon cards.", requires: ["noncanonical"] }, { name: "Adamantine armor.", - effect: "All monsters gain Immunity 1.", + effect: "All monsters gain Immunity 1.", requires: ["noncanonical"], unique: true }, { name: "Normative assumptions.", @@ -123,7 +123,7 @@ var EVENTS = [ requires: ["noncanonical"], unique: true }, { name: "Infighting.", - effect: "Greenskins have Undead +1 and Demons -1. Demons have Greenskins +1 and Undead -1. Undead have Greenskins -1 and Demons +1.", + effect: "Greenskins have Undead +1, Demons -1. Demons have Greenskins +1, Undead -1. Undead have Demons +1, Greenskins -1.", requires: ["noncanonical"], unique: true }, ]; @@ -192,13 +192,39 @@ function randomizeName () { var events = []; var style; -window.addEventListener('DOMContentLoaded', function () { + +function generateScenario () { var parts = location.hash.slice(1).split(','); events = generate(parts, parts.shift() | 0, parts.shift() | 0); style = document.createElement("style"); document.head.appendChild(style); randomizeName(); -}); +} + +function getEvents (matcher) { + return EVENTS.filter(matcher); +} + +function wrapRow (row) { + return "" + row + ""; +} + +function iscanonical (event) { + return !isnoncanonical(event); +} +function isnoncanonical (event) { + return ~(event.requires || []).indexOf('noncanonical'); +} + +function canonicalToHTML (sender) { + sender.innerHTML = EVENTS.filter(iscanonical) + .map(toHTML).sort().map(wrapRow).join(''); +} + +function noncanonicalToHTML (sender) { + sender.innerHTML = EVENTS.filter(isnoncanonical) + .map(toHTML).sort().map(wrapRow).join(''); +} function nextEvent (sender) { if (!events.length) {