// Holds functions needed to play the game const variables = require("./variables.js"); const death = require("./deathscreens.js"); module.exports = { eatFood, calcSickPoints, scavenge, checkLose, calcLocation, } function eatfood() { if (variables.food == 0) { variables.health - 3*variables.travelSpeed } else if (variables.isSick == true) { variables.food = variables.food-((variables.travelSpeed*variables.foodAmt)+variables.sickSeverity); } else { variables.food = variables.food-(variables.travelSpeed*variables.foodAmt); } variables.health = variables.health+(5*variables.foodAmt); } function calcSickPoints() { if (variables.isSick = true) { variables.sickPoints = variables.sickPoints+((variables.sickSeverity-(0.5*variables.foodAmt))+(0.5*(variables.travelSpeed+variables.radSeverity))); } } 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! if (variables.daysSinceScav < 20 ) { console.log("You must wait "+(20-variables.daysSinceScav)+" days until you can scavenge again") } else { let luck = variables.randomNumber(1,100); if (luck <= 20) { let group = 0; let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]); inventory.push(random); } else if (luck <= 40) { let group = 1; let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]); inventory.push(random); } else if (luck <= 60) { let group = 2; let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]); inventory.push(random); } else if (luck <= 80) { let group = 3; let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]); inventory.push(random); } else if (luck <= 100) { let group = 4; let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]); inventory.push(random); } } } function checkLose() { // Checks to see if any lose conditions have been met if (variables.health <= 0 || variables.sickPoints >= 50) { death.deathScreen(); } if (variables.day >= 365) { death.timeDeath(); } } 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 (variables.travelSpeed == 1) { if (variables.isSick == true) { variables.location = variables.location+0.75; } else { variables.location++; } } if (variables.travelSpeed == 2) { if (variables.isSick == true) { variables.location = variables.location+1.5; } else { variables.location = variables.location+2; } } if (variables.travelSpeed == 3) { if (variables.isSick == true) { variables.location = variables.location+2.25; } else { variables.location = variables.location+3; } } }