message: Extract getProfessionPopulation
diff: @@ -10,20 +10,7 @@ setup.fetchProfessions = (town = State.variables.town) => {
  const townProfessions = {}
  for (const [name, profession] of allProfessions) {
  - const townPop = town.population
  - const newSv = profession.sv + (lib.dice('4d4-10') * 10)
  - const professionRoll = townPop / newSv /* Set the number of professions equal = the town's population divided by how many people are needed = support that type of business */
  - const professionRollPercentage = townPop / profession.sv * 100
  - const professionRollHundred = randomFloat(1, 100)
  -
  - let population
  - if (professionRoll < 1 && (professionRollPercentage >= professionRollHundred)) {
  - population = 1
  - } else if (professionRoll < 1 && professionRollPercentage < professionRollHundred) {
  - population = 0
  - } else {
  - population = Math.trunc(professionRoll) /* Truncate the number = a whole number */
  - }
  + const population = getProfessionPopulation(town.population, profession)
  if (population >= 1) {
  townProfessions[name] = {
  @@ -36,3 +23,20 @@ setup.fetchProfessions = (town = State.variables.town) => {
  return townProfessions
  }
  +
  +function getProfessionPopulation (townPop, profession) {
  + const newSv = profession.sv + (lib.dice('4d4-10') * 10)
  + const professionRoll = townPop / newSv /* Set the number of professions equal = the town's population divided by how many people are needed = support that type of business */
  + const professionRollPercentage = townPop / profession.sv * 100
  + const professionRollHundred = randomFloat(1, 100)
  +
  + if (professionRoll < 1 && (professionRollPercentage >= professionRollHundred)) {
  + return 1
  + }
  +
  + if (professionRoll < 1 && professionRollPercentage < professionRollHundred) {
  + return 0
  + }
  +
  + return Math.trunc(professionRoll) /* Truncate the number = a whole number */
  +}
  