Added readline function, started work on shops, added some comments, made main menu and a bit of the start.

This commit is contained in:
Raktbastr 2025-02-25 10:04:03 -06:00
parent 455a867719
commit e413a5dea4
17 changed files with 3889 additions and 17 deletions

View file

@ -1,7 +1,7 @@
// Holds the global variables, functions, and math operations such as the day counter and food eaten..
const death = require("./deathscreens");
const readline = require('readline-sync');
module.exports = {
module.exports = { // Lets variables and functions be used in other files
day,
location,
ammo,
@ -14,29 +14,39 @@ module.exports = {
isSick,
sickSeverity,
inventory,
name,
prewarmoney,
caps,
eatfood,
calcLocation,
calcSickPoints,
scavenge,
sleep,
checkLose,
userInput,
};
var name = '';
var prewarmoney = 0; // Used in Enclave Stores
var caps = 0; // Used everywhere
var day = 0; // Should we add a definite end? 365 Days?
var location = 0; // Location in the world, 0 is Control Station Enclave, 200 is Raven rock.
var location = 0; // Location in the world, 0 is Raven Rock, 200 is CTE.
var ammo = 0; // No cap :)
var ammo = 0; // Used in encounters and hunting, No cap :)
var food = 0; // Max: 200
var foodAmt = 0; // Amt of food eaten per day, 3 levels, starting at 1
var health = 0; // Max: 100
var travelSpeed = 0; // 3 levels, starting at 1
var travelSpeed = 0; // Location points per day, 3 levels, starting at 1
var isRadiated = false;
var radSeverity = 0; // 3 levels, starting at 1
var radSeverity = 0; // Modifies many things, 3 levels, starting at 1
var isSick = false;
var sickPoints = 0; // If you accumulate 50 sick points you lose
@ -44,7 +54,7 @@ var sickSeverity = 0; // 3 levls, starting at 1
var inventory = []; // Max of 5 items
var lootTables = [[],[],[],[],[]] // 5 Loot tables per scavenge score, 3 items in each, first is best
var lootTables = [[],[],[],[],[]] // Only small things like food and ammo, 5 Loot tables per scavenge score, 3 items in each, first is best
function eatfood() {
if (food == 0) { health - 20 }
@ -59,7 +69,7 @@ function calcSickPoints() {
}
}
function scavenge() {
function scavenge() { // Rolls a random number between 1 and 100 to see which loot table you get, then picks a random item from it. ADD COOLDOWN!
let luck = Math.random(1,100);
if (luck <= 20) {
let group = 0;
@ -84,11 +94,11 @@ function scavenge() {
}
}
function sleep(time) {
function sleep(time) { // Waits the inputed amt of miliseconds before proceeding
setTimeout(() => {}, time);
}
function checkLose() {
function checkLose() { // Checks to see if any lose conditions have been met
if (health <= 0 || sickPoints >= 50) {
deathScreen();
}
@ -97,7 +107,8 @@ function checkLose() {
}
}
function calcLocation() { // You move your move speed per day, but 3/4 of it if you are sick
function calcLocation() { // Calculates your location in the world using location points.
// You move your move speed per day, but 3/4 of it if you are sick
if (travelSpeed == 1) {
if (isSick == true) {
location = location+0.75;
@ -119,4 +130,9 @@ function calcLocation() { // You move your move speed per day, but 3/4 of it if
location = location+3;
}
}
}
function userInput(question) { // Basic user input functions, takes in the question to be asked.
let answer = readline.question(question);
return(answer);
}