From 301bc138267a99d1135c5eec30cedbd316eed742 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 8 Dec 2023 12:08:30 +0100 Subject: more data --- tools/gendata.js | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'tools/gendata.js') diff --git a/tools/gendata.js b/tools/gendata.js index 14fcfd3..dce36b3 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -143,8 +143,17 @@ for (let c of card_records) { result.push(``) } - if (c.rule) - card.rule = c.rule_tag + if (c.rule) { + card.rules = {} + for (let rule of c.rule.split("; ")) { + if (/=/.test(rule)) { + let [ key, vals ] = rule.split("=") + card.rules[key] = vals.split(",") + } else { + card.rules[rule] = 1 + } + } + } if (c.rule_text) { card.rule_text = c.rule_text @@ -157,8 +166,11 @@ for (let c of card_records) { } if (c.reserve) { - console.log("RESERVE=", c.reserve) - if (c.reserve === "RETIRE") + if (c.reserve === "RETIRE, Ward") { + card.retire = 1 + card.reserve = [ "Ward" ] + } + else if (c.reserve === "RETIRE") card.retire = 1 else if (c.reserve === "PURSUIT") card.pursuit = 1 @@ -167,8 +179,12 @@ for (let c of card_records) { else card.reserve = c.reserve.split(" or ") - if (c.reserve === "RETIRE" || c.reserve === "PURSUIT") - result.push(`
${c.reserve}
`) + if (card.retire && card.reserve) + result.push(`
RETIRE; RESERVE (${card.reserve.join(", ")})
`) + else if (card.retire) + result.push(`
RETIRE
`) + else if (card.pursuit) + result.push(`
PURSUIT
`) else result.push(`
IN RESERVE (${c.reserve})
`) } @@ -231,12 +247,25 @@ for (let c of cards) { a.target_list = find_friendly_cards(c.scenario, c.wing) else if (a.target === "Any friendly Pink formation") a.target_list = find_wing_cards(c.scenario, WING.pink) + else if (a.target === "Any Red formation") + a.target_list = find_wing_cards(c.scenario, WING.red) + else if (a.target.startsWith("Any attack on ")) + a.target_list = a.target.replace("Any attack on ", "").split(" or ").map(name => find_card(c.scenario, name)) + else if (a.target === "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 (a.target === "The Fog Lifts...") a.target_list = [] else a.target_list = a.target.split(/, | OR /).map(name => find_card(c.scenario, name)) } } + if (c.rules) { + for (let key in c.rules) { + let val = c.rules[key] + if (Array.isArray(val)) + c.rules[key] = val.map(number => card_index[number]) + } + } if (c.pursuit) { if (c.actions[0].type !== "Attack") throw new Error("PURSUIT without Attack as first action") if (c.actions[0].target_list.length !== 1) throw new Error("PURSUIT with more than one target!") -- cgit v1.2.3