From 3d4909f946f724562d354a55a721ded43a12c268 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 9 Dec 2023 19:58:23 +0100 Subject: Towton and Edgecote Moor. take_from, rout_with, and remove_with. --- tools/gendata.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'tools') diff --git a/tools/gendata.js b/tools/gendata.js index 9580130..1bc9099 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -75,21 +75,13 @@ for (let c of card_records) { result.push(`
`) result.push(`
${c.name}
`) - if (c.symbol === "Inf1") { + if (c.symbol === "inf") { card.infantry = 1 - result.push(`
`) + result.push(`
`) } - if (c.symbol === "Inf2") { - card.infantry = 2 - result.push(`
`) - } - if (c.symbol === "Cav1") { + if (c.symbol === "cav") { card.cavalry = 1 - result.push(`
`) - } - if (c.symbol === "Cav2") { - card.cavalry = 2 - result.push(`
`) + result.push(`
`) } if (card.strength) @@ -177,9 +169,7 @@ for (let c of card_records) { card.retire = 1 else if (c.reserve === "PURSUIT") card.pursuit = 1 - else if (c.reserve === "Commanded") - card.reserve = [] - else if (c.reserve === "See Above") + else if (c.reserve === "Commanded" || c.reserve === "See Above" || c.reserve === "Special Rule") card.reserve = [] else card.reserve = c.reserve.split(" or ") @@ -242,7 +232,7 @@ function find_wing_cards(scenario, wing) { } /* process action and reserve targets */ -for (let c of cards) { +function process_card(c) { for (let a of c.actions) { if (a.target) { let tname = a.target.replace(" out of reserve", "") @@ -260,12 +250,16 @@ for (let c of cards) { a.target_list = find_wing_cards(c.scenario, WING.pink) else if (tname === "Any Blue formation") a.target_list = find_wing_cards(c.scenario, WING.blue) + else if (tname === "Any Dark Blue formation") + a.target_list = find_wing_cards(c.scenario, WING.dkblue) else if (tname.startsWith("Any attack on ")) a.target_list = tname.replace("Any attack on ", "").split(" or ").map(name => find_card(c.scenario, name)) else if (tname === "Any friendly but Little Round Top") a.target_list = find_friendly_cards(c.scenario, c.wing).filter(x => x !== find_card(c.scenario, "Little Round Top")) + else if (tname === 'Activate "Retreat to Nivelles"') + a.target_list = [ "Retreat to Nivelles" ] else if (tname === "The Fog Lifts...") - a.target_list = [] + a.target_list = [ "The Fog" ] else a.target_list = tname.split(/, | OR | or | and /).map(name => find_card(c.scenario, name)) } @@ -286,7 +280,18 @@ for (let c of cards) { c.reserve = c.reserve.map(name => find_card(c.scenario, name)) } -fs.writeFileSync("info/all-cards.html", result.join("\n")) +let failed = false +for (let c of cards) { + try { + process_card(c) + } catch (err) { + console.log(err) + failed = true + } +} + +if (!failed) + fs.writeFileSync("info/all-cards.html", result.join("\n")) result = [ ` -- cgit v1.2.3