const generator = require("project-name-generator");

let createPlace = () => {
  let numToSpawn = Math.round(Math.random() * 3) + 3

  for (let i = 0; i < numToSpawn; i++){

      const buildings = ['🏛️','⛺','🏚️','⛩️','🗿']
      const placeTypes = ['Village','Village','Village','House','House','Market','Market','Market','Crossroads','Place','Outpost','Trading Post','House','Shack','Meeting Place','Saloon','Watering Hole','Stall','Hideout','Cart','Camp','Camp','Camp','Camp','','','','Zone of Ill Repute']

    let whichBuilding = buildings[Math.floor(Math.random()*3)];

    let loc = generator.generate().spaced;

    let suffix = placeTypes[Math.floor(Math.random() * placeTypes.length)];

    let locName = capitalize(loc + ' ' + suffix);
    
    console.log(whichBuilding + ": "+locName)
  }
}

let capitalize = (str) => {
      let arr = str.split(' ');
      for(let i = 0; i < arr.length; i++ ) {
         arr[i] = arr[i].replace(arr[i].charAt(0),  arr[i].charAt(0).toUpperCase());
     }
     return arr.join(' ');
}

createPlace();
