Star Wars Dice
Copypasta
Escaped
[[span style="color:green"]]♦♦♦♦♦[[/span]]
[[span style="color:yellow"]]⬢⬢⬢⬢⬢[[/span]]
[[span style="color:#00BFFF"]] ■■■■■[[/span]]
[[span style="color:black"]]⬡⬡⬡⬡⬡[[/span]]
[[span style="color:purple"]]♦♦♦♦♦[[/span]]
[[span style="color:red"]]⬢⬢⬢⬢⬢[[/span]]
[[span style="color:black"]] ■■■■■[[/span]]
Rendered
♦♦♦♦♦
⬢⬢⬢⬢⬢
■■■■■
⬡⬡⬡⬡⬡
♦♦♦♦♦
⬢⬢⬢⬢⬢
■■■■■
JavaScript
This is my js scratch pad to make the dice mechanics work inline.
// I don't think Wikidot's javascript has string interpolation; that's fine, I'm hosting this externally <script type="text/javascript"> // colors, because names are hard function green (count) { return ability(count); }; function yellow (count) { return proficiency(count); }; function blue (count) { return boost(count); }; function purple (count) { return difficulty(count); }; function red (count) { return challenge(count); }; function black (count) { return setback(count); }; function white (count) { return force(count); }; // names, because colors are for noobs function ability (count) { let dice = diamond(count); return `[[span style="color:green"]]${dice}[[/span]]`; }; function proficiency (count) { let dice = hexagon(count); return `[[span style="color:yellow"]]${dice}[[/span]]`; }; function difficulty (count) { let dice = diamond(count); return `[[span style="color:purple"]]${dice}[[/span]]`; }; function boost (count) { let dice = square(count); return `[[span style="color:#00BFFF"]]${dice}[[/span]]`; }; function challenge (count) { let dice = hexagon(count); return `[[span style="color:red"]]${dice}[[/span]]`; }; function setback (count) { let dice = diamond(count); return `[[span style="color:black"]]${dice}[[/span]]`; }; function force (count) { let dice = emptyhex(count); return `[[span style="color:black"]]${dice}[[/span]]`; }; // shapes, because everything has a twin; should these be recursive? function diamond (count) { switch (count) { case 1: return "♦"; case 2: return "♦♦"; case 3: return "♦♦♦"; case 4: return "♦♦♦♦"; case 5: return "♦♦♦♦♦"; } }; function hexagon (count) { switch (count) { case 1: return "⬢"; case 2: return "⬢⬢"; case 3: return "⬢⬢⬢"; case 4: return "⬢⬢⬢⬢"; case 5: return "⬢⬢⬢⬢⬢"; } }; function emptyhex (count) { switch (count) { case 1: return "⬡"; case 2: return "⬡⬡"; case 3: return "⬡⬡⬡"; case 4: return "⬡⬡⬡⬡"; case 5: return "⬡⬡⬡⬡⬡"; } }; // the rendered result isn't monospaced function square (count) { switch (count) { case 1: return "■"; case 2: return "■■"; case 3: return "■■■"; case 4: return "■■■■"; case 5: return "■■■■■"; } }; </script>
page revision: 14, last edited: 23 Jul 2021 13:54