diff options
Diffstat (limited to 'tools/gendata.js')
-rw-r--r-- | tools/gendata.js | 115 |
1 files changed, 69 insertions, 46 deletions
diff --git a/tools/gendata.js b/tools/gendata.js index 07c4f47..ff38695 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -4,26 +4,7 @@ const { parse } = require("csv-parse/sync") var card_records = parse(fs.readFileSync("tools/cards.csv", "utf-8"), { columns: true, records_with_empty_values: true }) var scenario_records = parse(fs.readFileSync("tools/scenarios.csv", "utf-8"), { columns: true, skip_records_with_empty_values: true }) -var result = [ -`<!doctype html> -<html lang="en"> -<head> -<meta charset="utf-8"> -<title>Table Battle Cards</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(../images/background.png)} -h1{color: white} -.list{display:flex;flex-wrap:no-wrap;gap:20px;margin:60px 0;width:fit-content} -.list{display:grid;grid-auto-flow:column;grid-template-rows:auto auto;} -.list{display:grid;grid-auto-flow:row;grid-template-columns:auto auto;} -.ref{display:block;height:338;border-radius:10px;} -</style> -</head> -<body> -<div>` -] +var result = [] const WING = { red: 0, pink: 1, blue: 2, dkblue: 3 } const WING_ICON = [ "\u2666", "\u2665", "\u2663", "\u2660" ] @@ -51,13 +32,26 @@ function remap(x) { let last_wing = null +var last_scen = null +var result = [ ] + +var scenario_html = {} + +function flush_scenario_html() { + scenario_html[last_scen] = result + result = [] +} + for (let c of card_records) { if (!c.number) { - result.push(`</div><h2>${c.scenario}</h2><div class="list">`) + if (result.length > 2) + flush_scenario_html() last_wing = null continue } + last_scen = c.scenario + if ((c.wing === "blue" || c.wing === "dkblue") && (last_wing === "red" || last_wing === "pink")) result.push(`</div><div class="list">`) if ((last_wing === "blue" || last_wing === "dkblue") && (c.wing === "red" || c.wing === "pink")) @@ -275,12 +269,16 @@ for (let c of card_records) { result.push(`</div>`) + /* if (c.number.endsWith("A")) result.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_A${remap(a_seq++)}.jpg">`) else result.push(`<img class="ref" height="338" src="/table-battles/ref2/sliced/card_B${remap(b_seq++)}.jpg">`) + */ } +flush_scenario_html() + function find_card(scenario, name) { name = name.replace("*", "") name = name.replace(" (Voluntary)", "") @@ -398,13 +396,16 @@ fs.writeFileSync("info/all-cards.html", result.join("\n")) result = [ `<!doctype html> <html lang="en"> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> <head> <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(../images/background.png)} -.list{display:flex;flex-wrap:wrap;gap:20px;} +body{background-color:dimgray;color:whitesmoke;padding:20px;background-image:url(../images/background.png)} +.list{display:flex;flex-wrap:wrap;gap:20px;margin-bottom:40px} +a{text-decoration:none;color:black} </style> </head> <body> @@ -448,29 +449,51 @@ for (let s of scenario_records) { rule_text: s.rule_text || undefined, lore_text: s.lore_text || undefined, }) - result.push(` - <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_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_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> - <div class="number">${s.number}</div> - </div> - `) + var html = +`<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_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_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> +<div class="number">${s.number}</div> +</div>` + + scenario_html[s.number].unshift(`</div><div class="list">`) + scenario_html[s.number].unshift(html) + scenario_html[s.number].unshift( +`<!doctype html> +<html lang="en"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>${s.number} - ${s.name}</title> +<link rel="stylesheet" href="/fonts/fonts.css"> +<link rel="stylesheet" href="/table-battles/cards.css"> +<style> +body{background-color:dimgray;color:whitesmoke;padding:20px;background-image:url(../images/background.png)} +.list{display:flex;flex-wrap:wrap;gap:20px;margin-bottom:40px} +</style> +</head> +<body> +<h1>${s.number} - ${s.name}</h1> +<div class="list">`) + + fs.writeFileSync(`info/s_${s.number}.html`, scenario_html[s.number].join("\n")) + result.push(`<a href="/table-battles/info/s_${s.number}.html">`, html, '</a>') } catch (err) { console.log(err) } |