mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.4.08
This commit is contained in:
parent
2d2432acb2
commit
bb0251c020
3 changed files with 17 additions and 13 deletions
|
|
@ -1718,6 +1718,10 @@ rect.fillRect {
|
||||||
width: 4em;
|
width: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#militaryOptionsTable button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
#gridOverlay {
|
#gridOverlay {
|
||||||
fill: none;
|
fill: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2660,7 +2660,7 @@
|
||||||
<button id="convertColorsButton" data-tip="Set number of colors" class="icon-signal"></button>
|
<button id="convertColorsButton" data-tip="Set number of colors" class="icon-signal"></button>
|
||||||
<input id="convertColors" value="18" style="display: none"/>
|
<input id="convertColors" value="18" style="display: none"/>
|
||||||
<button id="convertComplete" data-tip="Complete the conversion. All unassigned colors will be considered as ocean" class="icon-check"></button>
|
<button id="convertComplete" data-tip="Complete the conversion. All unassigned colors will be considered as ocean" class="icon-check"></button>
|
||||||
<button id="convertCancel" data-tip="Cancel the conversion. Previous heoghtmap will be restored" class="icon-cancel"></button>
|
<button id="convertCancel" data-tip="Cancel the conversion. Previous heightmap will be restored" class="icon-cancel"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-tip="Set opacity of the loaded image" style="padding-top: 4px"><i>Overlay opacity:</i><br>
|
<div data-tip="Set opacity of the loaded image" style="padding-top: 4px"><i>Overlay opacity:</i><br>
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
let x = p[i][0], y = p[i][1], n = 0;
|
let x = p[i][0], y = p[i][1], n = 0;
|
||||||
if (u.type === "naval") {let haven = cells.haven[i]; x = p[haven][0], y = p[haven][1]; n = 1}; // place naval to sea
|
if (u.type === "naval") {let haven = cells.haven[i]; x = p[haven][0], y = p[haven][1]; n = 1}; // place naval to sea
|
||||||
s.temp.platoons.push({cell: i, a:t, t, x, y, u:u.name, n, s:u.separate});
|
s.temp.platoons.push({cell: i, a:t, t, x, y, u:u.name, n, s:u.separate, type:u.type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,8 +140,8 @@
|
||||||
const t = rn(army * s.temp[u.name] * populationRate.value);
|
const t = rn(army * s.temp[u.name] * populationRate.value);
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
let x = p[b.cell][0], y = p[b.cell][1], n = 0;
|
let x = p[b.cell][0], y = p[b.cell][1], n = 0;
|
||||||
if (u.type === "naval") {let haven = cells.haven[b.cell]; x = p[haven][0], y = p[haven][1]; n = 1}; // place naval to sea
|
if (u.type === "naval") {let haven = cells.haven[b.cell]; x = p[haven][0], y = p[haven][1]; n = 1}; // place naval in sea cell
|
||||||
s.temp.platoons.push({cell: b.cell, a:t, t, x, y, u:u.name, n, s:u.separate});
|
s.temp.platoons.push({cell: b.cell, a:t, t, x, y, u:u.name, n, s:u.separate, type:u.type});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +154,8 @@
|
||||||
}()
|
}()
|
||||||
|
|
||||||
const expected = 3 * populationRate.value; // expected regiment size
|
const expected = 3 * populationRate.value; // expected regiment size
|
||||||
const mergeable = (n, s) => (!n.s && !s.s) || n.u === s.u;
|
const mergeable = (n0, n1) => (!n0.s && !n1.s) || n0.type === n1.type; // check if regiments can be merged
|
||||||
|
|
||||||
// get regiments for each state
|
// get regiments for each state
|
||||||
valid.forEach(s => {
|
valid.forEach(s => {
|
||||||
s.military = createRegiments(s.temp.platoons, s);
|
s.military = createRegiments(s.temp.platoons, s);
|
||||||
|
|
@ -164,7 +165,7 @@
|
||||||
|
|
||||||
function createRegiments(nodes, s) {
|
function createRegiments(nodes, s) {
|
||||||
if (!nodes.length) return [];
|
if (!nodes.length) return [];
|
||||||
nodes.sort((a,b) => a.a - b.a);
|
nodes.sort((a,b) => a.a - b.a); // form regiments in cells with most troops
|
||||||
const tree = d3.quadtree(nodes, d => d.x, d => d.y);
|
const tree = d3.quadtree(nodes, d => d.x, d => d.y);
|
||||||
nodes.forEach(n => {
|
nodes.forEach(n => {
|
||||||
tree.remove(n);
|
tree.remove(n);
|
||||||
|
|
@ -186,7 +187,7 @@
|
||||||
n0.t = 0;
|
n0.t = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse regiments data to easy-readable json
|
// parse regiments data
|
||||||
const regiments = nodes.filter(n => n.t).sort((a,b) => b.t - a.t).map((r, i) => {
|
const regiments = nodes.filter(n => n.t).sort((a,b) => b.t - a.t).map((r, i) => {
|
||||||
const u = {}; u[r.u] = r.a;
|
const u = {}; u[r.u] = r.a;
|
||||||
(r.childen||[]).forEach(n => u[n.u] = u[n.u] ? u[n.u] += n.a : n.a);
|
(r.childen||[]).forEach(n => u[n.u] = u[n.u] ? u[n.u] += n.a : n.a);
|
||||||
|
|
@ -290,9 +291,8 @@
|
||||||
|
|
||||||
// get default regiment emblem
|
// get default regiment emblem
|
||||||
const getEmblem = function(r) {
|
const getEmblem = function(r) {
|
||||||
if (r.n) return "🌊";
|
if (!r.n && !Object.values(r.u).length) return "🔰"; // "Newbie" regiment without troops
|
||||||
if (!Object.values(r.u).length) return "🔰"; // regiment without troops
|
if (!r.n && pack.states[r.state].form === "Monarchy" && cells.burg[r.cell] && pack.burgs[cells.burg[r.cell]].capital) return "👑"; // "Royal" regiment based in capital
|
||||||
if (cells.burg[r.cell] && pack.burgs[cells.burg[r.cell]].capital) return "👑"; // "Royal" regiment based in capital
|
|
||||||
const mainUnit = Object.entries(r.u).sort((a,b) => b[1]-a[1])[0][0]; // unit with more troops in regiment
|
const mainUnit = Object.entries(r.u).sort((a,b) => b[1]-a[1])[0][0]; // unit with more troops in regiment
|
||||||
const unit = options.military.find(u => u.name === mainUnit);
|
const unit = options.military.find(u => u.name === mainUnit);
|
||||||
return unit.icon;
|
return unit.icon;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue