mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v.0.59.18b
This commit is contained in:
parent
dad446cf75
commit
11e05e263f
2 changed files with 56 additions and 43 deletions
|
|
@ -31,8 +31,8 @@
|
||||||
<script src="libs/polylabel.min.js"></script>
|
<script src="libs/polylabel.min.js"></script>
|
||||||
<script src="libs/quantize.min.js" defer></script>
|
<script src="libs/quantize.min.js" defer></script>
|
||||||
<script src="libs/jquery.ui.touch-punch.min.js" defer></script>
|
<script src="libs/jquery.ui.touch-punch.min.js" defer></script>
|
||||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.59.17b"/>
|
<link rel="stylesheet" type="text/css" href="index.css?version=0.59.18b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.59.17b"/>
|
<link rel="stylesheet" type="text/css" href="icons.css?version=0.59.18b"/>
|
||||||
<link rel="stylesheet" type="text/css" href="libs/jquery-ui.css"/>
|
<link rel="stylesheet" type="text/css" href="libs/jquery-ui.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -1170,5 +1170,5 @@
|
||||||
<input type="file" accept=".txt" id="namesbaseToLoad">
|
<input type="file" accept=".txt" id="namesbaseToLoad">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js?version=0.59.17b"></script>
|
<script src="script.js?version=0.59.18b"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
55
script.js
55
script.js
|
|
@ -2632,13 +2632,12 @@ function fantasyMap() {
|
||||||
minHeight: 30, width: "auto", resizable: false,
|
minHeight: 30, width: "auto", resizable: false,
|
||||||
position: {my: "center top+20", at: "top", of: d3.event},
|
position: {my: "center top+20", at: "top", of: d3.event},
|
||||||
close: function() {
|
close: function() {
|
||||||
if ($("#riverNew").hasClass('pressed')) {completeNewRiver();}
|
if ($("#riverNew").hasClass('pressed')) completeNewRiver();
|
||||||
unselect();
|
unselect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const controlPoints = debug.append("g").attr("class", "controlPoints")
|
if (!debug.select(".controlPoints").size()) debug.append("g").attr("class", "controlPoints");
|
||||||
.attr("transform", elSelected.attr("transform"));
|
|
||||||
riverDrawPoints();
|
riverDrawPoints();
|
||||||
|
|
||||||
if (modules.editRiver) {return;}
|
if (modules.editRiver) {return;}
|
||||||
|
|
@ -2821,7 +2820,7 @@ function fantasyMap() {
|
||||||
// enter creation mode
|
// enter creation mode
|
||||||
$(".pressed").removeClass('pressed');
|
$(".pressed").removeClass('pressed');
|
||||||
$(this).addClass('pressed');
|
$(this).addClass('pressed');
|
||||||
elSelected.call(d3.drag().on("drag", null));
|
if (elSelected) elSelected.call(d3.drag().on("drag", null));
|
||||||
debug.select(".controlPoints").selectAll("*").remove();
|
debug.select(".controlPoints").selectAll("*").remove();
|
||||||
viewbox.style("cursor", "crosshair").on("click", newRiverAddPoint);
|
viewbox.style("cursor", "crosshair").on("click", newRiverAddPoint);
|
||||||
}
|
}
|
||||||
|
|
@ -2830,31 +2829,36 @@ function fantasyMap() {
|
||||||
function newRiverAddPoint() {
|
function newRiverAddPoint() {
|
||||||
const point = d3.mouse(this);
|
const point = d3.mouse(this);
|
||||||
addRiverPoint([point[0], point[1]]);
|
addRiverPoint([point[0], point[1]]);
|
||||||
if (elSelected.attr("data-river") !== "new") {
|
if (!elSelected || elSelected.attr("data-river") !== "new") {
|
||||||
const id = +$("#rivers > path").last().attr("id").slice(5) + 1;
|
const id = +$("#rivers > path").last().attr("id").slice(5) + 1;
|
||||||
elSelected = rivers.append("path").attr("data-river", "new").attr("id", "river"+id)
|
elSelected = rivers.append("path").attr("data-river", "new").attr("id", "river"+id)
|
||||||
.attr("data-width", 2).attr("data-increment", 1).on("click", completeNewRiver);
|
.attr("data-width", 2).attr("data-increment", 1).on("click", completeNewRiver);
|
||||||
} else {
|
} else {
|
||||||
redrawRiver();
|
redrawRiver();
|
||||||
|
let cell = diagram.find(point[0], point[1]).index;
|
||||||
|
let f = cells[cell].fn;
|
||||||
|
let ocean = !features[f].land && features[f].border;
|
||||||
|
if (ocean && debug.select(".controlPoints").selectAll("circle").size() > 5) completeNewRiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeNewRiver() {
|
function completeNewRiver() {
|
||||||
$("#riverNew").removeClass('pressed');
|
$("#riverNew").removeClass('pressed');
|
||||||
restoreDefaultEvents();
|
restoreDefaultEvents();
|
||||||
if (elSelected.attr("data-river") === "new") {
|
if (!elSelected || elSelected.attr("data-river") !== "new") return;
|
||||||
redrawRiver();
|
redrawRiver();
|
||||||
elSelected.attr("data-river", "");
|
elSelected.attr("data-river", "");
|
||||||
elSelected.call(d3.drag().on("start", riverDrag)).on("click", editRiver);
|
elSelected.call(d3.drag().on("start", riverDrag)).on("click", editRiver);
|
||||||
const river = +elSelected.attr("id").slice(5);
|
const r = +elSelected.attr("id").slice(5);
|
||||||
debug.select(".controlPoints").selectAll("circle").each(function() {
|
debug.select(".controlPoints").selectAll("circle").each(function() {
|
||||||
const x = +d3.select(this).attr("cx");
|
const x = +d3.select(this).attr("cx");
|
||||||
const y = +d3.select(this).attr("cy");
|
const y = +d3.select(this).attr("cy");
|
||||||
const cell = diagram.find(x, y, 3);
|
const cell = diagram.find(x, y, 3);
|
||||||
if (!cell) {return;}
|
if (!cell) return;
|
||||||
if (cells[cell.index].river === undefined) {cells[cell.index].river = r;}
|
if (cells[cell.index].river === undefined) cells[cell.index].river = r;
|
||||||
});
|
});
|
||||||
}
|
unselect();
|
||||||
|
debug.append("g").attr("class", "controlPoints");
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#riverCopy").click(function() {
|
$("#riverCopy").click(function() {
|
||||||
|
|
@ -2920,11 +2924,10 @@ function fantasyMap() {
|
||||||
|
|
||||||
if (this !== window) {
|
if (this !== window) {
|
||||||
elSelected = d3.select(this);
|
elSelected = d3.select(this);
|
||||||
const controlPoints = debug.append("g").attr("class", "controlPoints");
|
if (!debug.select(".controlPoints").size()) debug.append("g").attr("class", "controlPoints");
|
||||||
routeDrawPoints();
|
routeDrawPoints();
|
||||||
const group = d3.select(this.parentNode);
|
|
||||||
routeUpdateGroups();
|
routeUpdateGroups();
|
||||||
let routeType = group.attr("id");
|
let routeType = d3.select(this.parentNode).attr("id");
|
||||||
routeType.value = routeType;
|
routeType.value = routeType;
|
||||||
|
|
||||||
$("#routeEditor").dialog({
|
$("#routeEditor").dialog({
|
||||||
|
|
@ -4115,11 +4118,23 @@ function fantasyMap() {
|
||||||
for (let f = 0; f < features.length; f++) {
|
for (let f = 0; f < features.length; f++) {
|
||||||
if (!features[f].land) continue;
|
if (!features[f].land) continue;
|
||||||
var manorsOnIsland = $.grep(land, function(e) {return e.manor !== undefined && e.fn === f;});
|
var manorsOnIsland = $.grep(land, function(e) {return e.manor !== undefined && e.fn === f;});
|
||||||
if (manorsOnIsland.length > 0) {
|
if (!manorsOnIsland.length) continue;
|
||||||
var ports = $.grep(manorsOnIsland, function(p) {return p.port;});
|
|
||||||
if (ports.length === 0) {
|
// if lake port is the only port on lake, remove port
|
||||||
var portCandidates = $.grep(manorsOnIsland, function(c) {return c.harbor && c.ctype === 1;});
|
var lakePorts = $.grep(manorsOnIsland, function(p) {return p.port && !features[p.port].border;});
|
||||||
if (portCandidates.length > 0) {
|
if (lakePorts.length) {
|
||||||
|
var lakes = [];
|
||||||
|
lakePorts.forEach(function(p) {lakes[p.port] = lakes[p.port] ? lakes[p.port] + 1 : 1;});
|
||||||
|
lakePorts.forEach(function(p) {if (lakes[p.port] === 1) p.port = undefined;});
|
||||||
|
}
|
||||||
|
|
||||||
|
// check how many ocean ports are there on island
|
||||||
|
var oceanPorts = $.grep(manorsOnIsland, function(p) {return p.port && features[p.port].border;});
|
||||||
|
if (oceanPorts.length) continue;
|
||||||
|
var portCandidates = $.grep(manorsOnIsland, function(c) {
|
||||||
|
return c.harbor && features[cells[c.harbor].fn].border && c.ctype === 1;
|
||||||
|
});
|
||||||
|
if (portCandidates.length) {
|
||||||
// No ports on island. Upgrading first burg to port
|
// No ports on island. Upgrading first burg to port
|
||||||
const candidate = portCandidates[0];
|
const candidate = portCandidates[0];
|
||||||
candidate.harbor = 1;
|
candidate.harbor = 1;
|
||||||
|
|
@ -4131,9 +4146,7 @@ function fantasyMap() {
|
||||||
candidate.score += Math.floor((portCandidates.length - 1) / 2);
|
candidate.score += Math.floor((portCandidates.length - 1) / 2);
|
||||||
} else {
|
} else {
|
||||||
// No ports on island. Reducing score for burgs
|
// No ports on island. Reducing score for burgs
|
||||||
manorsOnIsland.map(function(e) {e.score -= 2;});
|
manorsOnIsland.forEach(function(e) {e.score -= 2;});
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.timeEnd("checkAccessibility");
|
console.timeEnd("checkAccessibility");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue