From 5c8bbf8f6c3cdd4a0563b30be8821ee632dc6f43 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 8 Dec 2023 16:52:22 +0100 Subject: aliases --- tools/gendata.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'tools/gendata.js') diff --git a/tools/gendata.js b/tools/gendata.js index bb9c606..a5b3bae 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -12,7 +12,7 @@ var result = [ @@ -45,6 +45,9 @@ for (let c of card_records) { wing: WING[c.wing], } + if (c.alias) + card.alias = c.alias + let id = card_index[c.number] = cards.length cards.push(card) @@ -198,9 +201,8 @@ for (let c of card_records) { } function find_card(scenario, name) { - name = name.replace(" out of reserve", "") for (let c of cards) - if (c.scenario === scenario && c.name === name) + if (c.scenario === scenario && (c.name === name || c.alias === name)) return card_index[c.number] throw new Error("CARD NOT FOUND: " + scenario + " " + name) } @@ -243,24 +245,29 @@ function find_wing_cards(scenario, wing) { for (let c of cards) { for (let a of c.actions) { if (a.target) { - if (a.target === "Any enemy attack" || a.target === "Any enemy formation" || a.target === "Any enemy attacking it") + let tname = a.target.replace(" out of reserve", "") + if (tname === "Any enemy attack" || tname === "Any enemy formation" || tname === "Any enemy attacking it") a.target_list = find_enemy_cards(c.scenario, c.wing) - else if (a.target === "Any friendly formation") + else if (tname === "Any friendly formation") a.target_list = find_friendly_cards(c.scenario, c.wing) - else if (a.target === "Any friendly Pink formation") + else if (tname === "Any friendly Pink formation") a.target_list = find_wing_cards(c.scenario, WING.pink) - else if (a.target === "Any other Pink formation") + else if (tname === "Any other Pink formation") a.target_list = find_wing_cards(c.scenario, WING.pink).filter(x => x !== c) - else if (a.target === "Any Red formation") + else if (tname === "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") + else if (tname === "Any Pink formation") + 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.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 (a.target === "The Fog Lifts...") + else if (tname === "The Fog Lifts...") a.target_list = [] else - a.target_list = a.target.split(/, | OR /).map(name => find_card(c.scenario, name)) + a.target_list = tname.split(/, | OR | or | and /).map(name => find_card(c.scenario, name)) } } if (c.rules) { @@ -285,11 +292,11 @@ result = [ ` -Table Battle Cards +Table Battle Scenarios -- cgit v1.2.3