mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
feat: burg groups - relocate burg
This commit is contained in:
parent
4472ead06b
commit
984d351e4d
2 changed files with 18 additions and 31 deletions
|
|
@ -5380,7 +5380,9 @@
|
||||||
<th data-tip="Select allowed features">Features</th>
|
<th data-tip="Select allowed features">Features</th>
|
||||||
<th data-tip="Number of burgs in group">Count</th>
|
<th data-tip="Number of burgs in group">Count</th>
|
||||||
<th data-tip="Activate/deactivate group">Active</th>
|
<th data-tip="Activate/deactivate group">Active</th>
|
||||||
<th data-tip="Select group to be assigned if other groups are not passed">Default</th>
|
<th data-tip="Select group to be assigned if burg doesn't pass the criteria for other groups">
|
||||||
|
Default
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="burgGroupsBody"></tbody>
|
<tbody id="burgGroupsBody"></tbody>
|
||||||
|
|
|
||||||
|
|
@ -302,41 +302,26 @@ function editBurg(id) {
|
||||||
function relocateBurgOnClick() {
|
function relocateBurgOnClick() {
|
||||||
const cells = pack.cells;
|
const cells = pack.cells;
|
||||||
const point = d3.mouse(this);
|
const point = d3.mouse(this);
|
||||||
const cell = findCell(point[0], point[1]);
|
const cellId = findCell(...point);
|
||||||
const id = +elSelected.attr("data-id");
|
const id = +elSelected.attr("data-id");
|
||||||
const burg = pack.burgs[id];
|
const burg = pack.burgs[id];
|
||||||
|
|
||||||
if (cells.h[cell] < 20) {
|
if (cells.h[cellId] < 20) return tip("Cannot place burg into the water! Select a land cell", false, "error");
|
||||||
tip("Cannot place burg into the water! Select a land cell", false, "error");
|
if (cells.burg[cellId] && cells.burg[cellId] !== id)
|
||||||
return;
|
return tip("There is already a burg in this cell. Please select a free cell", false, "error");
|
||||||
}
|
|
||||||
|
|
||||||
if (cells.burg[cell] && cells.burg[cell] !== id) {
|
const newState = cells.state[cellId];
|
||||||
tip("There is already a burg in this cell. Please select a free cell", false, "error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const newState = cells.state[cell];
|
|
||||||
const oldState = burg.state;
|
const oldState = burg.state;
|
||||||
|
if (newState !== oldState && burg.capital)
|
||||||
if (newState !== oldState && burg.capital) {
|
return tip("Capital cannot be relocated into another state!", false, "error");
|
||||||
tip("Capital cannot be relocated into another state!", false, "error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// change UI
|
// change UI
|
||||||
const x = rn(point[0], 2),
|
const x = rn(point[0], 2);
|
||||||
y = rn(point[1], 2);
|
const y = rn(point[1], 2);
|
||||||
burgIcons
|
|
||||||
.select("[data-id='" + id + "']")
|
burgIcons.select(`#burg${id}`).attr("x", x).attr("y", y);
|
||||||
.attr("transform", null)
|
burgLabels.select(`#burgLabel${id}`).attr("transform", null).attr("x", x).attr("y", y);
|
||||||
.attr("cx", x)
|
|
||||||
.attr("cy", y);
|
|
||||||
burgLabels
|
|
||||||
.select("text[data-id='" + id + "']")
|
|
||||||
.attr("transform", null)
|
|
||||||
.attr("x", x)
|
|
||||||
.attr("y", y);
|
|
||||||
const anchor = anchors.select("use[data-id='" + id + "']");
|
const anchor = anchors.select("use[data-id='" + id + "']");
|
||||||
if (anchor.size()) {
|
if (anchor.size()) {
|
||||||
const size = anchor.attr("width");
|
const size = anchor.attr("width");
|
||||||
|
|
@ -347,8 +332,8 @@ function editBurg(id) {
|
||||||
|
|
||||||
// change data
|
// change data
|
||||||
cells.burg[burg.cell] = 0;
|
cells.burg[burg.cell] = 0;
|
||||||
cells.burg[cell] = id;
|
cells.burg[cellId] = id;
|
||||||
burg.cell = cell;
|
burg.cell = cellId;
|
||||||
burg.state = newState;
|
burg.state = newState;
|
||||||
burg.x = x;
|
burg.x = x;
|
||||||
burg.y = y;
|
burg.y = y;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue