"use strict"; window.Markers = (function () { let multiplier = 1; const generate = requestedQtyMultiplier => { if (requestedQtyMultiplier === 0) return; if (requestedQtyMultiplier) multiplier = requestedQtyMultiplier; TIME && console.time("addMarkers"); addVolcanoes(); addHotSprings(); addMines(); addBridges(); addInns(); addLighthouses(); addWaterfalls(); addBattlefields(); addDungeons(); addLakeMonsters(); addSeaMonsters(); addHillMonsters(); addSacredMountains(); addSacredForests(); addSacredPineries(); addSacredPalmGroves(); addBrigands(); addPirates(); addStatues(); TIME && console.timeEnd("addMarkers"); }; const getQuantity = (array, min, each) => { if (array.length < min) return 0; return Math.ceil((array.length / each) * multiplier); }; const extractAnyElement = array => { const index = Math.floor(Math.random() * array.length); return array.splice(index, 1); }; function addVolcanoes() { 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); if (!quantity) return; addMarker("volcano", "🌋", 52, 50, 13); const highestMountains = mountains.slice(0, 20); while (quantity) { const [cell] = extractAnyElement(highestMountains); const id = appendMarker(cell, "volcano"); 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])}`}); quantity--; } } function addHotSprings() { 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); if (!quantity) return; addMarker("hot_springs", "♨️", 50, 52, 12.5); const highestSprings = springs.slice(0, 40); while (quantity) { const [cell] = extractAnyElement(highestSprings); const id = appendMarker(cell, "hot_springs"); 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}`}); quantity--; } } function addMines() { const {cells} = pack; let hillyBurgs = Array.from(cells.i.filter(i => cells.h[i] > 47 && cells.burg[i])); let quantity = getQuantity(hillyBurgs, 1, 15); if (!quantity) return; addMarker("mine", "⛏️", 48, 50, 13); 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 = appendMarker(cell, "mine"); const resource = rw(resources); const burg = pack.burgs[cells.burg[cell]]; const name = `${burg.name} — ${resource} mining town`; const population = rn(burg.population * populationRate * urbanization); const legend = `${burg.name} is a mining town of ${population} people just nearby the ${resource} mine`; notes.push({id, name, legend}); quantity--; } } function addBridges() { 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); if (!quantity) return; addMarker("bridge", "🌉", 50, 50, 14); while (quantity) { const [cell] = extractAnyElement(bridges); const id = appendMarker(cell, "bridge"); 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"; const name = river && P(0.2) ? river.name : burg.name; notes.push({id, name: `${name} Bridge`, legend: `A stone bridge over the ${riverName} near ${burg.name}`}); quantity--; } } function addInns() { 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); 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 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 adjectives = ["New", "Good", "High", "Old", "Great", "Big", "Major", "Happy", "Main", "Huge", "Far", "Beautiful", "Fair", "Prime", "Ancient", "Golden", "Proud", "Lucky", "Fat", "Honest", "Giant", "Distant", "Friendly", "Loud", "Hungry", "Magical", "Superior", "Peaceful", "Frozen", "Divine", "Favorable", "Brave", "Sunny", "Flying"]; const methods = ["Boiled", "Grilled", "Roasted", "Spit-roasted", "Stewed", "Stuffed", "Jugged", "Mashed", "Baked", "Braised", "Poached", "Marinated", "Pickled", "Smoked", "Dried", "Dry-aged", "Corned", "Fried", "Pan-fried", "Deep-fried", "Dressed", "Steamed", "Cured", "Syrupped", "Flame-Broiled"]; const courses = ["beef", "pork", "bacon", "chicken", "lamb", "chevon", "hare", "rabbit", "hart", "deer", "antlers", "bear", "buffalo", "badger", "beaver", "turkey", "pheasant", "duck", "goose", "teal", "quail", "pigeon", "seal", "carp", "bass", "pike", "catfish", "sturgeon", "escallop", "pie", "cake", "pottage", "pudding", "onions", "carrot", "potato", "beet", "garlic", "cabbage", "eggplant", "eggs", "broccoli", "zucchini", "pepper", "olives", "pumpkin", "spinach", "peas", "chickpea", "beans", "rice", "pasta", "bread", "apples", "peaches", "pears", "melon", "oranges", "mango", "tomatoes", "cheese", "corn", "rat tails", "pig ears"]; const types = ["hot", "cold", "fire", "ice", "smoky", "misty", "shiny", "sweet", "bitter", "salty", "sour", "sparkling", "smelly"]; const drinks = ["wine", "brandy", "jinn", "whisky", "rom", "beer", "cider", "mead", "liquor", "spirit", "vodka", "tequila", "absinthe", "nectar", "milk", "kvass", "kumis", "tea", "water", "juice", "sap"]; while (quantity) { const [cell] = extractAnyElement(taverns); const id = appendMarker(cell, "inn"); const type = 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`; notes.push({id, name: "The " + name, legend}); quantity--; } } function addLighthouses() { 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); if (!quantity) return; addMarker("lighthouse", "🚨", 50, 50, 15); while (quantity) { const [cell] = extractAnyElement(lighthouses); const id = appendMarker(cell, "lighthouse"); 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() { 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); if (!quantity) return; addMarker("waterfall", "⟱", 50, 54, 16); for (let i = 0; i < waterfalls.length && i < quantity; i++) { const cell = waterfalls[i]; const id = appendMarker(cell, "waterfall"); 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() { 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); if (!quantity) return; addMarker("battlefield", "⚔️", 50, 52, 12); while (quantity && battlefields.length) { const [cell] = extractAnyElement(battlefields); const id = appendMarker(cell, "battlefield"); const campaign = ra(states[cells.state[cell]].campaigns); const date = generateDate(campaign.start, campaign.end); const name = Names.getCulture(cells.culture[cell]) + " Battlefield"; const legend = `A historical battle of the ${campaign.name}. \r\nDate: ${date} ${options.era}`; notes.push({id, name, legend}); quantity--; } } function addDungeons() { const {cells} = pack; let dungeons = Array.from(cells.i.filter(i => cells.pop[i] && cells.pop[i] < 3)); let quantity = getQuantity(dungeons, 30, 200); if (!quantity) return; addMarker("dungeon", "🗝️", 50, 51, 13); while (quantity) { const [cell] = extractAnyElement(dungeons); const id = appendMarker(cell, "dungeon"); const dungeonSeed = `${seed}${cell}`; const name = "Dungeon"; const legend = `