markers data rework - master data object

This commit is contained in:
Azgaar 2021-09-18 16:47:17 +03:00
parent c8b7e9ccee
commit 3b47efd9a4
3 changed files with 40 additions and 52 deletions

View file

@ -4,6 +4,7 @@ window.Markers = (function () {
let multiplier = 1; let multiplier = 1;
const generate = requestedQtyMultiplier => { const generate = requestedQtyMultiplier => {
pack.markers = [];
if (requestedQtyMultiplier === 0) return; if (requestedQtyMultiplier === 0) return;
if (requestedQtyMultiplier) multiplier = requestedQtyMultiplier; if (requestedQtyMultiplier) multiplier = requestedQtyMultiplier;
TIME && console.time("addMarkers"); TIME && console.time("addMarkers");
@ -63,13 +64,11 @@ window.Markers = (function () {
let mountains = Array.from(cells.i.filter(i => cells.h[i] >= 70).sort((a, b) => cells.h[b] - cells.h[a])); 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);
if (!quantity) return; if (!quantity) return;
addMarker("volcano", "🌋", 52, 50, 13);
const highestMountains = mountains.slice(0, 20); const highestMountains = mountains.slice(0, 20);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(highestMountains); const [cell] = extractAnyElement(highestMountains);
const id = appendMarker(cell, "volcano"); const id = addMarker({cell, icon: "🌋", type: "volcano", dx: 52, px: 13});
const proper = Names.getCulture(cells.culture[cell]); const proper = Names.getCulture(cells.culture[cell]);
const name = P(0.3) ? "Mount " + proper : Math.random() > 0.3 ? proper + " Volcano" : proper; 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])}`}); notes.push({id, name, legend: `Active volcano. Height: ${getFriendlyHeight(cells.p[cell])}`});
@ -83,13 +82,11 @@ window.Markers = (function () {
let springs = Array.from(cells.i.filter(i => cells.h[i] > 50).sort((a, b) => cells.h[b] - cells.h[a])); 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);
if (!quantity) return; if (!quantity) return;
addMarker("hot_springs", "♨️", 50, 52, 12.5);
const highestSprings = springs.slice(0, 40); const highestSprings = springs.slice(0, 40);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(highestSprings); const [cell] = extractAnyElement(highestSprings);
const id = appendMarker(cell, "hot_springs"); const id = addMarker({cell, icon: "♨️", type: "hot_springs", dy: 52});
const proper = Names.getCulture(cells.culture[cell]); const proper = Names.getCulture(cells.culture[cell]);
const temp = convertTemperature(gauss(35, 15, 20, 100)); const temp = convertTemperature(gauss(35, 15, 20, 100));
notes.push({id, name: proper + " Hot Springs", legend: `A hot springs area. Average temperature: ${temp}`}); notes.push({id, name: proper + " Hot Springs", legend: `A hot springs area. Average temperature: ${temp}`});
@ -104,12 +101,11 @@ window.Markers = (function () {
let quantity = getQuantity(hillyBurgs, 1, 15); let quantity = getQuantity(hillyBurgs, 1, 15);
if (!quantity) return; if (!quantity) return;
addMarker("mine", "⛏️", 48, 50, 13);
const resources = {salt: 5, gold: 2, silver: 4, copper: 2, iron: 3, lead: 1, tin: 1}; const resources = {salt: 5, gold: 2, silver: 4, copper: 2, iron: 3, lead: 1, tin: 1};
while (quantity && hillyBurgs.length) { while (quantity && hillyBurgs.length) {
const [cell] = extractAnyElement(hillyBurgs); const [cell] = extractAnyElement(hillyBurgs);
const id = appendMarker(cell, "mine"); const id = addMarker({cell, icon: "⛏️", type: "mine", dx: 48, px: 13});
const resource = rw(resources); const resource = rw(resources);
const burg = pack.burgs[cells.burg[cell]]; const burg = pack.burgs[cells.burg[cell]];
const name = `${burg.name}${resource} mining town`; const name = `${burg.name}${resource} mining town`;
@ -128,11 +124,9 @@ window.Markers = (function () {
let quantity = getQuantity(bridges, 1, 5); let quantity = getQuantity(bridges, 1, 5);
if (!quantity) return; if (!quantity) return;
addMarker("bridge", "🌉", 50, 50, 14);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(bridges); const [cell] = extractAnyElement(bridges);
const id = appendMarker(cell, "bridge"); const id = addMarker({cell, icon: "🌉", type: "bridge", px: 14});
const burg = pack.burgs[cells.burg[cell]]; const burg = pack.burgs[cells.burg[cell]];
const river = pack.rivers.find(r => r.i === pack.cells.r[cell]); const river = pack.rivers.find(r => r.i === pack.cells.r[cell]);
const riverName = river ? `${river.name} ${river.type}` : "river"; const riverName = river ? `${river.name} ${river.type}` : "river";
@ -148,7 +142,6 @@ window.Markers = (function () {
let taverns = Array.from(cells.i.filter(i => cells.h[i] >= 20 && cells.road[i] > 4 && cells.pop[i] > 10)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("inn", "🍻", 50, 50, 14);
const colors = ["Dark", "Light", "Bright", "Golden", "White", "Black", "Red", "Pink", "Purple", "Blue", "Green", "Yellow", "Amber", "Orange", "Brown", "Grey"]; const colors = ["Dark", "Light", "Bright", "Golden", "White", "Black", "Red", "Pink", "Purple", "Blue", "Green", "Yellow", "Amber", "Orange", "Brown", "Grey"];
const animals = ["Antelope", "Ape", "Badger", "Bear", "Beaver", "Bison", "Boar", "Buffalo", "Cat", "Crane", "Crocodile", "Crow", "Deer", "Dog", "Eagle", "Elk", "Fox", "Goat", "Goose", "Hare", "Hawk", "Heron", "Horse", "Hyena", "Ibis", "Jackal", "Jaguar", "Lark", "Leopard", "Lion", "Mantis", "Marten", "Moose", "Mule", "Narwhal", "Owl", "Panther", "Rat", "Raven", "Rook", "Scorpion", "Shark", "Sheep", "Snake", "Spider", "Swan", "Tiger", "Turtle", "Wolf", "Wolverine", "Camel", "Falcon", "Hound", "Ox"]; const animals = ["Antelope", "Ape", "Badger", "Bear", "Beaver", "Bison", "Boar", "Buffalo", "Cat", "Crane", "Crocodile", "Crow", "Deer", "Dog", "Eagle", "Elk", "Fox", "Goat", "Goose", "Hare", "Hawk", "Heron", "Horse", "Hyena", "Ibis", "Jackal", "Jaguar", "Lark", "Leopard", "Lion", "Mantis", "Marten", "Moose", "Mule", "Narwhal", "Owl", "Panther", "Rat", "Raven", "Rook", "Scorpion", "Shark", "Sheep", "Snake", "Spider", "Swan", "Tiger", "Turtle", "Wolf", "Wolverine", "Camel", "Falcon", "Hound", "Ox"];
@ -160,7 +153,7 @@ window.Markers = (function () {
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(taverns); const [cell] = extractAnyElement(taverns);
const id = appendMarker(cell, "inn"); const id = addMarker({cell, icon: "🍻", type: "inn", px: 14});
const type = P(0.3) ? "inn" : "tavern"; const type = P(0.3) ? "inn" : "tavern";
const isAnimalThemed = P(0.7); const isAnimalThemed = P(0.7);
const animal = ra(animals); const animal = ra(animals);
@ -180,11 +173,10 @@ window.Markers = (function () {
const lighthouses = Array.from(cells.i.filter(i => cells.harbor[i] > 6 && cells.c[i].some(c => cells.h[c] < 20 && cells.road[c]))); 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);
if (!quantity) return; if (!quantity) return;
addMarker("lighthouse", "🚨", 50, 50, 15);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(lighthouses); const [cell] = extractAnyElement(lighthouses);
const id = appendMarker(cell, "lighthouse"); const id = addMarker({cell, icon: "🚨", type: "lighthouse", px: 14});
const proper = cells.burg[cell] ? pack.burgs[cells.burg[cell]].name : Names.getCulture(cells.culture[cell]); 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`}); notes.push({id, name: getAdjective(proper) + " Lighthouse" + name, legend: `A lighthouse to keep the navigation safe`});
quantity--; quantity--;
@ -197,11 +189,10 @@ window.Markers = (function () {
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 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);
if (!quantity) return; if (!quantity) return;
addMarker("waterfall", "⟱", 50, 54, 16);
for (let i = 0; i < waterfalls.length && i < quantity; i++) { for (let i = 0; i < waterfalls.length && i < quantity; i++) {
const cell = waterfalls[i]; const cell = waterfalls[i];
const id = appendMarker(cell, "waterfall"); const id = addMarker({cell, icon: "⟱", type: "waterfall", dy: 54, px: 16});
const proper = cells.burg[cell] ? pack.burgs[cells.burg[cell]].name : Names.getCulture(cells.culture[cell]); 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`}); notes.push({id, name: getAdjective(proper) + " Waterfall" + name, legend: `An extremely beautiful waterfall`});
} }
@ -213,11 +204,10 @@ window.Markers = (function () {
let battlefields = Array.from(cells.i.filter(i => cells.state[i] && cells.pop[i] > 2 && cells.h[i] < 50 && cells.h[i] > 25)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("battlefield", "⚔️", 50, 52, 12);
while (quantity && battlefields.length) { while (quantity && battlefields.length) {
const [cell] = extractAnyElement(battlefields); const [cell] = extractAnyElement(battlefields);
const id = appendMarker(cell, "battlefield"); const id = addMarker({cell, icon: "⚔️", type: "battlefield", dy: 52});
const campaign = ra(states[cells.state[cell]].campaigns); const campaign = ra(states[cells.state[cell]].campaigns);
const date = generateDate(campaign.start, campaign.end); const date = generateDate(campaign.start, campaign.end);
const name = Names.getCulture(cells.culture[cell]) + " Battlefield"; const name = Names.getCulture(cells.culture[cell]) + " Battlefield";
@ -233,11 +223,10 @@ window.Markers = (function () {
let dungeons = Array.from(cells.i.filter(i => cells.pop[i] && cells.pop[i] < 3)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("dungeon", "🗝️", 50, 51, 13);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(dungeons); const [cell] = extractAnyElement(dungeons);
const id = appendMarker(cell, "dungeon"); const id = addMarker({cell, icon: "🗝️", type: "dungeon", dy: 51, px: 13});
const dungeonSeed = `${seed}${cell}`; const dungeonSeed = `${seed}${cell}`;
const name = "Dungeon"; const name = "Dungeon";
@ -253,12 +242,11 @@ window.Markers = (function () {
const lakes = features.filter(feature => feature.type === "lake" && feature.group === "freshwater"); const lakes = features.filter(feature => feature.type === "lake" && feature.group === "freshwater");
let quantity = getQuantity(lakes, 2, 10); let quantity = getQuantity(lakes, 2, 10);
if (!quantity) return; if (!quantity) return;
addMarker("lake_monster", "🐉", 50, 48, 12.5);
while (quantity) { while (quantity) {
const [lake] = extractAnyElement(lakes); const [lake] = extractAnyElement(lakes);
const cell = lake.firstCell; const cell = lake.firstCell;
const id = appendMarker(cell, "lake_monster"); const id = addMarker({cell, icon: "🐉", type: "lake_monster", dy: 48});
const name = `${lake.name} Monster`; const name = `${lake.name} Monster`;
const length = gauss(10, 5, 5, 100); 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`; 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`;
@ -273,11 +261,10 @@ window.Markers = (function () {
const sea = Array.from(cells.i.filter(i => cells.h[i] < 20 && cells.road[i] && features[cells.f[i]].type === "ocean")); 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);
if (!quantity) return; if (!quantity) return;
addMarker("sea_monster", "🦑", 50, 50, 12);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(sea); const [cell] = extractAnyElement(sea);
const id = appendMarker(cell, "sea_monster"); const id = addMarker({cell, icon: "🦑", type: "sea_monster"});
const name = `${Names.getCultureShort(0)} Monster`; const name = `${Names.getCultureShort(0)} Monster`;
const length = gauss(25, 10, 10, 100); 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`; const legend = `Old sailors tell stories of a gigantic sea monster inhabiting these dangerous waters. Rumors say it can be ${length} ${heightUnit.value} long`;
@ -292,7 +279,6 @@ window.Markers = (function () {
const hills = Array.from(cells.i.filter(i => cells.h[i] >= 50 && cells.pop[i])); 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);
if (!quantity) return; if (!quantity) return;
addMarker("hill_monster", "👹", 50, 54, 13);
const subjects = ["Locals", "Old folks", "Old books", "Tipplers"]; const subjects = ["Locals", "Old folks", "Old books", "Tipplers"];
const species = ["Ogre", "Troll", "Cyclops", "Giant", "Monster", "Beast", "Dragon", "Undead", "Ghoul", "Vampire"]; const species = ["Ogre", "Troll", "Cyclops", "Giant", "Monster", "Beast", "Dragon", "Undead", "Ghoul", "Vampire"];
@ -300,7 +286,7 @@ window.Markers = (function () {
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(hills); const [cell] = extractAnyElement(hills);
const id = appendMarker(cell, "hill_monster"); const id = addMarker({cell, icon: "👹", type: "hill_monster", dy: 54, px: 13});
const monster = ra(species); const monster = ra(species);
const toponym = Names.getCulture(cells.culture[cell]); const toponym = Names.getCulture(cells.culture[cell]);
const name = `${toponym} ${monster}`; const name = `${toponym} ${monster}`;
@ -316,11 +302,10 @@ window.Markers = (function () {
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 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);
if (!quantity) return; if (!quantity) return;
addMarker("sacred_mountain", "🗻", 50, 48, 12);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(lonelyMountains); const [cell] = extractAnyElement(lonelyMountains);
const id = appendMarker(cell, "sacred_mountain"); const id = addMarker({cell, icon: "🗻", type: "sacred_mountain", dy: 48});
const culture = cells.c[cell].map(c => cells.culture[c]).find(c => c); const culture = cells.c[cell].map(c => cells.culture[c]).find(c => c);
const name = `${Names.getCulture(culture)} Mountain`; const name = `${Names.getCulture(culture)} Mountain`;
const height = getFriendlyHeight(cells.p[cell]); const height = getFriendlyHeight(cells.p[cell]);
@ -336,11 +321,10 @@ window.Markers = (function () {
let temperateForests = Array.from(cells.i.filter(i => cells.culture[i] && [6, 8].includes(cells.biome[i]))); 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);
if (!quantity) return; if (!quantity) return;
addMarker("sacred_forest", "🌳", 50, 50, 12);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(temperateForests); const [cell] = extractAnyElement(temperateForests);
const id = appendMarker(cell, "sacred_forest"); const id = addMarker({cell, icon: "🌳", type: "sacred_forest"});
const culture = cells.culture[cell]; const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Forest`; const name = `${Names.getCulture(culture)} Forest`;
const legend = `A sacred forest of ${cultures[culture].name} culture`; const legend = `A sacred forest of ${cultures[culture].name} culture`;
@ -355,11 +339,10 @@ window.Markers = (function () {
let borealForests = Array.from(cells.i.filter(i => cells.culture[i] && cells.biome[i] === 9)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("pinery", "🌲", 50, 50, 13);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(borealForests); const [cell] = extractAnyElement(borealForests);
const id = appendMarker(cell, "pinery"); const id = addMarker({cell, icon: "🌲", type: "pinery", px: 13});
const culture = cells.culture[cell]; const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Pinery`; const name = `${Names.getCulture(culture)} Pinery`;
const legend = `A sacred pinery of ${cultures[culture].name} culture`; const legend = `A sacred pinery of ${cultures[culture].name} culture`;
@ -374,11 +357,10 @@ window.Markers = (function () {
let oasises = Array.from(cells.i.filter(i => cells.culture[i] && cells.biome[i] === 1 && cells.pop[i] > 1 && cells.road[i])); 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);
if (!quantity) return; if (!quantity) return;
addMarker("palm_grove", "🌴", 50, 50, 13);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(oasises); const [cell] = extractAnyElement(oasises);
const id = appendMarker(cell, "palm_grove"); const id = addMarker({cell, icon: "🌴", type: "palm_grove", px: 13});
const culture = cells.culture[cell]; const culture = cells.culture[cell];
const name = `${Names.getCulture(culture)} Palm Grove`; const name = `${Names.getCulture(culture)} Palm Grove`;
const legend = `A sacred palm grove of ${cultures[culture].name} culture`; const legend = `A sacred palm grove of ${cultures[culture].name} culture`;
@ -393,14 +375,13 @@ window.Markers = (function () {
let roads = Array.from(cells.i.filter(i => cells.culture[i] && cells.road[i] > 4)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("brigands", "💰", 50, 50, 13);
const animals = ["Apes", "Badgers", "Bears", "Beavers", "Bisons", "Boars", "Cats", "Crows", "Dogs", "Foxes", "Hares", "Hawks", "Hyenas", "Jackals", "Jaguars", "Leopards", "Lions", "Owls", "Panthers", "Rats", "Ravens", "Rooks", "Scorpions", "Sharks", "Snakes", "Spiders", "Tigers", "Wolfs", "Wolverines", "Falcons"]; const animals = ["Apes", "Badgers", "Bears", "Beavers", "Bisons", "Boars", "Cats", "Crows", "Dogs", "Foxes", "Hares", "Hawks", "Hyenas", "Jackals", "Jaguars", "Leopards", "Lions", "Owls", "Panthers", "Rats", "Ravens", "Rooks", "Scorpions", "Sharks", "Snakes", "Spiders", "Tigers", "Wolfs", "Wolverines", "Falcons"];
const types = {brigands: 4, bandits: 3, robbers: 1, highwaymen: 1}; const types = {brigands: 4, bandits: 3, robbers: 1, highwaymen: 1};
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(roads); const [cell] = extractAnyElement(roads);
const id = appendMarker(cell, "brigands"); const id = addMarker({cell, icon: "💰", type: "brigands", px: 13});
const culture = cells.culture[cell]; const culture = cells.culture[cell];
const biome = cells.biome[cell]; const biome = cells.biome[cell];
const height = cells.p[cell]; const height = cells.p[cell];
@ -418,11 +399,10 @@ window.Markers = (function () {
let searoutes = Array.from(cells.i.filter(i => cells.h[i] < 20 && cells.road[i])); 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);
if (!quantity) return; if (!quantity) return;
addMarker("pirates", "🏴‍☠️", 51, 50, 12);
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(searoutes); const [cell] = extractAnyElement(searoutes);
const id = appendMarker(cell, "pirates"); const id = addMarker({cell, type: "pirates", icon: "🏴‍☠️", dx: 51});
const name = `Pirates`; const name = `Pirates`;
const legend = `Pirate ships have been spotted in these waters`; const legend = `Pirate ships have been spotted in these waters`;
notes.push({id, name, legend}); notes.push({id, name, legend});
@ -435,7 +415,6 @@ window.Markers = (function () {
let statues = Array.from(cells.i.filter(i => cells.h[i] >= 20 && cells.h[i] < 40)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("statues", "🗿", 50, 50, 12);
const types = ["Statue", "Obelisk", "Monument", "Column", "Monolith", "Pillar", "Megalith", "Stele", "Runestone"]; const types = ["Statue", "Obelisk", "Monument", "Column", "Monolith", "Pillar", "Megalith", "Stele", "Runestone"];
const scripts = { const scripts = {
@ -448,7 +427,7 @@ window.Markers = (function () {
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(statues); const [cell] = extractAnyElement(statues);
const id = appendMarker(cell, "statues"); const id = addMarker({cell, icon: "🗿", type: "statues"});
const culture = cells.culture[cell]; const culture = cells.culture[cell];
const type = ra(types); const type = ra(types);
@ -470,13 +449,12 @@ window.Markers = (function () {
let ruins = Array.from(cells.i.filter(i => cells.culture[i] && cells.h[i] >= 20 && cells.h[i] < 60)); 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);
if (!quantity) return; if (!quantity) return;
addMarker("ruins", "🏺", 50, 50, 12);
const types = ["City", "Town", "Pyramid", "Fort"]; const types = ["City", "Town", "Pyramid", "Fort"];
while (quantity) { while (quantity) {
const [cell] = extractAnyElement(ruins); const [cell] = extractAnyElement(ruins);
const id = appendMarker(cell, "ruins"); const id = addMarker({cell, icon: "🏺", type: "ruins"});
const type = ra(types); const type = ra(types);
const name = `Ruined ${type}`; const name = `Ruined ${type}`;
@ -492,12 +470,11 @@ window.Markers = (function () {
let quantity = rand(5, 15); let quantity = rand(5, 15);
if (burgs.length < quantity + 1) return; if (burgs.length < quantity + 1) return;
let portals = burgs.slice(1, quantity + 1).map(burg => [burg.name, burg.cell]); let portals = burgs.slice(1, quantity + 1).map(burg => [burg.name, burg.cell]);
addMarker("portals", "🌀", 50, 50, 14);
while (quantity) { while (quantity) {
const [portal] = extractAnyElement(portals); const [portal] = extractAnyElement(portals);
const [burgName, cell] = portal; const [burgName, cell] = portal;
const id = appendMarker(cell, "portals"); const id = addMarker({cell, icon: "🌀", type: "portals", px: 14});
const name = `${burgName} Portal`; const name = `${burgName} Portal`;
const legend = `An element of the magic portal system connecting major cities. Portals installed centuries ago, but still work fine`; 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}); notes.push({id, name, legend});
@ -505,7 +482,18 @@ window.Markers = (function () {
} }
} }
function addMarker(id, icon, x, y, size) { 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 addMarkerGroup(id, icon, x, y, size) {
const markers = svg.select("#defs-markers"); const markers = svg.select("#defs-markers");
if (markers.select("#marker_" + id).size()) return; if (markers.select("#marker_" + id).size()) return;
@ -528,9 +516,9 @@ window.Markers = (function () {
.text(icon); .text(icon);
} }
function appendMarker(cell, type) { function drawMarker(cell, type) {
const [x, y] = getMarkerCoordinates(cell); const [x, y] = getMarkerCoordinates(cell);
const id = getNextId("markerElement"); const id = getNextId("marker");
const name = "#marker_" + type; const name = "#marker_" + type;
markers markers

View file

@ -707,7 +707,7 @@ class Battle {
const result = `The ${this.getTypeName(this.type)} ended in ${status}`; const result = `The ${this.getTypeName(this.type)} ended in ${status}`;
const legend = `${this.name} took place in ${options.year} ${options.eraShort}. It was fought between ${getSide(this.attackers.regiments, 1)} and ${getSide(this.defenders.regiments, 0)}. ${result}. const legend = `${this.name} took place in ${options.year} ${options.eraShort}. It was fought between ${getSide(this.attackers.regiments, 1)} and ${getSide(this.defenders.regiments, 0)}. ${result}.
\r\nAttackers losses: ${getLosses(this.attackers.casualties)}%, defenders losses: ${getLosses(this.defenders.casualties)}%`; \r\nAttackers losses: ${getLosses(this.attackers.casualties)}%, defenders losses: ${getLosses(this.defenders.casualties)}%`;
const id = getNextId("markerElement"); const id = getNextId("marker");
notes.push({id, name: this.name, legend}); notes.push({id, name: this.name, legend});
tip(`${this.name} is over. ${result}`, true, "success", 4000); tip(`${this.name} is over. ${result}`, true, "success", 4000);

View file

@ -690,9 +690,9 @@ function toggleAddMarker() {
function addMarkerOnClick() { function addMarkerOnClick() {
const point = d3.mouse(this); const point = d3.mouse(this);
const x = rn(point[0], 2), const x = rn(point[0], 2);
y = rn(point[1], 2); const y = rn(point[1], 2);
const id = getNextId("markerElement"); const id = getNextId("marker");
const selected = markerSelectGroup.value; const selected = markerSelectGroup.value;
const valid = const valid =