From 897c0c2fcd534159b78381036076c48d2db43465 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 7 Dec 2023 15:27:32 +0100 Subject: Links and rechts. --- tools/gendata.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'tools/gendata.js') diff --git a/tools/gendata.js b/tools/gendata.js index d1c6e1b..14fcfd3 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -45,7 +45,7 @@ for (let c of card_records) { wing: WING[c.wing], } - card_index[c.number] = cards.length + let id = card_index[c.number] = cards.length cards.push(card) @@ -72,11 +72,39 @@ for (let c of card_records) { result.push(`
`) result.push(`
${c.name}
`) + if (c.symbol === "Inf1") { + card.infantry = 1 + result.push(`
`) + } + if (c.symbol === "Inf2") { + card.infantry = 2 + result.push(`
`) + } + if (c.symbol === "Cav1") { + card.cavalry = 1 + result.push(`
`) + } + if (c.symbol === "Cav2") { + card.cavalry = 2 + result.push(`
`) + } + if (card.strength) result.push(`
${card.strength}
`) else result.push(`
${c.strength}
`) - + + if (c.link === "LR") { + card.link = [ id - 1, id + 1 ] + result.push(``) + result.push(``) + } else if (c.link === "L") { + result.push(``) + card.link = [ id - 1 ] + } else if (c.link === "R") { + result.push(``) + card.link = [ id + 1 ] + } if (c.dice) { if (card.star) @@ -129,6 +157,7 @@ for (let c of card_records) { } if (c.reserve) { + console.log("RESERVE=", c.reserve) if (c.reserve === "RETIRE") card.retire = 1 else if (c.reserve === "PURSUIT") @@ -196,16 +225,23 @@ 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") + if (a.target === "Any enemy attack" || a.target === "Any enemy formation" || a.target === "Any enemy attacking it") a.target_list = find_enemy_cards(c.scenario, c.wing) else if (a.target === "Any friendly formation") 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 === "The Fog Lifts...") + a.target_list = [] else - a.target_list = a.target.split(", ").map(name => find_card(c.scenario, name)) + a.target_list = a.target.split(/, | OR /).map(name => find_card(c.scenario, name)) } } + 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!") + c.pursuit = c.actions[0].target_list[0] + } if (c.reserve) c.reserve = c.reserve.map(name => find_card(c.scenario, name)) } @@ -237,6 +273,7 @@ function parse_cards(text) { b = card_index[b] if (a === undefined || b === undefined) throw new Error("MISSING CARDS FOR " + text) + console.log("MISSING CARDS FOR " + text) for (let i = a; i <= b; ++i) out.push(i) } @@ -254,29 +291,32 @@ for (let s of scenario_records) { try { scenarios.push({ number: parseInt(s.number), + expansion: s.expansion, name: s.name, date: s.date, players: [ - { name: s.player1, cards: parse_cards(s.cards1), morale: parseInt(s.morale1) }, - { name: s.player2, cards: parse_cards(s.cards2), morale: parseInt(s.morale2) }, + { name: s.player1, cards: parse_cards(s.cards1), morale: parseInt(s.morale1), tactical: parseInt(s.tactical1) }, + { name: s.player2, cards: parse_cards(s.cards2), morale: parseInt(s.morale2), tactical: parseInt(s.tactical2) }, ], rule: s.rule || undefined }) result.push(` -
+
${s.name}
${s.date}
${s.player1}
-
Cards ${s.cards1}
-
Morale: ${s.morale1}
+
Cards ${s.cards1}
+
Morale: ${s.morale1}
+
${s.tactical1 ? "Tactical Victory: " + s.tactical1 : ""}
${s.player2}
-
Cards ${s.cards2}
-
Morale: ${s.morale2}
+
Cards ${s.cards2}
+
Morale: ${s.morale2}
+
${s.tactical2 ? "Tactical Victory: " + s.tactical2 : ""}
${s.rule_text}
${s.lore_text}
-- cgit v1.2.3