Add map and deathscreen files, add exports to variable file.

This commit is contained in:
Raktbastr 2025-02-22 10:31:14 -06:00
parent ef3035f944
commit 455a867719
4 changed files with 90 additions and 8 deletions

View file

@ -1,11 +1,31 @@
// Holds the global variables, functions, and math operations such as the day counter and food eaten..
const death = require("./deathscreens");
module.exports = {
sleep
day,
location,
ammo,
food,
foodAmt,
health,
travelSpeed,
isRadiated,
radSeverity,
isSick,
sickSeverity,
inventory,
eatfood,
calcLocation,
calcSickPoints,
scavenge,
sleep,
checkLose,
};
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 ammo = 0; // No cap :)
var food = 0; // Max: 200
@ -27,8 +47,9 @@ var inventory = []; // Max of 5 items
var lootTables = [[],[],[],[],[]] // 5 Loot tables per scavenge score, 3 items in each, first is best
function eatfood() {
if (food == 0) { health - 20 }
if (isSick == true) { food = food-((travelSpeed*foodAmt)+sickSeverity); }
else { food = food-(travelSpeed*3); }
else { food = food-(travelSpeed*foodAmt); }
health = health+(5*foodAmt);
}
@ -67,3 +88,35 @@ function sleep(time) {
setTimeout(() => {}, time);
}
function checkLose() {
if (health <= 0 || sickPoints >= 50) {
deathScreen();
}
if (day >= 365) {
timeDeath();
}
}
function calcLocation() { // 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;
} else {
location++;
}
}
if (travelSpeed == 2) {
if (isSick == true) {
location = location+1.5;
} else {
location = location+2;
}
}
if (travelSpeed == 3) {
if (isSick == true) {
location = location+2.25;
} else {
location = location+3;
}
}
}