summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-11-12 01:53:17 +0100
committerTor Andersson <tor@ccxvii.net>2023-11-12 13:18:04 +0100
commite8b02e17173feec741bd4475a299aa664346a41f (patch)
tree2ac9e9a81c5e413c75a33b09359fcaff6e29640c /tools
parent31e0d18cc7b6d4e1ad185c2430bfbeff6a1c39a7 (diff)
downloadhammer-of-the-scots-e8b02e17173feec741bd4475a299aa664346a41f.tar.gz
Show last used border, border limits, and main attack.
Optimize border state representation (use maps instead of objects).
Diffstat (limited to 'tools')
-rw-r--r--tools/borders.svg359
-rw-r--r--tools/genborders.js53
-rw-r--r--tools/makeborders.js32
3 files changed, 444 insertions, 0 deletions
diff --git a/tools/borders.svg b/tools/borders.svg
new file mode 100644
index 0000000..0e05b74
--- /dev/null
+++ b/tools/borders.svg
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1688"
+ height="1950"
+ version="1.1"
+ id="svg102"
+ sodipodi:docname="borders.svg"
+ inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
+ <metadata
+ id="metadata108">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs106" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="640"
+ inkscape:window-height="480"
+ id="namedview104"
+ showgrid="true"
+ inkscape:snap-bbox="true"
+ inkscape:snap-text-baseline="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:zoom="6.3795364"
+ inkscape:cx="542.64371"
+ inkscape:cy="1069.5661"
+ inkscape:current-layer="svg102"
+ inkscape:document-rotation="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid110" />
+ </sodipodi:namedview>
+ <image
+ sodipodi:absref="/home/tor/src/rally/public/hammer-of-the-scots/map75.png"
+ xlink:href="../map75.png"
+ id="image2"
+ sodipodi:insensitive="true"
+ image-rendering="pixelated"
+ height="1950"
+ width="1688"
+ y="0"
+ x="0" />
+ <circle
+ inkscape:label="England / Dunbar"
+ cx="1285"
+ cy="1320"
+ r="16"
+ id="circle4" />
+ <circle
+ inkscape:label="England / Annan"
+ cx="1065"
+ cy="1630"
+ r="16"
+ id="circle6" />
+ <circle
+ inkscape:label="England / Teviot"
+ cx="1210"
+ cy="1495"
+ r="16"
+ id="circle8" />
+ <circle
+ inkscape:label="Ross / Garmoran"
+ cx="505"
+ cy="450"
+ r="16"
+ id="circle10" />
+ <circle
+ inkscape:label="Ross / Moray"
+ cx="665"
+ cy="455"
+ r="16"
+ id="circle12" />
+ <circle
+ inkscape:label="Garmoran / Moray"
+ cx="550"
+ cy="590"
+ r="16"
+ id="circle14" />
+ <circle
+ inkscape:label="Garmoran / Lochaber"
+ cx="445"
+ cy="670"
+ r="16"
+ id="circle16" />
+ <circle
+ inkscape:label="Moray / Strathspey"
+ cx="860"
+ cy="460"
+ r="16"
+ id="circle18" />
+ <circle
+ inkscape:label="Moray / Lochaber"
+ cx="565"
+ cy="665"
+ r="16"
+ id="circle20" />
+ <circle
+ inkscape:label="Moray / Badenoch"
+ cx="715"
+ cy="610"
+ r="16"
+ id="circle22" />
+ <circle
+ inkscape:label="Strathspey / Buchan"
+ cx="1110"
+ cy="430"
+ r="16"
+ id="circle24" />
+ <circle
+ inkscape:label="Strathspey / Badenoch"
+ cx="880"
+ cy="530"
+ r="16"
+ id="circle26" />
+ <circle
+ inkscape:label="Buchan / Badenoch"
+ cx="990"
+ cy="565"
+ r="16"
+ id="circle28" />
+ <circle
+ inkscape:label="Buchan / Mar"
+ cx="1095"
+ cy="605"
+ r="16"
+ id="circle30" />
+ <circle
+ inkscape:label="Buchan / Angus"
+ cx="1240"
+ cy="645"
+ r="16"
+ id="circle32" />
+ <circle
+ inkscape:label="Lochaber / Badenoch"
+ cx="675"
+ cy="730"
+ r="16"
+ id="circle34" />
+ <circle
+ inkscape:label="Lochaber / Argyll"
+ cx="530"
+ cy="860"
+ r="16"
+ id="circle36" />
+ <circle
+ inkscape:label="Lochaber / Atholl"
+ cx="635"
+ cy="855"
+ r="16"
+ id="circle38" />
+ <circle
+ inkscape:label="Badenoch / Mar"
+ cx="904"
+ cy="672"
+ r="16"
+ id="circle40" />
+ <circle
+ inkscape:label="Badenoch / Atholl"
+ cx="730"
+ cy="790"
+ r="16"
+ id="circle42" />
+ <circle
+ inkscape:label="Mar / Angus"
+ cx="1035"
+ cy="750"
+ r="16"
+ id="circle44" />
+ <circle
+ inkscape:label="Mar / Atholl"
+ cx="835"
+ cy="785"
+ r="16"
+ id="circle46" />
+ <circle
+ inkscape:label="Angus / Atholl"
+ cx="880"
+ cy="855"
+ r="16"
+ id="circle48" />
+ <circle
+ inkscape:label="Angus / Fife"
+ cx="965"
+ cy="900"
+ r="16"
+ id="circle50" />
+ <circle
+ inkscape:label="Argyll / Atholl"
+ cx="585"
+ cy="950"
+ r="16"
+ id="circle52" />
+ <circle
+ inkscape:label="Argyll / Lennox"
+ cx="545"
+ cy="1065"
+ r="16"
+ id="circle54" />
+ <circle
+ inkscape:label="Atholl / Lennox"
+ cx="615"
+ cy="1025"
+ r="16"
+ id="circle56" />
+ <circle
+ inkscape:label="Atholl / Mentieth"
+ cx="690"
+ cy="980"
+ r="16"
+ id="circle58" />
+ <circle
+ inkscape:label="Atholl / Fife"
+ cx="845"
+ cy="905"
+ r="16"
+ id="circle60" />
+ <circle
+ inkscape:label="Lennox / Mentieth"
+ cx="725"
+ cy="1185"
+ r="16"
+ id="circle62" />
+ <circle
+ inkscape:label="Lennox / Carrick"
+ cx="625"
+ cy="1310"
+ r="16"
+ id="circle64" />
+ <circle
+ inkscape:label="Lennox / Lanark"
+ cx="725"
+ cy="1260"
+ r="16"
+ id="circle66" />
+ <circle
+ inkscape:label="Mentieth / Fife"
+ cx="880"
+ cy="1060"
+ r="16"
+ id="circle68" />
+ <circle
+ inkscape:label="Mentieth / Lanark"
+ cx="810"
+ cy="1235"
+ r="16"
+ id="circle70" />
+ <circle
+ inkscape:label="Mentieth / Lothian"
+ cx="900"
+ cy="1215"
+ r="16"
+ id="circle72" />
+ <circle
+ inkscape:label="Carrick / Lanark"
+ cx="790"
+ cy="1450"
+ r="16"
+ id="circle74" />
+ <circle
+ inkscape:label="Carrick / Galloway"
+ cx="680"
+ cy="1556"
+ r="16"
+ id="circle76" />
+ <circle
+ inkscape:label="Carrick / Annan"
+ cx="850"
+ cy="1540"
+ r="16"
+ id="circle78" />
+ <circle
+ inkscape:label="Lanark / Lothian"
+ cx="905"
+ cy="1275"
+ r="16"
+ id="circle80" />
+ <circle
+ inkscape:label="Lanark / Selkirk"
+ cx="922"
+ cy="1377"
+ r="16"
+ id="circle82" />
+ <circle
+ inkscape:label="Lanark / Annan"
+ cx="888"
+ cy="1470"
+ r="16"
+ id="circle84" />
+ <circle
+ inkscape:label="Lothian / Selkirk"
+ cx="1010"
+ cy="1300"
+ r="16"
+ id="circle86" />
+ <circle
+ inkscape:label="Lothian / Dunbar"
+ cx="1100"
+ cy="1235"
+ r="16"
+ id="circle88" />
+ <circle
+ inkscape:label="Selkirk / Dunbar"
+ cx="1115"
+ cy="1310"
+ r="16"
+ id="circle90" />
+ <circle
+ inkscape:label="Selkirk / Annan"
+ cx="980"
+ cy="1472"
+ r="16"
+ id="circle92" />
+ <circle
+ inkscape:label="Selkirk / Teviot"
+ cx="1080"
+ cy="1405"
+ r="16"
+ id="circle94" />
+ <circle
+ inkscape:label="Dunbar / Teviot"
+ cx="1195"
+ cy="1335"
+ r="16"
+ id="circle96" />
+ <circle
+ inkscape:label="Galloway / Annan"
+ cx="860"
+ cy="1625"
+ r="16"
+ id="circle98" />
+ <circle
+ inkscape:label="Annan / Teviot"
+ cx="1070"
+ cy="1525"
+ r="16"
+ id="circle100" />
+</svg>
diff --git a/tools/genborders.js b/tools/genborders.js
new file mode 100644
index 0000000..9c50721
--- /dev/null
+++ b/tools/genborders.js
@@ -0,0 +1,53 @@
+const fs = require("fs")
+
+const { round, floor, ceil } = Math
+
+let output = {}
+let mode, name, x, y, w, h, cx, cy, rx, ry
+
+function flush() {
+ if (mode === 'circle') {
+ output[name] = { x: cx, y: cy }
+ }
+ x = y = w = h = cx = cy = rx = ry = 0
+ name = null
+}
+
+for (let line of fs.readFileSync("tools/borders.svg", "utf-8").split("\n")) {
+ line = line.trim()
+ if (line.startsWith("<rect")) {
+ flush()
+ mode = "rect"
+ x = y = w = h = 0
+ } else if (line.startsWith("<ellipse") || line.startsWith("<circle")) {
+ flush()
+ mode = "circle"
+ cx = cy = rx = ry = 0
+ } else if (line.startsWith('x="'))
+ x = round(Number(line.split('"')[1]))
+ else if (line.startsWith('y="'))
+ y = round(Number(line.split('"')[1]))
+ else if (line.startsWith('width="'))
+ w = round(Number(line.split('"')[1]))
+ else if (line.startsWith('height="'))
+ h = round(Number(line.split('"')[1]))
+ else if (line.startsWith('cx="'))
+ cx = round(Number(line.split('"')[1]))
+ else if (line.startsWith('cy="'))
+ cy = round(Number(line.split('"')[1]))
+ else if (line.startsWith('r="'))
+ rx = ry = round(Number(line.split('"')[1]))
+ else if (line.startsWith('rx="'))
+ rx = round(Number(line.split('"')[1]))
+ else if (line.startsWith('ry="'))
+ ry = round(Number(line.split('"')[1]))
+ else if (line.startsWith('inkscape:label="'))
+ name = line.split('"')[1]
+}
+
+flush()
+
+console.log("const BORDERS_XY = {")
+for (let key in output)
+ console.log("\t\"" + key + "\": " + JSON.stringify(output[key]) + ",")
+console.log("}")
diff --git a/tools/makeborders.js b/tools/makeborders.js
new file mode 100644
index 0000000..a54a36c
--- /dev/null
+++ b/tools/makeborders.js
@@ -0,0 +1,32 @@
+const print = console.log
+
+const data = require("../data.js")
+
+var w = 1688
+var h = 1950
+var m = "../map75.png"
+
+print(`<?xml version="1.0" encoding="UTF-8"?>
+<svg
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="${w}"
+ height="${h}"
+>
+<image xlink:href="${m}" x="0" y="0" width="${w}" height="${h}" image-rendering="pixelated" sodipodi:insensitive="true" />`)
+
+for (let id = 0; id < data.BORDERS.length; ++id) {
+ if (data.BORDERS[id]) {
+ let a = (id / 100) | 0
+ let b = id % 100
+ let x = (data.AREAS[a].x + data.AREAS[b].x) >> 1
+ let y = (data.AREAS[a].y + data.AREAS[b].y) >> 1
+ let label = data.AREAS[a].name + " / " + data.AREAS[b].name
+ print(`<circle inkscape:label="${label}" cx="${x}" cy="${y}" r="16"/>`)
+
+ }
+}
+
+print(`</svg>`)