From 1441b54b78438348df7e34a727bd3fead6690326 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 19 Dec 2023 16:19:43 +0100 Subject: Use HTML text for Arts of War cards (to improve legibility). --- tools/aow.js | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 tools/aow.js (limited to 'tools/aow.js') diff --git a/tools/aow.js b/tools/aow.js new file mode 100644 index 0000000..f58f065 --- /dev/null +++ b/tools/aow.js @@ -0,0 +1,137 @@ +const fs = require("fs") + +let buf = [] + +let cards = [] + +let SHIELD_EVT_1 = [ "L17", "L32", "L35", "Y20", "Y24", "Y26", "Y28", "Y29", "Y32", "Y33" ] +let SHIELD_EVT_2 = [ "Y20", "Y26" ] +let SHIELD_CAP_R = [ "L19", "L21", "L23", "L26", "L35", "Y24" ] +let SHIELD_CAP_2 = [ "L20", "L33", "L34", "L35", "Y14", "Y18", "Y19", "Y20", "Y23", "Y30" ] +let SHIELD_CAP_3 = [ "L18", "L19", "L27", "L37", "Y21", "Y31", "L36" ] + +function flush_card() { + function blank() { + while(buf.length > 0 && buf[0].length === 0) + buf.shift() + } + + if (buf.length === 0) + return + + let number = buf.shift() + blank() + + let evt_title = buf.shift() + let evt_subtitle = null + if (buf[0].length > 0) + evt_subtitle = buf.shift() + blank() + let evt_text = buf.shift() + blank() + + let cap_title = buf.shift() + let cap_subtitle = null + if (buf[0].length > 0) + cap_subtitle = buf.shift() + blank() + let cap_text = buf.shift() + blank() + + let card = { + number, + evt_title, evt_subtitle, evt_text, + cap_title, cap_subtitle, cap_text + } + + cards.push(card) +} + +function process_line(line) { + line = line.trim() + if (/[YL]\d+/.test(line)) { + flush_card() + buf = [] + } + buf.push(line) +} + +fs.readFileSync("tools/cards/york.txt", "utf-8").split("\n").forEach(process_line) +fs.readFileSync("tools/cards/lancaster.txt", "utf-8").split("\n").forEach(process_line) +flush_card() + + + +console.log( +` + + + + +Plantagenet - Arts of War + + + + + +`) + +let out = [] +let i = 0 +for (let c of cards) { + + if (c.evt_text.startsWith("This Levy ")) + c.evt_text = c.evt_text.replace("This Levy ", "This Levy
") + if (c.evt_text.startsWith("This Campaign ")) + c.evt_text = c.evt_text.replace("This Campaign ", "This Campaign
") + if (c.evt_text.startsWith("Hold: ")) + c.evt_text = c.evt_text.replace("Hold: ", "Hold: ") + //c.evt_text = c.evt_text.replaceAll("Richard III", "Richard\xa0III") + c.evt_text = c.evt_text.replaceAll("'", "\u2019") + + c.cap_text = c.cap_text.replaceAll("'", "\u2019") + + let img = "" + if (c.number[0] == "Y") + img = `aow_york_${c.number.substring(1)}.jpg` + if (c.number[0] == "L") + img = `aow_lancaster_${c.number.substring(1)}.jpg` + + let xx = c.number[0] === "Y" ? " york" : " lancaster" + + out.push(`
`) + + let ec = "" + if (SHIELD_EVT_1.includes(c.number)) + ec = " sh1" + if (SHIELD_EVT_2.includes(c.number)) + ec = " sh2" + out.push(`
`) + out.push(`
${c.evt_title}
`) + if (c.evt_subtitle) + out.push(`
${c.evt_subtitle}
`) + out.push(`
${c.evt_text}
`) + out.push(`
`) + + let cc = " sh1" + if (SHIELD_CAP_2.includes(c.number)) + cc = " sh2" + if (SHIELD_CAP_3.includes(c.number)) + cc = " sh3" + if (SHIELD_CAP_R.includes(c.number)) + cc += " shr" + out.push(`
`) + out.push(`
${c.cap_title}
`) + if (c.cap_subtitle) + out.push(`
${c.cap_subtitle}
`) + out.push(`
${c.cap_text}
`) + out.push(`
`) + + out.push(`
${c.number}
`) + + out.push("
\n") +} + +console.log(out.join("")) -- cgit v1.2.3