From 1179fb5afc90a80d585839de857edc5e788a3517 Mon Sep 17 00:00:00 2001 From: Caroline Foy Date: Mon, 28 Apr 2025 12:11:00 -0500 Subject: [PATCH] Added comments for "poiscreens" and "encounters" files --- files/encounters.js | 10 ++++++++++ files/poiscreens.js | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/files/encounters.js b/files/encounters.js index 3163268..4666507 100644 --- a/files/encounters.js +++ b/files/encounters.js @@ -5,10 +5,16 @@ import './variables.js'; //5-50 abominations, 51-200 MWBOS, 201-255 legion, a5-a40 NCR, b0-b30 abomination, b40-b80 abomination, b90+ NCR, b80-b90 enclave //HLE = high level encounter, this is a filter that determines if the player can get, as the name implies, high level encounters + +//This function, which is called whenever the player moves, runs a quick calculation to determine if the player encounters +//an enemy. If they do encounter an enemy, the function uses the player's location to determine which enemy they encounter. +//The farther the player goes, the more likely they are to encounter a high-level enemy. Enemies scale in health and damage with +//the player's level. export function naturalEncounter(location){ var HLE = false; var encounter = false; var encounterLuck = randomNumber(1, 100); + //Checks if the player gets an encounter, and what enemy pool the encounter comes from. if(location > 250){ HLE = true; } @@ -48,6 +54,7 @@ export function naturalEncounter(location){ } } + //Draws the enemy/encounter from an array of different possible encounters. if(encounter != false){ switch(encounter){ case "abomination": @@ -133,6 +140,8 @@ export function naturalEncounter(location){ } }; +//Used for when we need to ensure that the player encounters an enemy somewhere. Also used for combat testing. +//Function takes in the faction of the enemy, and if the enemy can be/has to be a high level encounter. export function forcedEncounter(HLE, faction, forcedHLE){ var HLEDeterminant = randomNumber(1, 2) if((HLE == true && HLEDeterminant == 1) || forcedHLE == true){ @@ -172,6 +181,7 @@ export function forcedEncounter(HLE, faction, forcedHLE){ } } +//A list of arrays with every possible enemy encounter, as well as their stats and equipment. var raiderEncounters = [ {name: "Raider Aspirant", faction: "raider", minLevel: 1, maxLevel: 15, health: 10, weapon: equipmentList[2], armor: equipmentList[10]}, {name: "Raider", faction: "raider", minLevel: 15, maxLevel: 25, health: 10, weapon: equipmentList[2], armor: equipmentList[10]}, diff --git a/files/poiscreens.js b/files/poiscreens.js index b96eb76..31c3dab 100644 --- a/files/poiscreens.js +++ b/files/poiscreens.js @@ -4,6 +4,9 @@ import { userInput, pauseScreen, enableRawMode, disableRawMode, sleep } from "./ import './variables.js'; import { whitespringStore, trader, eurekaStore, newVegasStore, vaultZeroStore } from "./shops.js"; +//This function uses a switch statement to determine the player's location within a given range. If said location IS +//within the given range, the statement will call a seperate function to declare that the player is in a point of interest, +//building the player's screen to match that. export function checkPOI() { if (path == 0) { if (location >= (pois[poiCounter].location)-3 && location <= pois[poiCounter].location && pois[poiCounter].visited == false) { @@ -92,6 +95,8 @@ export function checkPOI() { } } +//This array holds important information about every point of interest in the game, such as its name, locaiton on the +//player's path, and a boolean for if it has been visited by the player yet. global.poiCounter = 0; global.pois = [ {name: "Whitespring Bunker", location: 25, path: 0, visited: false}, @@ -119,7 +124,12 @@ global.pois = [ {name: "Camp Navarro", location: 100, path: 2, visited: false}, ] +//EVERY POI FUNCTION WORKS THE SAME, THE ONLY DIFFERENCE IS THAT THEY EACH CALL THEIR RESPECTIVE DIALOGUE AND +//SHOP FUNCTIONS. + +//This function builds the POI the player has reached. In this instance, it builds the POI called "The Whitespring". function whitespring() { + //Basic introductory message, along with changing the game's basic functioning with the raw mode command. disableRawMode(); console.clear(); sleep(1); @@ -131,6 +141,8 @@ function whitespring() { console.log("3) Open your PIP-Boy"); console.log("4) Leave"); let whitespringInput = userInput("Enter: "); + //Switch statement changes depending on the user's input, allowing them to explore the POI, talk or trade with the locals, + //check their stats, or leave if they wish to. switch(whitespringInput) { case "1": console.clear();