Begin work on rep system. Finished encounter generation for the most part. Needs testing.

This commit is contained in:
Raktbastr 2025-03-20 11:34:17 -05:00
parent 42bf2a484a
commit 49f93574af
5 changed files with 185 additions and 37 deletions

View file

@ -1,12 +1,13 @@
const variables = require("./variables.js");
const combat = requre("./combat.js");
module.exports = {
encounterMenuMaker,
initializeEncounter,
}
function initializeEncounter(reqFaction, diffWeighting, fight, flee){
var encounter = encounterMenuMaker(reqFaction, diffWeighting);
function initializeEncounter(reqFaction, diffWeighting, fight, flee, forceFaction){
var encounter = encounterMenuMaker(reqFaction, diffWeighting, forceFaction);
console.clear();
console.log("You come across a " + encounter.name);
var encounterHealth = variables.randomNumber(encounter.minHealth, encounter.maxHealth);
@ -14,6 +15,8 @@ function initializeEncounter(reqFaction, diffWeighting, fight, flee){
console.log("What would you like to do?");
console.log("--------------------------");
var playerOptions = 1;
console.log(playerOptions + ") Inventory");
playerOptions++
if(fight == true){
console.log(playerOptions + ") Fight");
playerOptions++;
@ -22,7 +25,23 @@ function initializeEncounter(reqFaction, diffWeighting, fight, flee){
console.log(playerOptions + ") Flee");
playerOptions++;
}
console.log(playerOptions + ") Inventory");
while(true) {
let encounterInput = variables.userInput("Enter: ")
switch(mainMenuInput) {
case "1":
console.log(variables.inventory);
case "2":
combat.initCombat(encounter);
break;
case "3":
if (variables.reputation{reqFaction} < 4) {
if (variables.randomNumber(1,100) < 40){
console.log("You tried to flee... but they noticed you.");
combat.initCombat(encounter);
}
}
}
}
}
//Add any new encounter ideas to their required faction and difficulty
@ -47,7 +66,9 @@ var encounterDiffOne = [
{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},
]
],
//MWBOS
[]
];
var encounterDiffTwo = [
//NCR
@ -61,6 +82,8 @@ var encounterDiffTwo = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffThree = [
@ -75,6 +98,8 @@ var encounterDiffThree = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFour = [
@ -89,6 +114,8 @@ var encounterDiffFour = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFive = [
@ -103,25 +130,40 @@ var encounterDiffFive = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
//RIP the filterFactionFunction :(
//Declaring some stuff to make them global variables
var encountered = [];
var faction = 0;
let encountered = [];
//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;
function encounterMenuMaker(reqFactionEMM, diffWeightingEMM, forceOptEMM){
switch(diffWeightingEMM){
case 1:
reqFactionEMM = encounterDiffOne
break;
case 2:
reqFactionEMM = encounterDiffTwo
break;
case 3:
reqFactionEMM = encounterDiffThree
break;
case 4:
reqFactionEMM = encounterDiffFour
break;
case 5:
reqFactionEMM = encounterDiffFive
break;
}
var encounterDifficulty = (diffWeightingEMM * variables.randomNumber(1, 20));
factionFailsafe = reqFactionEMM.toLowerCase();
switch(factionFailsafe){
case "NCR":
faction = 0;
@ -141,17 +183,38 @@ function encounterMenuMaker(reqFaction, diffWeighting){
case "abomination":
faction = 5;
break;
case "MWBOS":
faction = 6;
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){
if (forceOptEMM == true) {
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 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[encountered.length - 1];
} else {
encountered.push(encounterDiffFive[faction][variables.randomNumber(0, encounterDiffFive[faction].length - 1)]);
let x = variables.randomNumber(0, 100)
if (x >= 75) {
if (x <=80) {
encountered.push(encounterDiffOne[raider][variables.randomNumber(0, encounterDiffOne[raider].length - 1)])
}
if (x <=90) {
encountered.push(encounterDiffOne[settler][variables.randomNumber(0, encounterDiffOne[settler].length - 1)])
}
if (x <=100) {
encountered.push(encounterDiffOne[abomination][variables.randomNumber(0, encounterDiffOne[abomination].length - 1)])
}
}
if (x < 75) {
encountered.push(encounterDiffOne[faction][variables.randomNumber(0, encounterDiffOne[faction].length - 1)])
}
}
return encountered[0];
}