diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-08 16:52:22 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:47 +0100 |
commit | 5c8bbf8f6c3cdd4a0563b30be8821ee632dc6f43 (patch) | |
tree | a1c8ac39e1ef5caa19bb5458ff6e55b508dafd09 /tools/gendata.js | |
parent | 7c6d64086fac989ad7ede51d017b05da5796facd (diff) | |
download | table-battles-5c8bbf8f6c3cdd4a0563b30be8821ee632dc6f43.tar.gz |
aliases
Diffstat (limited to 'tools/gendata.js')
-rw-r--r-- | tools/gendata.js | 37 |
1 files changed, 22 insertions, 15 deletions
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 = [ <link rel="stylesheet" href="/fonts/fonts.css"> <link rel="stylesheet" href="/table-battles/cards.css"> <style> -body{background-color:dimgray;color:whitesmoke;max-width:1600px;margin:0 auto;padding:20px;background-image:url(../background.png)} +body{background-color:dimgray;color:whitesmoke;max-width:1600px;margin:0 auto;padding:20px;background-image:url(../images/background.png)} h1{color: white} .list{display:flex;flex-wrap:wrap;gap:20px;} </style> @@ -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 = [ `<!doctype html> <html lang="en"> <head> -<title>Table Battle Cards</title> +<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;max-width:1600px;margin:0 auto;padding:20px;background-image:url(../background.png)} +body{background-color:dimgray;color:whitesmoke;max-width:1600px;margin:0 auto;padding:20px;background-image:url(../images/background.png)} .list{display:flex;flex-wrap:wrap;gap:20px;} </style> </head> |