markers - generate from config file

This commit is contained in:
Azgaar 2021-09-25 21:49:34 +03:00
parent 3dea76777b
commit 60057c52ed
6 changed files with 192 additions and 147 deletions

View file

@ -428,6 +428,31 @@ button.options:hover {
cursor: pointer;
}
#options button i.icon-cog {
position: absolute;
padding: 0.1em 0.3em;
background-color: var(--bg-lighter);
border-radius: 50%;
visibility: hidden;
opacity: 0;
transition: 0.4s ease-in-out;
}
#options button i.icon-cog:hover {
color: #111;
background-color: var(--bg-light);
transform: rotateZ(180deg);
}
#options button i.icon-cog:active {
transform: translateY(1px);
}
#options button:hover i.icon-cog {
visibility: visible;
opacity: 1;
}
input[type="color"] {
-webkit-appearance: none;
cursor: pointer;

View file

@ -227,7 +227,7 @@
<div id="loading">
<div id="titleName"><t data-t="titleName">Azgaar's</t></div>
<div id="title"><t data-t="title">Fantasy Map Generator</t></div>
<div id="version"><t data-t="version">v. </t>1.66</div>
<div id="version"><t data-t="version">v. </t>1.7</div>
<p id="loading-text"><t data-t="loading">LOADING</t><span>.</span><span>.</span><span>.</span></p>
</div>
@ -1362,7 +1362,7 @@
<button id="regenerateCultures" data-tip="Click to regenerate cultures">Cultures</button>
<button id="regenerateMilitary" data-tip="Click to recalculate military forces based on current military options">Military</button>
<button id="regenerateIce" data-tip="Click to icebergs and glaciers">Ice</button>
<button id="regenerateMarkers" data-tip="Click to regenerate markers. Hold Ctrl and click to set markers number multiplier">Markers</button>
<button id="regenerateMarkers" data-tip="Click to regenerate markers">Markers <i id="configRegenerateMarkers" class="icon-cog" data-tip="Click to set number multiplier"></i></button>
<button id="regenerateZones" data-tip="Click to regenerate zones. Hold Ctrl and click to set zones number multiplier">Zones</button>
</div>

View file

@ -2,6 +2,7 @@
// https://github.com/Azgaar/Fantasy-Map-Generator
"use strict";
// TODO: pump version to 1.7
const version = "1.662"; // generator version
document.title += " v" + version;

View file

@ -868,6 +868,11 @@ function parseLoadedData(data) {
rivers.attr("style", null);
borders.attr("style", null);
}
if (version < 1.7) {
// v 1.7 changed markers data
// TODO: get markers data from svg
}
})();
void (function checkDataIntegrity() {

View file

@ -1,62 +1,86 @@
"use strict";
window.Markers = (function () {
let multiplier = 1;
let config = [];
function getDefaultConfig() {
const culturesSet = document.getElementById("culturesSet").value;
const isFantasy = culturesSet.includes("Fantasy");
return [
{type: "volcanoes", icon: "🌋", multiplier: 1, fn: addVolcanoes},
{type: "hot-springs", icon: "♨️", multiplier: 1, fn: addHotSprings},
{type: "mines", icon: "⛏️", multiplier: 1, fn: addMines},
{type: "bridges", icon: "🌉", multiplier: 1, fn: addBridges},
{type: "inns", icon: "🍻", multiplier: 1, fn: addInns},
{type: "lighthouses", icon: "🚨", multiplier: 1, fn: addLighthouses},
{type: "waterfalls", icon: "⟱", multiplier: 1, fn: addWaterfalls},
{type: "battlefields", icon: "⚔️", multiplier: 1, fn: addBattlefields},
{type: "dungeons", icon: "🗝️", multiplier: 1, fn: addDungeons},
{type: "lake-monsters", icon: "🐉", multiplier: 1, fn: addLakeMonsters},
{type: "sea-monsters", icon: "🦑", multiplier: 1, fn: addSeaMonsters},
{type: "hill-monsters", icon: "👹", multiplier: 1, fn: addHillMonsters},
{type: "sacred-mountains", icon: "🗻", multiplier: 1, fn: addSacredMountains},
{type: "sacred-forests", icon: "🌳", multiplier: 1, fn: addSacredForests},
{type: "sacred-pineries", icon: "🌲", multiplier: 1, fn: addSacredPineries},
{type: "sacred-palm-groves", icon: "🌴", multiplier: 1, fn: addSacredPalmGroves},
{type: "brigands", icon: "💰", multiplier: 1, fn: addBrigands},
{type: "pirates", icon: "🏴‍☠️", multiplier: 1, fn: addPirates},
{type: "statues", icon: "🗿", multiplier: 1, fn: addStatues},
{type: "ruines", icon: "🏺", multiplier: 1, fn: addRuines},
{type: "portals", icon: "🌀", multiplier: isFantasy, fn: addPortals}
];
}
const getConfig = () => config;
const setConfig = newConfig => {
config = newConfig;
};
const generate = function () {
setConfig(getDefaultConfig());
pack.markers = [];
generateTypes();
};
const regenerate = requestedMultiplier => {
if (requestedMultiplier === 0) return;
if (requestedMultiplier) multiplier = requestedMultiplier;
const regenerate = () => {
pack.markers = pack.markers.filter(({i, lock}) => {
if (lock) return true;
const id = `marker${i}`;
document.getElementById(id)?.remove();
const index = notes.findIndex(note => note.id === id);
if (index != -1) notes.splice(index, 1);
return false;
});
generateTypes();
};
const generateTypes = () => {
function generateTypes() {
TIME && console.time("addMarkers");
const culturesSet = document.getElementById("culturesSet").value;
// TODO: don't put multiple markers to the same cell
addVolcanoes();
addHotSprings();
addMines();
addBridges();
addInns();
addLighthouses();
addWaterfalls();
addBattlefields();
addDungeons();
addLakeMonsters();
addSeaMonsters();
addHillMonsters();
addSacredMountains();
addSacredForests();
addSacredPineries();
addSacredPalmGroves();
addBrigands();
addPirates();
addStatues();
addRuines();
if (culturesSet.includes("Fantasy")) addPortals();
config.forEach(({type, icon, multiplier, fn}) => {
if (multiplier === 0) return;
fn(type, icon, multiplier);
});
TIME && console.timeEnd("addMarkers");
};
}
const getQuantity = (array, min, each) => {
function getQuantity(array, min, each, multiplier) {
if (!array.length || array.length < min / multiplier) return 0;
const requestQty = Math.ceil((array.length / each) * multiplier);
return array.length < requestQty ? array.length : requestQty;
};
}
const extractAnyElement = array => {
function extractAnyElement(array) {
const index = Math.floor(Math.random() * array.length);
return array.splice(index, 1);
};
}
const getMarkerCoordinates = cell => {
function getMarkerCoordinates(cell) {
const {cells, burgs} = pack;
const burgId = cells.burg[cell];
@ -66,19 +90,30 @@ window.Markers = (function () {
}
return cells.p[cell];
};
}
function addVolcanoes() {
function addMarker({cell, type, icon, dx, dy, px}) {
const i = pack.markers.length;
const [x, y] = getMarkerCoordinates(cell);
const marker = {i, icon, type, x, y};
if (dx) marker.dx = dx;
if (dy) marker.dy = dy;
if (px) marker.px = px;
pack.markers.push(marker);
return "marker" + i;
}
function addVolcanoes(type, icon, multiplier) {
const {cells} = pack;
let mountains = Array.from(cells.i.filter(i => cells.h[i] >= 70).sort((a, b) => cells.h[b] - cells.h[a]));
let quantity = getQuantity(mountains, 10, 300);
let quantity = getQuantity(mountains, 10, 300, multiplier);
if (!quantity) return;
const highestMountains = mountains.slice(0, 20);
while (quantity) {
const [cell] = extractAnyElement(highestMountains);
const id = addMarker({cell, icon: "🌋", type: "volcano", dx: 52, px: 13});
const id = addMarker({cell, icon, type, dx: 52, px: 13});
const proper = Names.getCulture(cells.culture[cell]);
const name = P(0.3) ? "Mount " + proper : Math.random() > 0.3 ? proper + " Volcano" : proper;
notes.push({id, name, legend: `Active volcano. Height: ${getFriendlyHeight(cells.p[cell])}`});
@ -86,17 +121,17 @@ window.Markers = (function () {
}
}
function addHotSprings() {
function addHotSprings(type, icon, multiplier) {
const {cells} = pack;
let springs = Array.from(cells.i.filter(i => cells.h[i] > 50).sort((a, b) => cells.h[b] - cells.h[a]));
let quantity = getQuantity(springs, 30, 800);
let quantity = getQuantity(springs, 30, 800, multiplier);
if (!quantity) return;
const highestSprings = springs.slice(0, 40);
while (quantity) {
const [cell] = extractAnyElement(highestSprings);
const id = addMarker({cell, icon: "♨️", type: "hot_springs", dy: 52});
const id = addMarker({cell, icon, type, dy: 52});
const proper = Names.getCulture(cells.culture[cell]);
const temp = convertTemperature(gauss(35, 15, 20, 100));
notes.push({id, name: proper + " Hot Springs", legend: `A hot springs area. Average temperature: ${temp}`});
@ -104,18 +139,18 @@ window.Markers = (function () {
}
}
function addMines() {
function addMines(type, icon, multiplier) {
const {cells} = pack;
let hillyBurgs = Array.from(cells.i.filter(i => cells.h[i] > 47 && cells.burg[i]));
let quantity = getQuantity(hillyBurgs, 1, 15);
let quantity = getQuantity(hillyBurgs, 1, 15, multiplier);
if (!quantity) return;
const resources = {salt: 5, gold: 2, silver: 4, copper: 2, iron: 3, lead: 1, tin: 1};
while (quantity && hillyBurgs.length) {
const [cell] = extractAnyElement(hillyBurgs);
const id = addMarker({cell, icon: "⛏️", type: "mine", dx: 48, px: 13});
const id = addMarker({cell, icon, type, dx: 48, px: 13});
const resource = rw(resources);
const burg = pack.burgs[cells.burg[cell]];
const name = `${burg.name}${resource} mining town`;
@ -126,19 +161,19 @@ window.Markers = (function () {
}
}
function addBridges() {
function addBridges(type, icon, multiplier) {
const {cells, burgs} = pack;
const meanFlux = d3.mean(cells.fl.filter(fl => fl));
let bridges = Array.from(
cells.i.filter(i => cells.burg[i] && cells.t[i] !== 1 && burgs[cells.burg[i]].population > 20 && cells.r[i] && cells.fl[i] > meanFlux)
);
let quantity = getQuantity(bridges, 1, 5);
let quantity = getQuantity(bridges, 1, 5, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(bridges);
const id = addMarker({cell, icon: "🌉", type: "bridge", px: 14});
const id = addMarker({cell, icon, type, px: 14});
const burg = pack.burgs[cells.burg[cell]];
const river = pack.rivers.find(r => r.i === pack.cells.r[cell]);
const riverName = river ? `${river.name} ${river.type}` : "river";
@ -148,11 +183,11 @@ window.Markers = (function () {
}
}
function addInns() {
function addInns(type, icon, multiplier) {
const {cells} = pack;
let taverns = Array.from(cells.i.filter(i => cells.h[i] >= 20 && cells.road[i] > 4 && cells.pop[i] > 10));
let quantity = getQuantity(taverns, 1, 100);
let quantity = getQuantity(taverns, 1, 100, multiplier);
if (!quantity) return;
const colors = [
@ -385,61 +420,61 @@ window.Markers = (function () {
while (quantity) {
const [cell] = extractAnyElement(taverns);
const id = addMarker({cell, icon: "🍻", type: "inn", px: 14});
const type = P(0.3) ? "inn" : "tavern";
const id = addMarker({cell, icon, type, px: 14});
const typeName = P(0.3) ? "inn" : "tavern";
const isAnimalThemed = P(0.7);
const animal = ra(animals);
const name = isAnimalThemed ? (P(0.6) ? ra(colors) + " " + animal : ra(adjectives) + " " + animal) : ra(adjectives) + " " + capitalize(type);
const meal = isAnimalThemed && P(0.3) ? animal : ra(courses);
const course = `${ra(methods)} ${meal}`.toLowerCase();
const drink = `${P(0.5) ? ra(types) : ra(colors)} ${ra(drinks)}`.toLowerCase();
const legend = `A big and famous roadside ${type}. Delicious ${course} with ${drink} is served here`;
const legend = `A big and famous roadside ${typeName}. Delicious ${course} with ${drink} is served here`;
notes.push({id, name: "The " + name, legend});
quantity--;
}
}
function addLighthouses() {
function addLighthouses(type, icon, multiplier) {
const {cells} = pack;
const lighthouses = Array.from(cells.i.filter(i => cells.harbor[i] > 6 && cells.c[i].some(c => cells.h[c] < 20 && cells.road[c])));
let quantity = getQuantity(lighthouses, 1, 2);
let quantity = getQuantity(lighthouses, 1, 2, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(lighthouses);
const id = addMarker({cell, icon: "🚨", type: "lighthouse", px: 14});
const id = addMarker({cell, icon, type, px: 14});
const proper = cells.burg[cell] ? pack.burgs[cells.burg[cell]].name : Names.getCulture(cells.culture[cell]);
notes.push({id, name: getAdjective(proper) + " Lighthouse" + name, legend: `A lighthouse to keep the navigation safe`});
quantity--;
}
}
function addWaterfalls() {
function addWaterfalls(type, icon, multiplier) {
const {cells} = pack;
const waterfalls = Array.from(cells.i.filter(i => cells.r[i] && cells.h[i] >= 50 && cells.c[i].some(c => cells.h[c] < 40 && cells.r[c])));
const quantity = getQuantity(waterfalls, 1, 5);
const quantity = getQuantity(waterfalls, 1, 5, multiplier);
if (!quantity) return;
for (let i = 0; i < waterfalls.length && i < quantity; i++) {
const cell = waterfalls[i];
const id = addMarker({cell, icon: "⟱", type: "waterfall", dy: 54, px: 16});
const id = addMarker({cell, icon, type, dy: 54, px: 16});
const proper = cells.burg[cell] ? pack.burgs[cells.burg[cell]].name : Names.getCulture(cells.culture[cell]);
notes.push({id, name: getAdjective(proper) + " Waterfall" + name, legend: `An extremely beautiful waterfall`});
}
}
function addBattlefields() {
function addBattlefields(type, icon, multiplier) {
const {cells, states} = pack;
let battlefields = Array.from(cells.i.filter(i => cells.state[i] && cells.pop[i] > 2 && cells.h[i] < 50 && cells.h[i] > 25));
let quantity = getQuantity(battlefields, 50, 700);
let quantity = getQuantity(battlefields, 50, 700, multiplier);
if (!quantity) return;
while (quantity && battlefields.length) {
const [cell] = extractAnyElement(battlefields);
const id = addMarker({cell, icon: "⚔️", type: "battlefield", dy: 52});
const id = addMarker({cell, icon, type, dy: 52});
const campaign = ra(states[cells.state[cell]].campaigns);
const date = generateDate(campaign.start, campaign.end);
const name = Names.getCulture(cells.culture[cell]) + " Battlefield";
@ -449,16 +484,16 @@ window.Markers = (function () {
}
}
function addDungeons() {
function addDungeons(type, icon, multiplier) {
const {cells} = pack;
let dungeons = Array.from(cells.i.filter(i => cells.pop[i] && cells.pop[i] < 3));
let quantity = getQuantity(dungeons, 30, 200);
let quantity = getQuantity(dungeons, 30, 200, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(dungeons);
const id = addMarker({cell, icon: "🗝️", type: "dungeon", dy: 51, px: 13});
const id = addMarker({cell, icon, type, dy: 51, px: 13});
const dungeonSeed = `${seed}${cell}`;
const name = "Dungeon";
@ -468,17 +503,17 @@ window.Markers = (function () {
}
}
function addLakeMonsters() {
function addLakeMonsters(type, icon, multiplier) {
const {features} = pack;
const lakes = features.filter(feature => feature.type === "lake" && feature.group === "freshwater");
let quantity = getQuantity(lakes, 2, 10);
let quantity = getQuantity(lakes, 2, 10, multiplier);
if (!quantity) return;
while (quantity) {
const [lake] = extractAnyElement(lakes);
const cell = lake.firstCell;
const id = addMarker({cell, icon: "🐉", type: "lake_monster", dy: 48});
const id = addMarker({cell, icon, type, dy: 48});
const name = `${lake.name} Monster`;
const length = gauss(10, 5, 5, 100);
const legend = `Rumors said a relic monster of ${length} ${heightUnit.value} long inhabits ${lake.name} Lake. Truth or lie, but folks are affraid to fish in the lake`;
@ -487,16 +522,16 @@ window.Markers = (function () {
}
}
function addSeaMonsters() {
function addSeaMonsters(type, icon, multiplier) {
const {cells, features} = pack;
const sea = Array.from(cells.i.filter(i => cells.h[i] < 20 && cells.road[i] && features[cells.f[i]].type === "ocean"));
let quantity = getQuantity(sea, 50, 700);
let quantity = getQuantity(sea, 50, 700, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(sea);
const id = addMarker({cell, icon: "🦑", type: "sea_monster"});
const id = addMarker({cell, icon, type});
const name = `${Names.getCultureShort(0)} Monster`;
const length = gauss(25, 10, 10, 100);
const legend = `Old sailors tell stories of a gigantic sea monster inhabiting these dangerous waters. Rumors say it can be ${length} ${heightUnit.value} long`;
@ -505,11 +540,11 @@ window.Markers = (function () {
}
}
function addHillMonsters() {
function addHillMonsters(type, icon, multiplier) {
const {cells} = pack;
const hills = Array.from(cells.i.filter(i => cells.h[i] >= 50 && cells.pop[i]));
let quantity = getQuantity(hills, 30, 600);
let quantity = getQuantity(hills, 30, 600, multiplier);
if (!quantity) return;
const subjects = ["Locals", "Old folks", "Old books", "Tipplers"];
@ -525,7 +560,7 @@ window.Markers = (function () {
while (quantity) {
const [cell] = extractAnyElement(hills);
const id = addMarker({cell, icon: "👹", type: "hill_monster", dy: 54, px: 13});
const id = addMarker({cell, icon, type, dy: 54, px: 13});
const monster = ra(species);
const toponym = Names.getCulture(cells.culture[cell]);
const name = `${toponym} ${monster}`;
@ -535,16 +570,16 @@ window.Markers = (function () {
}
}
function addSacredMountains() {
function addSacredMountains(type, icon, multiplier) {
const {cells, cultures} = pack;
let lonelyMountains = Array.from(cells.i.filter(i => cells.h[i] >= 70 && cells.c[i].some(c => cells.culture[c]) && cells.c[i].every(c => cells.h[c] < 60)));
let quantity = getQuantity(lonelyMountains, 1, 5);
let quantity = getQuantity(lonelyMountains, 1, 5, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(lonelyMountains);
const id = addMarker({cell, icon: "🗻", type: "sacred_mountain", dy: 48});
const id = addMarker({cell, icon, type, dy: 48});
const culture = cells.c[cell].map(c => cells.culture[c]).find(c => c);
const name = `${Names.getCulture(culture)} Mountain`;
const height = getFriendlyHeight(cells.p[cell]);
@ -554,16 +589,16 @@ window.Markers = (function () {
}
}
function addSacredForests() {
function addSacredForests(type, icon, multiplier) {
const {cells, cultures} = pack;
let temperateForests = Array.from(cells.i.filter(i => cells.culture[i] && [6, 8].includes(cells.biome[i])));
let quantity = getQuantity(temperateForests, 30, 1000);
let quantity = getQuantity(temperateForests, 30, 1000, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(temperateForests);
const id = addMarker({cell, icon: "🌳", type: "sacred_forest"});
const id = addMarker({cell, icon, type});
const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Forest`;
const legend = `A sacred forest of ${cultures[culture].name} culture`;
@ -572,16 +607,16 @@ window.Markers = (function () {
}
}
function addSacredPineries() {
function addSacredPineries(type, icon, multiplier) {
const {cells, cultures} = pack;
let borealForests = Array.from(cells.i.filter(i => cells.culture[i] && cells.biome[i] === 9));
let quantity = getQuantity(borealForests, 30, 800);
let quantity = getQuantity(borealForests, 30, 800, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(borealForests);
const id = addMarker({cell, icon: "🌲", type: "pinery", px: 13});
const id = addMarker({cell, icon, type, px: 13});
const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Pinery`;
const legend = `A sacred pinery of ${cultures[culture].name} culture`;
@ -590,16 +625,16 @@ window.Markers = (function () {
}
}
function addSacredPalmGroves() {
function addSacredPalmGroves(type, icon, multiplier) {
const {cells, cultures} = pack;
let oasises = Array.from(cells.i.filter(i => cells.culture[i] && cells.biome[i] === 1 && cells.pop[i] > 1 && cells.road[i]));
let quantity = getQuantity(oasises, 1, 100);
let quantity = getQuantity(oasises, 1, 100, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(oasises);
const id = addMarker({cell, icon: "🌴", type: "palm_grove", px: 13});
const id = addMarker({cell, icon, type, px: 13});
const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Palm Grove`;
const legend = `A sacred palm grove of ${cultures[culture].name} culture`;
@ -608,11 +643,11 @@ window.Markers = (function () {
}
}
function addBrigands() {
function addBrigands(type, icon, multiplier) {
const {cells} = pack;
let roads = Array.from(cells.i.filter(i => cells.culture[i] && cells.road[i] > 4));
let quantity = getQuantity(roads, 50, 100);
let quantity = getQuantity(roads, 50, 100, multiplier);
if (!quantity) return;
const animals = [
@ -651,7 +686,7 @@ window.Markers = (function () {
while (quantity) {
const [cell] = extractAnyElement(roads);
const id = addMarker({cell, icon: "💰", type: "brigands", px: 13});
const id = addMarker({cell, icon, type, px: 13});
const culture = cells.culture[cell];
const biome = cells.biome[cell];
const height = cells.p[cell];
@ -674,16 +709,16 @@ window.Markers = (function () {
}
}
function addPirates() {
function addPirates(type, icon, multiplier) {
const {cells} = pack;
let searoutes = Array.from(cells.i.filter(i => cells.h[i] < 20 && cells.road[i]));
let quantity = getQuantity(searoutes, 40, 300);
let quantity = getQuantity(searoutes, 40, 300, multiplier);
if (!quantity) return;
while (quantity) {
const [cell] = extractAnyElement(searoutes);
const id = addMarker({cell, type: "pirates", icon: "🏴‍☠️", dx: 51});
const id = addMarker({cell, icon, type, dx: 51});
const name = `Pirates`;
const legend = `Pirate ships have been spotted in these waters`;
notes.push({id, name, legend});
@ -691,13 +726,13 @@ window.Markers = (function () {
}
}
function addStatues() {
function addStatues(type, icon, multiplier) {
const {cells} = pack;
let statues = Array.from(cells.i.filter(i => cells.h[i] >= 20 && cells.h[i] < 40));
let quantity = getQuantity(statues, 80, 1200);
let quantity = getQuantity(statues, 80, 1200, multiplier);
if (!quantity) return;
const types = ["Statue", "Obelisk", "Monument", "Column", "Monolith", "Pillar", "Megalith", "Stele", "Runestone"];
const variants = ["Statue", "Obelisk", "Monument", "Column", "Monolith", "Pillar", "Megalith", "Stele", "Runestone"];
const scripts = {
cypriot: "𐠁𐠂𐠃𐠄𐠅𐠈𐠊𐠋𐠌𐠍𐠎𐠏𐠐𐠑𐠒𐠓𐠔𐠕𐠖𐠗𐠘𐠙𐠚𐠛𐠜𐠝𐠞𐠟𐠠𐠡𐠢𐠣𐠤𐠥𐠦𐠧𐠨𐠩𐠪𐠫𐠬𐠭𐠮𐠯𐠰𐠱𐠲𐠳𐠴𐠵𐠷𐠸𐠼𐠿 ",
geez: "ሀለሐመሠረሰቀበተኀነአከወዐዘየደገጠጰጸፀፈፐ ",
@ -708,54 +743,53 @@ window.Markers = (function () {
while (quantity) {
const [cell] = extractAnyElement(statues);
const id = addMarker({cell, icon: "🗿", type: "statues"});
const id = addMarker({cell, icon, type});
const culture = cells.culture[cell];
const type = ra(types);
const name = `${Names.getCulture(culture)} ${type}`;
const variant = ra(variants);
const name = `${Names.getCulture(culture)} ${variant}`;
const script = scripts[ra(Object.keys(scripts))];
const inscription = Array(rand(40, 100))
.fill(null)
.map(() => ra(script))
.join("");
const legend = `An ancient ${type.toLowerCase()}. It has an inscription, but no one can translate it:
const legend = `An ancient ${variant.toLowerCase()}. It has an inscription, but no one can translate it:
<div style="font-size: 1.8em; line-break: anywhere;">${inscription}</div>`;
notes.push({id, name, legend});
quantity--;
}
}
function addRuines() {
function addRuines(type, icon, multiplier) {
const {cells} = pack;
let ruins = Array.from(cells.i.filter(i => cells.culture[i] && cells.h[i] >= 20 && cells.h[i] < 60));
let quantity = getQuantity(ruins, 80, 1200);
let quantity = getQuantity(ruins, 80, 1200, multiplier);
if (!quantity) return;
const types = ["City", "Town", "Pyramid", "Fort"];
while (quantity) {
const [cell] = extractAnyElement(ruins);
const id = addMarker({cell, icon: "🏺", type: "ruins"});
const id = addMarker({cell, icon, type});
const type = ra(types);
const name = `Ruined ${type}`;
const legend = `Ruins of an ancient ${type.toLowerCase()}. A good place for a treasures hunt`;
const ruinType = ra(types);
const name = `Ruined ${ruinType}`;
const legend = `Ruins of an ancient ${ruinType.toLowerCase()}. A good place for a treasures hunt`;
notes.push({id, name, legend});
quantity--;
}
}
function addPortals() {
function addPortals(type, icon, multiplier) {
const {burgs} = pack;
let quantity = rand(5, 15);
if (burgs.length < quantity + 1) return;
let portals = burgs.slice(1, quantity + 1).map(burg => [burg.name, burg.cell]);
let portals = burgs.slice(1, rand(12, 30) + 1).map(burg => [burg.name, burg.cell]);
let quantity = getQuantity(portals, 10, 3, multiplier);
if (!quantity) return;
while (quantity) {
const [portal] = extractAnyElement(portals);
const [burgName, cell] = portal;
const id = addMarker({cell, icon: "🌀", type: "portals", px: 14});
const id = addMarker({cell, icon, type, px: 14});
const name = `${burgName} Portal`;
const legend = `An element of the magic portal system connecting major cities. Portals installed centuries ago, but still work fine`;
notes.push({id, name, legend});
@ -763,16 +797,5 @@ window.Markers = (function () {
}
}
function addMarker({cell, type, icon, dx, dy, px}) {
const i = pack.markers.length;
const [x, y] = getMarkerCoordinates(cell);
const marker = {i, icon, type, x, y};
if (dx) marker.dx = dx;
if (dy) marker.dy = dy;
if (px) marker.px = px;
pack.markers.push(marker);
return "marker" + i;
}
return {generate, regenerate};
return {generate, regenerate, getConfig, setConfig};
})();

View file

@ -1,5 +1,5 @@
// module to control the Tools options (click to edit, to re-geenerate, tp add)
"use strict";
// module to control the Tools options (click to edit, to re-geenerate, tp add)
toolsContent.addEventListener("click", function (event) {
if (customization) {
@ -9,7 +9,7 @@ toolsContent.addEventListener("click", function (event) {
if (event.target.tagName !== "BUTTON") return;
const button = event.target.id;
// Click to open Editor buttons
// click on open Editor buttons
if (button === "editHeightmapButton") editHeightmap();
else if (button === "editBiomesButton") editBiomes();
else if (button === "editStatesButton") editStates();
@ -27,7 +27,7 @@ toolsContent.addEventListener("click", function (event) {
else if (button === "overviewMilitaryButton") overviewMilitary();
else if (button === "overviewCellsButton") viewCellDetails();
// Click to Regenerate buttons
// click on Regenerate buttons
if (event.target.parentNode.id === "regenerateFeature") {
if (sessionStorage.getItem("regenerateFeatureDontAsk")) {
processFeatureRegeneration(event, button);
@ -62,7 +62,11 @@ toolsContent.addEventListener("click", function (event) {
});
}
// Click to Add buttons
// click on Configure regenerate buttons
if (button === "configRegenerateMarkers") {
}
// click on Add buttons
if (button === "addLabel") toggleAddLabel();
else if (button === "addBurgTool") toggleAddBurg();
else if (button === "addRiver") toggleAddRiver();
@ -90,7 +94,7 @@ function processFeatureRegeneration(event, button) {
else if (button === "regenerateCultures") regenerateCultures();
else if (button === "regenerateMilitary") regenerateMilitary();
else if (button === "regenerateIce") regenerateIce();
else if (button === "regenerateMarkers") regenerateMarkers(event);
else if (button === "regenerateMarkers") regenerateMarkers();
else if (button === "regenerateZones") regenerateZones(event);
}
@ -416,24 +420,11 @@ function regenerateIce() {
drawIce();
}
function regenerateMarkers(event) {
if (isCtrlClick(event)) prompt("Please provide markers number multiplier", {default: 1, step: 0.01, min: 0, max: 100}, v => addNumberOfMarkers(v));
else addNumberOfMarkers();
function addNumberOfMarkers(multiplier) {
pack.markers = pack.markers.filter(marker => {
if (marker.lock) return true;
document.getElementById(`marker${marker.i}`)?.remove();
const index = notes.findIndex(note => note.id === marker.id);
if (index != -1) notes.splice(index, 1);
return false;
});
Markers.regenerate(multiplier);
function regenerateMarkers() {
Markers.regenerate();
turnButtonOn("toggleMarkers");
drawMarkers();
}
}
function regenerateZones(event) {
if (isCtrlClick(event)) prompt("Please provide zones number multiplier", {default: 1, step: 0.01, min: 0, max: 100}, v => addNumberOfZones(v));