diff --git a/index.html b/index.html index f8570efc..f600e0ff 100644 --- a/index.html +++ b/index.html @@ -2377,10 +2377,10 @@ - + Paste here:
-
Please note icons look different in different browsers!
+
Emojis look different in different browsers. Visit Emojipedia to check and find more
diff --git a/modules/military-generator.js b/modules/military-generator.js index bce56ef8..1bb02e92 100644 --- a/modules/military-generator.js +++ b/modules/military-generator.js @@ -21,7 +21,11 @@ "ranged": {"Nomadic":.9, "Highland":1.3, "Lake":1, "Naval":.8, "Hunting":2, "River":.8}, "mounted": {"Nomadic":2.3, "Highland":.6, "Lake":.7, "Naval":.3, "Hunting":.7, "River":.8}, "machinery":{"Nomadic":.8, "Highland":1.4, "Lake":1.1, "Naval":1.4, "Hunting":.4, "River":1.1}, - "naval": {"Nomadic":.5, "Highland":.5, "Lake":1.2, "Naval":1.8, "Hunting":.7, "River":1.2} + "naval": {"Nomadic":.5, "Highland":.5, "Lake":1.2, "Naval":1.8, "Hunting":.7, "River":1.2}, + // non-default generic: + "armored": {"Nomadic":1, "Highland":.5, "Lake":1, "Naval":1, "Hunting":.7, "River":1.1}, + "aviation": {"Nomadic":.5, "Highland":.5, "Lake":1.2, "Naval":1.2, "Hunting":.6, "River":1.2}, + "magical": {"Nomadic":1, "Highland":2, "Lake":1, "Naval":1, "Hunting":1, "River":1} }; valid.forEach(s => { @@ -59,7 +63,7 @@ for (const u of options.military) { const perc = +u.rural; - if (isNaN(perc) || perc <= 0) continue; + if (isNaN(perc) || perc <= 0 || !s.temp[u.name]) continue; let army = m * perc; // basic army for rural cell if (nomadic) { // "nomadic" biomes special rules @@ -105,7 +109,7 @@ for (const u of options.military) { const perc = +u.urban; - if (isNaN(perc) || perc <= 0) continue; + if (isNaN(perc) || perc <= 0 || !s.temp[u.name]) continue; let army = m * perc; // basic army for rural cell if (u.type === "naval" && !b.port) continue; // only ports produce naval units @@ -113,20 +117,24 @@ if (nomadic) { // "nomadic" biomes special rules if (u.type === "melee") army /= 3; else if (u.type === "machinery") army /= 2; else - if (u.type === "mounted") army *= 3; + if (u.type === "mounted") army *= 3; else + if (u.type === "armored") army *= 2; } if (wetland) { // "wet" biomes special rules if (u.type === "melee") army *= 1.2; else if (u.type === "ranged") army *= 1.4; else if (u.type === "machinery") army *= 1.2; else - if (u.type === "mounted") army /= 4; + if (u.type === "mounted") army /= 4; else + if (u.type === "armored") army /= 3; } if (highland) { // highlands special rules if (u.type === "ranged") army *= 2; else if (u.type === "naval") army /= 3; else - if (u.type === "mounted") army /= 3; + if (u.type === "mounted") army /= 3; else + if (u.type === "armored") army /= 2; else + if (u.type === "magical") army *= 2; } const t = rn(army * s.temp[u.name] * populationRate.value); @@ -265,6 +273,9 @@ if (type === "ranged") return "🏹"; if (type === "mounted") return "🐴"; if (type === "machinery") return "💣"; + if (type === "armored") return "🐢"; + if (type === "aviation") return "🦅"; + if (type === "magical") return "🔮"; else return "⚔️"; } diff --git a/modules/ui/military-overview.js b/modules/ui/military-overview.js index dc0c850f..a494cbf0 100644 --- a/modules/ui/military-overview.js +++ b/modules/ui/military-overview.js @@ -173,7 +173,7 @@ function overviewMilitary() { } function militaryCustomize() { - const types = ["melee", "ranged", "mounted", "machinery", "naval"]; + const types = ["melee", "ranged", "mounted", "machinery", "naval", "armored", "aviation", "magical"]; const table = document.getElementById("militaryOptions").querySelector("tbody"); removeUnitLines(); options.military.map(u => addUnitLine(u)); @@ -182,8 +182,8 @@ function overviewMilitary() { title: "Edit Military Units", resizable: false, width: fitContent(), position: {my: "center", at: "center", of: "svg"}, buttons: { - Apply: function() {applyMilitaryOptions(); $(this).dialog("close");}, - Add: () => addUnitLine({name: "custom"+rand(1000), rural: .2, urban: .5, crew: 1, type: "melee"}), + Apply: applyMilitaryOptions, + Add: () => addUnitLine({name: "custom"+militaryOptionsTable.rows.length, rural: .2, urban: .5, crew: 1, type: "melee"}), Restore: restoreDefaultUnits, Cancel: function() {$(this).dialog("close");} }, open: function() { @@ -221,9 +221,17 @@ function overviewMilitary() { } function applyMilitaryOptions() { - options.military = Array.from(table.querySelectorAll("tr")).map(r => { + const unitLines = Array.from(table.querySelectorAll("tr")); + const names = unitLines.map(r => r.querySelector("input").value.replace(/[&\/\\#, +()$~%.'":*?<>{}]/g, '_')); + if (new Set(names).size !== names.length) { + tip("All units should have unique names", false, "error"); + return; + } + + $("#militaryOptions").dialog("close"); + options.military = unitLines.map((r, i) => { const [name, rural, urban, crew, type, separate] = Array.from(r.querySelectorAll("input, select")).map(d => d.value||d.checked); - return {name:name.replace(/[&\/\\#, +()$~%.'":*?<>{}]/g, '_'), rural:+rural||0, urban:+urban||0, crew:+crew||0, type, separate:+separate||0}; + return {name:names[i], rural:+rural||0, urban:+urban||0, crew:+crew||0, type, separate:+separate||0}; }); localStorage.setItem("military", JSON.stringify(options.military)); Military.generate(); diff --git a/modules/ui/regiment-editor.js b/modules/ui/regiment-editor.js index a02eff41..6cc64271 100644 --- a/modules/ui/regiment-editor.js +++ b/modules/ui/regiment-editor.js @@ -118,7 +118,10 @@ function editRegiment(selector) { $("#alert").dialog({ resizable: false, width: fitContent(), title: "Select emblem", - buttons: {Close: function() {$(this).dialog("close");}} + buttons: { + Emojipedia: function() {openURL("https://emojipedia.org/");}, + Close: function() {$(this).dialog("close");} + } }); function showTip(e) {