This commit is contained in:
Azgaar 2020-04-02 19:44:30 +03:00
parent 3fe1c8d27e
commit b8514c3780
4 changed files with 36 additions and 14 deletions

View file

@ -2377,10 +2377,10 @@
<input id="markerIconShiftX" data-tip="Change icon horizontal shift" type="number" value=50 style="width:3em"> <input id="markerIconShiftX" data-tip="Change icon horizontal shift" type="number" value=50 style="width:3em">
<i data-tip="Change marker vertical shift" class="icon-resize-vertical"></i> <i data-tip="Change marker vertical shift" class="icon-resize-vertical"></i>
<input id="markerIconShiftY" data-tip="Change vertical shift" type="number" min=0 max=100 value=50 style="width:3em"> <input id="markerIconShiftY" data-tip="Change vertical shift" type="number" min=0 max=100 value=50 style="width:3em">
<i data-tip="Paste custom unicode symbol to use as icon" class="icon-pencil"></i> <span data-tip="Paste custom unicode symbol to use as icon">Paste here:</span>
<input id="markerIconCustom" data-tip="Paste custom unicode symbol to use as icon" style="width:3em"> <input id="markerIconCustom" data-tip="Paste custom unicode symbol to use as icon" style="width:3em">
<table id="markerIconTable"></table> <table id="markerIconTable"></table>
<div style="font-style: italic; color: darkgrey;">Please note icons look different in different browsers!</div> <div style="font-style: italic; color: darkgrey;">Emojis look different in different browsers. Visit <a href="https://emojipedia.org/" rel="noopener" target="_blank">Emojipedia</a> to check and find more</div>
</div> </div>
<button id="markerStyle" data-tip="Change marker size and colors" class="icon-brush"></button> <button id="markerStyle" data-tip="Change marker size and colors" class="icon-brush"></button>

View file

@ -21,7 +21,11 @@
"ranged": {"Nomadic":.9, "Highland":1.3, "Lake":1, "Naval":.8, "Hunting":2, "River":.8}, "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}, "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}, "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 => { valid.forEach(s => {
@ -59,7 +63,7 @@
for (const u of options.military) { for (const u of options.military) {
const perc = +u.rural; 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 let army = m * perc; // basic army for rural cell
if (nomadic) { // "nomadic" biomes special rules if (nomadic) { // "nomadic" biomes special rules
@ -105,7 +109,7 @@
for (const u of options.military) { for (const u of options.military) {
const perc = +u.urban; 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 let army = m * perc; // basic army for rural cell
if (u.type === "naval" && !b.port) continue; // only ports produce naval units if (u.type === "naval" && !b.port) continue; // only ports produce naval units
@ -113,20 +117,24 @@
if (nomadic) { // "nomadic" biomes special rules if (nomadic) { // "nomadic" biomes special rules
if (u.type === "melee") army /= 3; else if (u.type === "melee") army /= 3; else
if (u.type === "machinery") army /= 2; 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 (wetland) { // "wet" biomes special rules
if (u.type === "melee") army *= 1.2; else if (u.type === "melee") army *= 1.2; else
if (u.type === "ranged") army *= 1.4; else if (u.type === "ranged") army *= 1.4; else
if (u.type === "machinery") army *= 1.2; 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 (highland) { // highlands special rules
if (u.type === "ranged") army *= 2; else if (u.type === "ranged") army *= 2; else
if (u.type === "naval") army /= 3; 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); const t = rn(army * s.temp[u.name] * populationRate.value);
@ -265,6 +273,9 @@
if (type === "ranged") return "🏹"; if (type === "ranged") return "🏹";
if (type === "mounted") return "🐴"; if (type === "mounted") return "🐴";
if (type === "machinery") return "💣"; if (type === "machinery") return "💣";
if (type === "armored") return "🐢";
if (type === "aviation") return "🦅";
if (type === "magical") return "🔮";
else return "⚔️"; else return "⚔️";
} }

View file

@ -173,7 +173,7 @@ function overviewMilitary() {
} }
function militaryCustomize() { 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"); const table = document.getElementById("militaryOptions").querySelector("tbody");
removeUnitLines(); removeUnitLines();
options.military.map(u => addUnitLine(u)); options.military.map(u => addUnitLine(u));
@ -182,8 +182,8 @@ function overviewMilitary() {
title: "Edit Military Units", resizable: false, width: fitContent(), title: "Edit Military Units", resizable: false, width: fitContent(),
position: {my: "center", at: "center", of: "svg"}, position: {my: "center", at: "center", of: "svg"},
buttons: { buttons: {
Apply: function() {applyMilitaryOptions(); $(this).dialog("close");}, Apply: applyMilitaryOptions,
Add: () => addUnitLine({name: "custom"+rand(1000), rural: .2, urban: .5, crew: 1, type: "melee"}), Add: () => addUnitLine({name: "custom"+militaryOptionsTable.rows.length, rural: .2, urban: .5, crew: 1, type: "melee"}),
Restore: restoreDefaultUnits, Restore: restoreDefaultUnits,
Cancel: function() {$(this).dialog("close");} Cancel: function() {$(this).dialog("close");}
}, open: function() { }, open: function() {
@ -221,9 +221,17 @@ function overviewMilitary() {
} }
function applyMilitaryOptions() { 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); 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)); localStorage.setItem("military", JSON.stringify(options.military));
Military.generate(); Military.generate();

View file

@ -118,7 +118,10 @@ function editRegiment(selector) {
$("#alert").dialog({ $("#alert").dialog({
resizable: false, width: fitContent(), title: "Select emblem", 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) { function showTip(e) {