const variables = require("./variables.js"); module.exports = { encounterMenuMaker, initializeEncounter, } function initializeEncounter(reqFaction, diffWeighting, fight, flee){ var encounter = encounterMenuMaker(reqFaction, diffWeighting); console.clear(); console.log("You come across a " + encounter.name); var encounterHealth = variables.randomNumber(encounter.minHealth, encounter.maxHealth); console.log("Health: " + encounterHealth); console.log("What would you like to do?"); console.log("--------------------------"); var playerOptions = 1; if(fight == true){ console.log(playerOptions + ") Fight"); playerOptions++; } if(flee == true){ console.log(playerOptions + ") Flee"); playerOptions++; } console.log(playerOptions + ") Inventory"); } //Add any new encounter ideas to their required faction and difficulty var encounterDiffOne = [ //NCR [], //Legion [], //Raider [ {name: "raider aspirant", minHealth: 30, maxHealth: 50, lootTable: "teir1A&W", numEnemies: 1}, ], //Settler [ {name: "drunk", minHealth: 15, maxHealth: 25, lootTable: "junk", numEnemies: 1}, ], //BOS [], //Abomination [ {name: "radroach", minHealth: 1, maxHealth: 10, lootTable: "food", numEnemies: 1}, {name: "weak ghoul", minHealth: 10, maxHealth: 15, lootTable: "junk", numEnemies: 1}, {name: "bloatfly swarm", minHealth: 1, maxHealth: 5, lootTable: "food", numEnemies: 5}, {name: "wolf", minHealth: 5, maxHealth: 10, lootTable: "food", numEnemies: 1}, ] ]; var encounterDiffTwo = [ //NCR [], //Legion [], //Raider [], //Settler [], //BOS [], //Abomination [] ]; var encounterDiffThree = [ //NCR [], //Legion [], //Raider [], //Settler [], //BOS [], //Abomination [] ]; var encounterDiffFour = [ //NCR [], //Legion [], //Raider [], //Settler [], //BOS [], //Abomination [] ]; var encounterDiffFive = [ //NCR [], //Legion [], //Raider [], //Settler [], //BOS [], //Abomination [] ]; //RIP the filterFactionFunction :( //Declaring some stuff to make them global variables var encountered = []; var faction = 0; //Creates the menu for an encounter. "faction" represents the faction for the encounter, "diffWeighting" changes the odds for //an encounter's difficulty (1-5) //IGNORE THE VARIABLE COMMENTS IN THE NESTED SWITCH STATEMENT, they're placeholders for me function encounterMenuMaker(reqFaction, diffWeighting){ var encounterDifficulty = (diffWeighting * variables.randomNumber(1, 20)); if((reqFaction != "NCR") && (reqFaction != "BOS")){ factionFailsafe = reqFaction.toLowerCase(); } else { factionFailsafe = reqFaction; } switch(factionFailsafe){ case "NCR": faction = 0; break; case "legion": faction = 1; break; case "raider": faction = 2; break; case "settler": faction = 3; break; case "BOS": faction = 4; break; case "abomination": faction = 5; break; } if(encounterDifficulty <= 20){ encountered.push(encounterDiffOne[faction][variables.randomNumber(0, encounterDiffOne[faction].length - 1)]); } else if(21 <= encounterDifficulty <= 40){ encountered.push(encounterDiffTwo[faction][variables.randomNumber(0, encounterDiffTwo[faction].length - 1)]); } else if(41 <= encounterDifficulty <= 60){ encountered.push(encounterDiffThree[faction][variables.randomNumber(0, encounterDiffThree[faction].length - 1)]); } else if(61 <= encounterDifficulty <= 80){ encountered.push(encounterDiffFour[faction][variables.randomNumber(0, encounterDiffFour[faction].length - 1)]); } else { encountered.push(encounterDiffFive[faction][variables.randomNumber(0, encounterDiffFive[faction].length - 1)]); } return encountered[0]; }