diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gendata.js | 125 |
1 files changed, 77 insertions, 48 deletions
diff --git a/tools/gendata.js b/tools/gendata.js index 370c9e0..5e4891b 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -33,6 +33,26 @@ function remap(x) { let last_wing = null var last_scen = null + +var allcards = [ +`<!doctype html> +<html lang="en"> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<head> +<title>Table Battle Scenarios</title> +<link rel="stylesheet" href="/fonts/fonts.css"> +<link rel="stylesheet" href="/table-battles/cards.css"> +<style> +body{background-color:dimgray;color:whitesmoke;padding:20px;background-image:url(../images/background.png)} +.list{display:grid;grid-template-columns:min-content min-content;gap:20px;margin-bottom:40px} +a{text-decoration:none;color:black} +</style> +</head> +<body> +<div class="list">` +] + var result = [ ] var scenario_html = {} @@ -44,18 +64,22 @@ function flush_scenario_html() { for (let c of card_records) { if (!c.number) { - if (result.length > 2) + allcards.push(`</div><h1>${c.scenario}</h1><div class="list">`) + if (result.length > 2) { flush_scenario_html() + } last_wing = null continue } last_scen = c.scenario + let html = [] + if ((c.wing === "blue" || c.wing === "dkblue") && (last_wing === "red" || last_wing === "pink")) - result.push(`</div><div class="list">`) + html.push(`</div><div class="list">`) if ((last_wing === "blue" || last_wing === "dkblue") && (c.wing === "red" || c.wing === "pink")) - result.push(`</div><div class="list">`) + html.push(`</div><div class="list">`) last_wing = c.wing if (!c.name) @@ -117,46 +141,46 @@ for (let c of card_records) { if (SQUEEZE_MARGINS.includes(c.number)) { card.squeeze = 1 - result.push(`<div class="formation card squeeze">`) + html.push(`<div class="formation card squeeze">`) } else { - result.push(`<div class="formation card">`) + html.push(`<div class="formation card">`) } if (c.symbol) - result.push(`<div class="name with_symbol ${c.wing}">${c.name}</div>`) + html.push(`<div class="name with_symbol ${c.wing}">${c.name}</div>`) else - result.push(`<div class="name ${c.wing}">${c.name}</div>`) + html.push(`<div class="name ${c.wing}">${c.name}</div>`) if (c.symbol === "inf") { card.infantry = 1 - result.push(`<div class="symbol infantry"></div>`) + html.push(`<div class="symbol infantry"></div>`) } if (c.symbol === "cav") { card.cavalry = 1 - result.push(`<div class="symbol cavalry"></div>`) + html.push(`<div class="symbol cavalry"></div>`) } if (card.strength) - result.push(`<div class="strength">${card.strength}</div>`) + html.push(`<div class="strength">${card.strength}</div>`) else - result.push(`<div class="strength">${c.strength}</div>`) + html.push(`<div class="strength">${c.strength}</div>`) if (c.link === "LR") { card.link = [ id - 1, id + 1 ] - result.push(`<div class="link left"></div>`) - result.push(`<div class="link right"></div>`) + html.push(`<div class="link left"></div>`) + html.push(`<div class="link right"></div>`) } else if (c.link === "L") { - result.push(`<div class="link left"></div>`) + html.push(`<div class="link left"></div>`) card.link = [ id - 1 ] } else if (c.link === "R") { - result.push(`<div class="link right"></div>`) + html.push(`<div class="link right"></div>`) card.link = [ id + 1 ] } if (c.dice) { if (card.morale === 2) - result.push(`<div class="star">★</div>`) - result.push(`<div class="dice_area">${c.dice}</div>`) + html.push(`<div class="star">★</div>`) + html.push(`<div class="dice_area">${c.dice}</div>`) } function make_action(type, requirement, target, effect, rule_text, short) { @@ -172,54 +196,54 @@ for (let c of card_records) { if (c.action1_type) { let short = c.action1_effect && (c.rule_text_1 || squeeze) card.actions.push(make_action(c.action1_type, c.action1_req, c.action1_target, c.action1_effect, c.action1_rule_text, short)) - result.push(`<div class="action_row">`) + html.push(`<div class="action_row">`) if (/Screen|Absorb|Counterattack/.test(c.action1_type)) - result.push(`<div class="action_type reaction">${c.action1_type}</div>`) + html.push(`<div class="action_type reaction">${c.action1_type}</div>`) else - result.push(`<div class="action_type">${c.action1_type}</div>`) - result.push(`<div class="action_requirement">${c.action1_req}</div>`) - result.push(`<div class="action_target">${c.action1_target}</div>`) + html.push(`<div class="action_type">${c.action1_type}</div>`) + html.push(`<div class="action_requirement">${c.action1_req}</div>`) + html.push(`<div class="action_target">${c.action1_target}</div>`) if (c.action1_effect) { if (c.rule_text_1 || squeeze) - result.push(`<div class="action_effect short">${c.action1_effect}</div>`) + html.push(`<div class="action_effect short">${c.action1_effect}</div>`) else - result.push(`<div class="action_effect">${c.action1_effect}</div>`) + html.push(`<div class="action_effect">${c.action1_effect}</div>`) } - result.push(`</div>`) + html.push(`</div>`) } if (c.rule_text_1) { card.rule_text_1 = c.rule_text_1 - result.push(`<div class="rule_text">${c.rule_text_1}</div>`) + html.push(`<div class="rule_text">${c.rule_text_1}</div>`) } if (c.action2_type || c.action2_effect) { let short = c.action2_effect && (c.rule_text_2 || squeeze) card.actions.push(make_action(c.action2_type, c.action2_req, c.action2_target, c.action2_effect, c.action2_rule_text, short)) - result.push(`<div class="action_row">`) + html.push(`<div class="action_row">`) if (/Screen|Absorb|Counterattack/.test(c.action2_type)) - result.push(`<div class="action_type reaction">${c.action2_type}</div>`) + html.push(`<div class="action_type reaction">${c.action2_type}</div>`) else - result.push(`<div class="action_type">${c.action2_type}</div>`) - result.push(`<div class="action_requirement">${c.action2_req}</div>`) - result.push(`<div class="action_target">${c.action2_target}</div>`) + html.push(`<div class="action_type">${c.action2_type}</div>`) + html.push(`<div class="action_requirement">${c.action2_req}</div>`) + html.push(`<div class="action_target">${c.action2_target}</div>`) if (c.action2_effect) { if (c.rule_text_2 || squeeze) - result.push(`<div class="action_effect short">${c.action2_effect}</div>`) + html.push(`<div class="action_effect short">${c.action2_effect}</div>`) else - result.push(`<div class="action_effect">${c.action2_effect}</div>`) + html.push(`<div class="action_effect">${c.action2_effect}</div>`) } - result.push(`</div>`) + html.push(`</div>`) } if (c.rule_text_2) { card.rule_text_2 = c.rule_text_2 - result.push(`<div class="rule_text">${c.rule_text_2}</div>`) + html.push(`<div class="rule_text">${c.rule_text_2}</div>`) } if (c.lore_text) { card.lore_text = c.lore_text - result.push(`<div class="lore_text">${c.lore_text}</div>`) + html.push(`<div class="lore_text">${c.lore_text}</div>`) } if (c.rule) { @@ -253,28 +277,31 @@ for (let c of card_records) { card.reserve = c.reserve.split(" or ") if (card.retire && card.reserve) - result.push(`<div class="reserve">RETIRE; RESERVE (${card.reserve.join(", ")})</div>`) + html.push(`<div class="reserve">RETIRE; RESERVE (${card.reserve.join(", ")})</div>`) else if (card.retire && card.pursuit) - result.push(`<div class="reserve">RETIRE, PURSUIT</div>`) + html.push(`<div class="reserve">RETIRE, PURSUIT</div>`) else if (card.retire) - result.push(`<div class="reserve">RETIRE</div>`) + html.push(`<div class="reserve">RETIRE</div>`) else if (card.pursuit) - result.push(`<div class="reserve">PURSUIT</div>`) + html.push(`<div class="reserve">PURSUIT</div>`) else - result.push(`<div class="reserve">IN RESERVE (${c.reserve})</div>`) + html.push(`<div class="reserve">IN RESERVE (${c.reserve})</div>`) } - result.push(`<div class="number">${c.number}</div>`) - result.push(`<div class="extra">${WING_ICON[card.wing]}</div>`) + html.push(`<div class="number">${c.number}</div>`) + html.push(`<div class="extra">${WING_ICON[card.wing]}</div>`) - result.push(`</div>`) + html.push(`</div>`) + + for (let line of html) { + result.push(line) + allcards.push(line) + } - /* if (c.number.endsWith("A")) - result.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_A${remap(a_seq++)}.jpg">`) + allcards.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_A${remap(a_seq++)}.jpg">`) else - result.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_B${remap(b_seq++)}.jpg">`) - */ + allcards.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_B${remap(b_seq++)}.jpg">`) } flush_scenario_html() @@ -402,6 +429,8 @@ cards.forEach((c, ix) => { } }) +fs.writeFileSync("info/ref.html", allcards.join("\n")) + result = [ `<!doctype html> <html lang="en"> |