const fs = require('fs') const { units } = require("../rawdata.js"); var out = [] function print(s) { out.push(s) } function print_defs() { print(` `) } const 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", "i-tank": "armor", "infantry": "infantry", "mech. inf.": "mechanized_infantry", "mob. a/t": "mobile_antitank", // "mot. a/t": "motorized_antitank_new", "mot. a/t": "motorized_antitank_old", "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" } function print_units(show_text) { out = [] print_defs() 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(``); if (show_text) { 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(``); return out.join("\n") } fs.writeFileSync("units.svg", print_units(true)) fs.writeFileSync("units-simple.svg", print_units(false))