mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
feat: random encounters
This commit is contained in:
parent
b2241b1cd3
commit
fbe5f4ad55
5 changed files with 35 additions and 19 deletions
|
|
@ -2077,7 +2077,6 @@ div.textual span,
|
|||
}
|
||||
|
||||
#notesBody > iframe {
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7980,7 +7980,7 @@
|
|||
<script src="modules/routes-generator.js"></script>
|
||||
<script src="modules/religions-generator.js?v=1.89.36"></script>
|
||||
<script src="modules/military-generator.js"></script>
|
||||
<script src="modules/markers-generator.js?v=1.89.34"></script>
|
||||
<script src="modules/markers-generator.js?v=1.93.04"></script>
|
||||
<script src="modules/coa-generator.js?v=1.91.00"></script>
|
||||
<script src="modules/submap.js?v=1.91.05"></script>
|
||||
<script src="libs/polylabel.min.js"></script>
|
||||
|
|
@ -7991,7 +7991,7 @@
|
|||
<script src="modules/ui/measurers.js?v=1.87.02"></script>
|
||||
<script src="modules/ui/stylePresets.js?v=1.89.11"></script>
|
||||
|
||||
<script src="modules/ui/general.js?v=1.93.01"></script>
|
||||
<script src="modules/ui/general.js?v=1.93.04"></script>
|
||||
<script src="modules/ui/options.js?v=1.93.03"></script>
|
||||
<script src="main.js?v=1.93.02"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ window.Markers = (function () {
|
|||
{type: "rifts", icon: "🎆", min: 5, each: 3000, multiplier: +isFantasy, list: listRifts, add: addRift},
|
||||
{type: "disturbed-burials", icon: "💀", min: 20, each: 3000, multiplier: +isFantasy, list: listDisturbedBurial, add: addDisturbedBurial},
|
||||
{type: "necropolises", icon: "🪦", min: 20, each: 1000, multiplier: 1, list: listNecropolis, add: addNecropolis},
|
||||
{type: "encounters", icon: "🧙", min: 10, each: 1000, multiplier: 1, list: listEncounters, add: addEncounter},
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -603,7 +604,7 @@ window.Markers = (function () {
|
|||
function addDungeon(id, cell) {
|
||||
const dungeonSeed = `${seed}${cell}`;
|
||||
const name = "Dungeon";
|
||||
const legend = `<div>Undiscovered dungeon. See <a href="https://watabou.github.io/one-page-dungeon/?seed=${dungeonSeed}" target="_blank">One page dungeon</a></div><iframe src="https://watabou.github.io/one-page-dungeon/?seed=${dungeonSeed}" sandbox="allow-scripts allow-same-origin"></iframe>`;
|
||||
const legend = `<div>Undiscovered dungeon. See <a href="https://watabou.github.io/one-page-dungeon/?seed=${dungeonSeed}" target="_blank">One page dungeon</a></div><iframe style="pointer-events: none;" src="https://watabou.github.io/one-page-dungeon/?seed=${dungeonSeed}" sandbox="allow-scripts allow-same-origin"></iframe>`;
|
||||
notes.push({id, name, legend});
|
||||
}
|
||||
|
||||
|
|
@ -849,18 +850,16 @@ window.Markers = (function () {
|
|||
const culture = cells.culture[cell];
|
||||
const biome = cells.biome[cell];
|
||||
const height = cells.p[cell];
|
||||
const locality =
|
||||
height >= 70
|
||||
? "highlander"
|
||||
: [1, 2].includes(biome)
|
||||
? "desert"
|
||||
: [3, 4].includes(biome)
|
||||
? "mounted"
|
||||
: [5, 6, 7, 8, 9].includes(biome)
|
||||
? "forest"
|
||||
: biome === 12
|
||||
? "swamp"
|
||||
: "angry";
|
||||
|
||||
const locality = ((height, biome) => {
|
||||
if (height >= 70) return "highlander";
|
||||
if ([1, 2].includes(biome)) return "desert";
|
||||
if ([3, 4].includes(biome)) return "mounted";
|
||||
if ([5, 6, 7, 8, 9].includes(biome)) return "forest";
|
||||
if (biome === 12) return "swamp";
|
||||
return "angry";
|
||||
})(height, biome);
|
||||
|
||||
const name = `${Names.getCulture(culture)} ${ra(animals)}`;
|
||||
const legend = `A gang of ${locality} ${rw(types)}.`;
|
||||
notes.push({id, name, legend});
|
||||
|
|
@ -1270,5 +1269,16 @@ window.Markers = (function () {
|
|||
notes.push({id, name, legend});
|
||||
}
|
||||
|
||||
function listEncounters({cells}) {
|
||||
return cells.i.filter(i => !occupied[i] && cells.h[i] >= 20 && cells.pop[i] > 1);
|
||||
}
|
||||
|
||||
function addEncounter(id, cell) {
|
||||
const name = "Random encounter";
|
||||
const encounterSeed = cell; // use just cell Id to not overwhelm the Vercel KV database
|
||||
const legend = `<div>You have encountered a character.</div><iframe src="https://deorum.vercel.app/encounter/${encounterSeed}" width="375" height="600" sandbox="allow-scripts allow-same-origin allow-popups"></iframe>`;
|
||||
notes.push({id, name, legend});
|
||||
}
|
||||
|
||||
return {add, generate, regenerate, getConfig, setConfig, deleteMarker};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ function handleMouseMove() {
|
|||
if (cellInfo?.offsetParent) updateCellInfo(point, i, gridCell);
|
||||
}
|
||||
|
||||
let currentNoteId = null; // store currently displayed node to not rerender to often
|
||||
|
||||
// show note box on hover (if any)
|
||||
function showNotes(e) {
|
||||
if (notesEditor?.offsetParent) return;
|
||||
|
|
@ -96,13 +98,17 @@ function showNotes(e) {
|
|||
|
||||
const note = notes.find(note => note.id === id);
|
||||
if (note !== undefined && note.legend !== "") {
|
||||
if (currentNoteId === id) return;
|
||||
currentNoteId = id;
|
||||
|
||||
document.getElementById("notes").style.display = "block";
|
||||
document.getElementById("notesHeader").innerHTML = note.name;
|
||||
document.getElementById("notesBody").innerHTML = note.legend;
|
||||
} else if (!options.pinNotes && !markerEditor?.offsetParent) {
|
||||
} else if (!options.pinNotes && !markerEditor?.offsetParent && !e.shiftKey) {
|
||||
document.getElementById("notes").style.display = "none";
|
||||
document.getElementById("notesHeader").innerHTML = "";
|
||||
document.getElementById("notesBody").innerHTML = "";
|
||||
currentNoteId = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +166,7 @@ function showMapTooltip(point, e, i, g) {
|
|||
}
|
||||
if (group === "labels") return tip("Click to edit the Label");
|
||||
|
||||
if (group === "markers") return tip("Click to edit the Marker and pin the marker note");
|
||||
if (group === "markers") return tip("Click to edit the Marker. Hold Shift to not close the assosiated note");
|
||||
|
||||
if (group === "ruler") {
|
||||
const tag = e.target.tagName;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
// version and caching control
|
||||
const version = "1.93.03"; // generator version, update each time
|
||||
const version = "1.93.04"; // generator version, update each time
|
||||
|
||||
{
|
||||
document.title += " v" + version;
|
||||
|
|
@ -28,6 +28,7 @@ const version = "1.93.03"; // generator version, update each time
|
|||
|
||||
<ul>
|
||||
<strong>Latest changes:</strong>
|
||||
<li>Random encounter markers (integration with <a href="https://deorum.vercel.app/" target="_blank">Deorum</a>)</li>
|
||||
<li>Auto-load of the last saved map is now optional (see <i>Onload behavior</i> in Options)</li>
|
||||
<li>New label placement algorithm for states</li>
|
||||
<li>North and South Poles temperature can be set independently</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue