1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
const fs = require("fs")
let buf = []
let cards = []
let SHIELD_EVT_1 = [ "L17", "L32", "L35", "Y20", "Y24", "Y26", "Y28", "Y29", "Y32", "Y33" ]
let SHIELD_EVT_2 = [ "Y20", "Y26" ]
let SHIELD_CAP_R = [ "L19", "L21", "L23", "L26", "L35", "Y24" ]
let SHIELD_CAP_2 = [ "L20", "L33", "L34", "L35", "Y14", "Y18", "Y19", "Y20", "Y23", "Y30" ]
let SHIELD_CAP_3 = [ "L18", "L19", "L27", "L37", "Y21", "Y31", "L36" ]
function flush_card() {
function blank() {
while(buf.length > 0 && buf[0].length === 0)
buf.shift()
}
if (buf.length === 0)
return
let number = buf.shift()
blank()
let evt_title = buf.shift()
let evt_subtitle = null
if (buf[0].length > 0)
evt_subtitle = buf.shift()
blank()
let evt_text = buf.shift()
blank()
let cap_title = buf.shift()
let cap_subtitle = null
if (buf[0].length > 0)
cap_subtitle = buf.shift()
blank()
let cap_text = buf.shift()
blank()
let card = {
number,
evt_title, evt_subtitle, evt_text,
cap_title, cap_subtitle, cap_text
}
cards.push(card)
}
function process_line(line) {
line = line.trim()
if (/[YL]\d+/.test(line)) {
flush_card()
buf = []
}
buf.push(line)
}
fs.readFileSync("tools/cards/york.txt", "utf-8").split("\n").forEach(process_line)
fs.readFileSync("tools/cards/lancaster.txt", "utf-8").split("\n").forEach(process_line)
flush_card()
console.log(
`<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<title>Plantagenet - Arts of War</title>
<link rel="stylesheet" href="/fonts/fonts.css">
<link rel="stylesheet" href="/plantagenet/cards.css">
<style>
body{background-color:dimgray;margin:20px;display:flex;flex-wrap:wrap;gap:20px;}
</style>
</head>
<body>
`)
let out = []
let i = 0
for (let c of cards) {
if (c.evt_text.startsWith("This Levy "))
c.evt_text = c.evt_text.replace("This Levy ", "<b>This Levy</b><br>")
if (c.evt_text.startsWith("This Campaign "))
c.evt_text = c.evt_text.replace("This Campaign ", "<b>This Campaign</b><br>")
if (c.evt_text.startsWith("Hold: "))
c.evt_text = c.evt_text.replace("Hold: ", "<b>Hold:</b> ")
//c.evt_text = c.evt_text.replaceAll("Richard III", "Richard\xa0III")
c.evt_text = c.evt_text.replaceAll("'", "\u2019")
c.cap_text = c.cap_text.replaceAll("'", "\u2019")
let img = ""
if (c.number[0] == "Y")
img = `aow_york_${c.number.substring(1)}.jpg`
if (c.number[0] == "L")
img = `aow_lancaster_${c.number.substring(1)}.jpg`
let xx = c.number[0] === "Y" ? " york" : " lancaster"
out.push(`<div data-card="${c.number}" class="card aow${xx} c${i++}">`)
let ec = ""
if (SHIELD_EVT_1.includes(c.number))
ec = " sh1"
if (SHIELD_EVT_2.includes(c.number))
ec = " sh2"
out.push(`<div class="event${ec}">`)
out.push(`<div class="title">${c.evt_title}</div>`)
if (c.evt_subtitle)
out.push(`<div class="subtitle">${c.evt_subtitle}</div>`)
out.push(`<div class="text">${c.evt_text}</div>`)
out.push(`</div>`)
let cc = " sh1"
if (SHIELD_CAP_2.includes(c.number))
cc = " sh2"
if (SHIELD_CAP_3.includes(c.number))
cc = " sh3"
if (SHIELD_CAP_R.includes(c.number))
cc += " shr"
out.push(`<div class="capability${cc}">`)
out.push(`<div class="title">${c.cap_title}</div>`)
if (c.cap_subtitle)
out.push(`<div class="subtitle">${c.cap_subtitle}</div>`)
out.push(`<div class="text">${c.cap_text}</div>`)
out.push(`</div>`)
out.push(`<div class="number">${c.number}</div>`)
out.push("</div>\n")
}
console.log(out.join(""))
|