Finally got the encounter menu function working
This commit is contained in:
parent
0c36b89ff6
commit
f732586c24
1 changed files with 118 additions and 82 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
const testingShite = require("./main.js");
|
const testingShite = require("./main.js");
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
encounterMenuMaker,
|
encounterMenuMaker,
|
||||||
|
|
@ -9,97 +10,132 @@ function beginTesting(){
|
||||||
console.log(encounterMenuMaker("abomination", 1));
|
console.log(encounterMenuMaker("abomination", 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const variables = require("./variables.js");
|
//Editor's note: abomination, raider, settler, BOS, NCR, Legion
|
||||||
|
var encounterDiffOne = [
|
||||||
//abomination, raider, settler, BOS, NCR, Legion
|
//NCR
|
||||||
|
[],
|
||||||
//Declare all faction arrays and difficulties
|
//Legion
|
||||||
const legion1 = [];
|
[],
|
||||||
const BOS1 = [];
|
//Raider
|
||||||
const settler1 = [
|
[
|
||||||
{name: "drunk", faction: "settler", minHealth: 15, maxHealth: 25, lootTable: "junk", numEnemies: 1},
|
{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},
|
||||||
|
]
|
||||||
];
|
];
|
||||||
const NCR1 = [];
|
var encounterDiffTwo = [
|
||||||
const raider1 = [
|
//NCR
|
||||||
{name: "raider aspirant", faction: "raider", minHealth: 30, maxHealth: 50, lootTable: "teir1A&W", numEnemies: 1},
|
[],
|
||||||
|
//Legion
|
||||||
|
[],
|
||||||
|
//Raider
|
||||||
|
[],
|
||||||
|
//Settler
|
||||||
|
[],
|
||||||
|
//BOS
|
||||||
|
[],
|
||||||
|
//Abomination
|
||||||
|
[]
|
||||||
];
|
];
|
||||||
const abomination1 = [
|
var encounterDiffThree = [
|
||||||
{name: "radroach", faction: "abomination", minHealth: 1, maxHealth: 10, lootTable: "food", numEnemies: 1},
|
//NCR
|
||||||
{name: "weak ghoul", faction: "abomination", minHealth: 10, maxHealth: 15, lootTable: "junk", numEnemies: 1},
|
[],
|
||||||
{name: "bloatfly swarm", faction: "abomination", minHealth: 1, maxHealth: 5, lootTable: "food", numEnemies: 5},
|
//Legion
|
||||||
|
[],
|
||||||
|
//Raider
|
||||||
|
[],
|
||||||
|
//Settler
|
||||||
|
[],
|
||||||
|
//BOS
|
||||||
|
[],
|
||||||
|
//Abomination
|
||||||
|
[]
|
||||||
|
];
|
||||||
|
var encounterDiffFour = [
|
||||||
|
//NCR
|
||||||
|
[],
|
||||||
|
//Legion
|
||||||
|
[],
|
||||||
|
//Raider
|
||||||
|
[],
|
||||||
|
//Settler
|
||||||
|
[],
|
||||||
|
//BOS
|
||||||
|
[],
|
||||||
|
//Abomination
|
||||||
|
[]
|
||||||
|
];
|
||||||
|
var encounterDiffFive = [
|
||||||
|
//NCR
|
||||||
|
[],
|
||||||
|
//Legion
|
||||||
|
[],
|
||||||
|
//Raider
|
||||||
|
[],
|
||||||
|
//Settler
|
||||||
|
[],
|
||||||
|
//BOS
|
||||||
|
[],
|
||||||
|
//Abomination
|
||||||
|
[]
|
||||||
];
|
];
|
||||||
|
|
||||||
const legion2 = [];
|
|
||||||
const BOS2 = [];
|
|
||||||
const settler2 = [];
|
|
||||||
const NCR2 = [];
|
|
||||||
const raider2 = [];
|
|
||||||
const abomination2 = [];
|
|
||||||
|
|
||||||
const legion3 = [];
|
|
||||||
const BOS3 = [];
|
|
||||||
const settler3 = [];
|
|
||||||
const NCR3 = [];
|
|
||||||
const raider3 = [];
|
|
||||||
const abomination3 = [];
|
|
||||||
|
|
||||||
const legion4 = [];
|
|
||||||
const BOS4 = [];
|
|
||||||
const settler4 = [];
|
|
||||||
const NCR4 = [];
|
|
||||||
const raider4 = [];
|
|
||||||
const abomination4 = [];
|
|
||||||
|
|
||||||
const legion5 = [];
|
|
||||||
const BOS5 = [];
|
|
||||||
const settler5 = [];
|
|
||||||
const NCR5 = [];
|
|
||||||
const raider5 = [];
|
|
||||||
const abomination5 = [];
|
|
||||||
|
|
||||||
//RIP the filterFactionFunction :(
|
//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
|
//Creates the menu for an encounter. "faction" represents the faction for the encounter, "diffWeighting" changes the odds for
|
||||||
//an encounter's difficulty (1-5)
|
//an encounter's difficulty (1-5)
|
||||||
//IGNORE THE VARIABLE COMMENTS IN THE NESTED SWITCH STATEMENT, they're placeholders for me
|
//IGNORE THE VARIABLE COMMENTS IN THE NESTED SWITCH STATEMENT, they're placeholders for me
|
||||||
function encounterMenuMaker(reqFaction, diffWeighting){
|
function encounterMenuMaker(reqFaction, diffWeighting){
|
||||||
var encounterDifficulty = diffWeighting*(variables.randomNumber(1, 20));
|
var encounterDifficulty = (diffWeighting * variables.randomNumber(1, 20));
|
||||||
switch(encounterDifficulty){
|
if((reqFaction != "NCR") && (reqFaction != "BOS")){
|
||||||
case(encounterDifficulty <= 20):
|
factionFailsafe = reqFaction.toLowerCase();
|
||||||
//var encounterDiffActual = 1;
|
} else {
|
||||||
switch(reqFaction){
|
factionFailsafe = reqFaction;
|
||||||
case "legion":
|
|
||||||
var encountered = legion1[variables.randomNumber(0, legion1.length)];
|
|
||||||
break;
|
|
||||||
case "BOS":
|
|
||||||
var encountered = BOS1[variables.randomNumber(0, BOS1.length)];
|
|
||||||
break;
|
|
||||||
case "NCR":
|
|
||||||
var encountered = NCR1[variables.randomNumber(0, NCR1.length)];
|
|
||||||
break;
|
|
||||||
case "raider":
|
|
||||||
var encountered = raider1[variables.randomNumber(0, raider1.length)];
|
|
||||||
break;
|
|
||||||
case "settler":
|
|
||||||
var encountered = settler1[variables.randomNumber(0, settler1.length)];
|
|
||||||
break;
|
|
||||||
case "abomination":
|
|
||||||
var encountered = abomination1[variables.randomNumber(0, abomination1.length)];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case(21 <= encounterDifficulty <= 40):
|
|
||||||
//var encounterDiffActual = 2;
|
|
||||||
break;
|
|
||||||
case(41 <= encounterDifficulty <= 60):
|
|
||||||
//var encounterDiffActual = 3;
|
|
||||||
break;
|
|
||||||
case(61 <= encounterDifficulty <= 80):
|
|
||||||
//var encounterDiffActual = 4;
|
|
||||||
break;
|
|
||||||
case(81 <= encounterDifficulty):
|
|
||||||
//var encounterDiffActual = 5;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return encountered;
|
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];
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue