From e8a5f5410a0e876d889a2a8137c34bb925f65408 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 8 Apr 2022 01:29:54 +0200 Subject: Assets. --- tools/genunits.js | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 tools/genunits.js (limited to 'tools/genunits.js') diff --git a/tools/genunits.js b/tools/genunits.js new file mode 100644 index 0000000..4e0f30e --- /dev/null +++ b/tools/genunits.js @@ -0,0 +1,227 @@ +const { units } = require("../data.js"); +const print = console.log; + +print(` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`); + +SYMBOLS = { + +"armor": ` + + +`, + +"armor_elite": ` + + +`, + +"armor_itank": ` + + + +`, + +"artillery": ` + + +`, + +"infantry": ` + + +`, + +"mechanized_infantry": ` + + +`, + +"mobile_antitank": ` + + + +`, + +"motorized_antitank_new": ` + + + +`, + +"motorized_antitank_old": ` + + +`, + +"motorized_infantry": ` + + + +`, + +"paratroopers": ` + + +`, + +"recon": ` + + +`, + +"self_propelled_artillery": ` + + + +`, + +} + +const TYPEMAP = { + "armor": "armor", + "artillery": "artillery", + "i-tank": "armor_itank", + "infantry": "infantry", + "mech. inf.": "mechanized_infantry", + "mob. a/t": "mobile_antitank", + "mot. a/t": "motorized_antitank_new", + "mot. inf.": "motorized_infantry", + "para": "paratroopers", + "recon": "recon", + "self prop. arty": "self_propelled_artillery", +}; + +// 94 units + +let smcp = /(IN|AU|NZ|SA|AT|H|G)$/; +smcp = /NEVER/; + +const COLORMAP = { + "italian": "#b0c5d4", + "german": "#f9e3b3", + "allied": "#cead78", + "Pol": "#ffffff", + "FF": "#8197cd", + "NZ": "#95c3d6", + "AU": "#f48480", + "SA": "#f9a64a", + "IN": "#84c88b", +} + +const BLACK = { + italian: "#221f1f", + german: "#004e2f", + allied: "#5c3a1e" +} + +let x = 0, y = 0; +for (let u of units) { + let type = TYPEMAP[u.type]; + let black = BLACK[u.nationality]; + let fill = COLORMAP[u.nationality]; + + let [a, b] = u.name.split('/'); + if (b) + b = b.split('+'); + + for (let n in COLORMAP) + if (a.endsWith(n) || (b && b[0] === n)) + fill = COLORMAP[n]; + + print(``); + + if (type === 'armor' && u.elite && u.nationality === 'allied') + type = 'armor_elite'; + + let symbol = SYMBOLS[type]; + print(symbol.replace(/#ccc/g, fill).replace(/#111/g, black).trim()); + + if (u.elite) + print(``); + else + print(``); + + print(``); + print(`${u.appearance}`); + print(`${a}`); + + if (b) { + if (b.length > 1) { + print(`${b[0]}`); + print(`${b[1]}`); + } else { + print(`${b[0]}`); + } + } + + print(``); + print(``); + x += 51; + if (x >= 510) { + y += 51; + x = 0; + } +} +print(``); +print(``); -- cgit v1.2.3