summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-31 17:47:38 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commitd818566e2e80b4cbb4eab80c95229e317bf9332d (patch)
tree89308a56e860e6306196c5907ceec312206b8f2c
parent4a3d059599d88ddfea44c9d57f0db5aeba1e3780 (diff)
downloadtable-battles-d818566e2e80b4cbb4eab80c95229e317bf9332d.tar.gz
WIP paintings and wikipedia links
-rw-r--r--play.html14
-rw-r--r--play.js13
-rw-r--r--rules.js1
-rw-r--r--tools/gendata.js1
4 files changed, 29 insertions, 0 deletions
diff --git a/play.html b/play.html
index dec92ea..1155ccd 100644
--- a/play.html
+++ b/play.html
@@ -53,6 +53,15 @@
padding: 2px 8px;
}
+#log .h1 a {
+ color: black;
+ text-decoration: none;
+}
+
+#log .h1 a:hover {
+ text-decoration: underline;
+}
+
#log .h2 {
text-align: center;
font-variant: small-caps;
@@ -70,6 +79,11 @@
#log div.i1 { padding-left: 32px; text-indent: -12px; }
#log div.i2 { padding-left: 44px; text-indent: -12px; }
+#log img {
+ padding: 0;
+ max-width: 100%;
+}
+
#log .lore {
font-style: italic;
text-indent: 0;
diff --git a/play.js b/play.js
index 9fed183..c853573 100644
--- a/play.js
+++ b/play.js
@@ -511,6 +511,14 @@ function on_log(text) {
if (text.match(/^\.h1 /)) {
text = text.substring(4)
p.className = "h1"
+ let w = null
+ for (let s of data.scenarios)
+ if (s.name === text)
+ w = s.wikipedia
+ if (w) {
+ p.innerHTML = `<a href="${w}">${text}</a>`
+ return p
+ }
}
else if (text.match(/^\.h2 /)) {
text = text.substring(4)
@@ -540,6 +548,11 @@ function on_log(text) {
text = text.substring(1)
p.className = "i1"
}
+ else if (text.match(/^.img /)) {
+ p = document.createElement("img")
+ p.src = "paintings/" + text.substring(5) + ".jpg"
+ return p
+ }
text = text.replace(/\bC\d+\b/g, sub_card)
text = text.replace(/\b[DPRBK]\d\b/g, sub_icon)
diff --git a/rules.js b/rules.js
index 2267dc9..8e65a20 100644
--- a/rules.js
+++ b/rules.js
@@ -443,6 +443,7 @@ exports.setup = function (seed, scenario, options) {
log(".h1 " + info.name)
log(".h2 " + info.date)
+ log(".img " + info.name.toLowerCase().replaceAll(" ", "_"))
log("")
if (info.players[0].tactical > 0 || info.players[1].tactical > 0) {
diff --git a/tools/gendata.js b/tools/gendata.js
index 6940249..a00a3eb 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -530,6 +530,7 @@ for (let s of scenario_records) {
rule: s.rule || undefined,
rule_text: s.rule_text || undefined,
lore_text: s.lore_text || undefined,
+ wikipedia: s.wikipedia,
})
var html =
`<div id="scenario_${s.number}" class="scenario card">