summaryrefslogtreecommitdiff
path: root/tools/gendata.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-07 15:27:32 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:47 +0100
commit897c0c2fcd534159b78381036076c48d2db43465 (patch)
tree0714012c49679c650cf72a3bba0e6d6122c1cc98 /tools/gendata.js
parentdc6e8cd3fe0106c6233685e6d637c8b17cd635ea (diff)
downloadtable-battles-897c0c2fcd534159b78381036076c48d2db43465.tar.gz
Links and rechts.
Diffstat (limited to 'tools/gendata.js')
-rw-r--r--tools/gendata.js62
1 files changed, 51 insertions, 11 deletions
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(`<div class="formation card">`)
result.push(`<div class="name ${c.wing}">${c.name}</div>`)
+ if (c.symbol === "Inf1") {
+ card.infantry = 1
+ result.push(`<div class="symbol infantry1"></div>`)
+ }
+ if (c.symbol === "Inf2") {
+ card.infantry = 2
+ result.push(`<div class="symbol infantry2"></div>`)
+ }
+ if (c.symbol === "Cav1") {
+ card.cavalry = 1
+ result.push(`<div class="symbol cavalry1"></div>`)
+ }
+ if (c.symbol === "Cav2") {
+ card.cavalry = 2
+ result.push(`<div class="symbol cavalry2"></div>`)
+ }
+
if (card.strength)
result.push(`<div class="strength">${card.strength}</div>`)
else
result.push(`<div class="strength">${c.strength}</div>`)
-
+
+ if (c.link === "LR") {
+ card.link = [ id - 1, id + 1 ]
+ result.push(`<div class="link left"></div>`)
+ result.push(`<div class="link right"></div>`)
+ } else if (c.link === "L") {
+ result.push(`<div class="link left"></div>`)
+ card.link = [ id - 1 ]
+ } else if (c.link === "R") {
+ result.push(`<div class="link right"></div>`)
+ 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(`
- <div class="scenario card">
+ <div id="scenario_${s.number}" class="scenario card">
<div class="scenario_title">
<div class="battle_name">${s.name}</div>
<div class="battle_date">${s.date}</div>
</div>
<div class="scenario_player">
<div class="scenario_player_name">${s.player1}</div>
- <div class="scenario_cards">Cards ${s.cards1}</div>
- <div class="scenario_morale">Morale: ${s.morale1}</div>
+ <div class="scenario_line">Cards ${s.cards1}</div>
+ <div class="scenario_line">Morale: ${s.morale1}</div>
+ <div class="scenario_line">${s.tactical1 ? "Tactical Victory: " + s.tactical1 : ""}</div>
</div>
<div class="scenario_player">
<div class="scenario_player_name">${s.player2}</div>
- <div class="scenario_cards">Cards ${s.cards2}</div>
- <div class="scenario_morale">Morale: ${s.morale2}</div>
+ <div class="scenario_line">Cards ${s.cards2}</div>
+ <div class="scenario_line">Morale: ${s.morale2}</div>
+ <div class="scenario_line">${s.tactical2 ? "Tactical Victory: " + s.tactical2 : ""}</div>
</div>
<div class="rule_text">${s.rule_text}</div>
<div class="lore_text">${s.lore_text}</div>