Add game,js and modify calcLocation. Added variable exports to every file.
This commit is contained in:
parent
25efc4f9f9
commit
3178ef479b
10 changed files with 109 additions and 85 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
// Deathscreens, they should be the fallout 1 screens
|
// Deathscreens, they should be the fallout 1 screens
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
deathScreen,
|
deathScreen,
|
||||||
|
|
@ -6,7 +7,7 @@ module.exports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function deathScreen() {
|
function deathScreen() {
|
||||||
let random = Math.random(1,3);
|
let random = variables.randomNumber(1,3);
|
||||||
if (random = 1) { death1(); }
|
if (random = 1) { death1(); }
|
||||||
if (random = 2) { death2(); }
|
if (random = 2) { death2(); }
|
||||||
if (random = 3) { death3(); }
|
if (random = 3) { death3(); }
|
||||||
|
|
|
||||||
90
files/game.js
Normal file
90
files/game.js
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
// Hunting Game, if we even decide to do it.
|
// Hunting Game, if we even decide to do it.
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
// Program is started from here, runs functions from other files.
|
// Program is started from here, runs functions from other files.
|
||||||
const variables = require("./variables.js");
|
const variables = require("./variables.js");
|
||||||
|
const game = require("./game.js");
|
||||||
const shops = require("./shops");
|
const shops = require("./shops");
|
||||||
const readline = require('node:readline');
|
const readline = require('node:readline');
|
||||||
|
|
||||||
|
|
@ -26,7 +27,8 @@ switch(mainMenuInput) {
|
||||||
startGame();
|
startGame();
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
while (true) { console.log(variables.randomNumber(10,15)); }
|
console.log("Follow the link below for a game manual.")
|
||||||
|
console.log("[ENTER LINK HERE]")
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
console.log("Quitting Game...");
|
console.log("Quitting Game...");
|
||||||
|
|
@ -48,5 +50,5 @@ function startGame() { // So far what I have is filler and testing, feel free to
|
||||||
console.clear();
|
console.clear();
|
||||||
|
|
||||||
variables.prewarmoney = 500;
|
variables.prewarmoney = 500;
|
||||||
shops.trader();
|
shops.ravenRock();
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
// Map Screen
|
// Map Screen
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
// Holds the screens for every POI including thier menus.
|
// Holds the screens for every POI including thier menus.
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
// River crossing screens and options.
|
// River crossing screens and options.
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const readline = require('readline-sync');
|
const readline = require('readline-sync');
|
||||||
const variables = require("./variables");
|
const variables = require("./variables.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ravenRock,
|
ravenRock,
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
// Halt travel screen and menu.
|
// Halt travel screen and menu.
|
||||||
|
const variables = require("./variables.js");
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Holds the global variables, functions, and math operations such as the day counter and food eaten..
|
// Holds the global variables and useful functions such as userInput
|
||||||
const readline = require('readline-sync');
|
const readline = require('readline-sync');
|
||||||
|
|
||||||
module.exports = { // Lets variables and functions be used in other files
|
module.exports = { // Lets variables and functions be used in other files
|
||||||
|
|
@ -17,12 +17,7 @@ module.exports = { // Lets variables and functions be used in other files
|
||||||
name,
|
name,
|
||||||
prewarmoney,
|
prewarmoney,
|
||||||
caps,
|
caps,
|
||||||
eatfood,
|
|
||||||
calcLocation,
|
|
||||||
calcSickPoints,
|
|
||||||
scavenge,
|
|
||||||
sleep,
|
sleep,
|
||||||
checkLose,
|
|
||||||
userInput,
|
userInput,
|
||||||
randomNumber
|
randomNumber
|
||||||
};
|
};
|
||||||
|
|
@ -59,81 +54,12 @@ var inventory = []; // Max of 5 items
|
||||||
|
|
||||||
var lootTables = [[],[],[],[],[]] // Only small things like food and ammo, 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() {
|
var daysSinceScav = 0; // Days since your last scavenge, you must wait 15 days before scavenging again.
|
||||||
if (food == 0) { health - 20 }
|
|
||||||
if (isSick == true) { food = food-((travelSpeed*foodAmt)+sickSeverity); }
|
|
||||||
else { food = food-(travelSpeed*foodAmt); }
|
|
||||||
health = health+(5*foodAmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcSickPoints() {
|
|
||||||
if (isSick = true) {
|
|
||||||
sickPoints = sickPoints+((sickSeverity-(0.5*foodAmt))+(0.5*(travelSpeed+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!
|
|
||||||
let luck = Math.random(1,100);
|
|
||||||
if (luck <= 20) {
|
|
||||||
let group = 0;
|
|
||||||
let random = Math.random(lootTables[group][0], lootTables[group][3]);
|
|
||||||
inventory.push(random);
|
|
||||||
} else if (luck <= 40) {
|
|
||||||
let group = 1;
|
|
||||||
let random = Math.random(lootTables[group][0], lootTables[group][3]);
|
|
||||||
inventory.push(random);
|
|
||||||
} else if (luck <= 60) {
|
|
||||||
let group = 2;
|
|
||||||
let random = Math.random(lootTables[group][0], lootTables[group][3]);
|
|
||||||
inventory.push(random);
|
|
||||||
} else if (luck <= 80) {
|
|
||||||
let group = 3;
|
|
||||||
let random = Math.random(lootTables[group][0], lootTables[group][3]);
|
|
||||||
inventory.push(random);
|
|
||||||
} else if (luck <= 100) {
|
|
||||||
let group = 4;
|
|
||||||
let random = Math.random(lootTables[group][0], lootTables[group][3]);
|
|
||||||
inventory.push(random);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sleep(time) { // Waits the inputed amt of miliseconds before proceeding
|
function sleep(time) { // Waits the inputed amt of miliseconds before proceeding
|
||||||
setTimeout(() => {}, time);
|
setTimeout(() => {}, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLose() { // Checks to see if any lose conditions have been met
|
|
||||||
if (health <= 0 || sickPoints >= 50) {
|
|
||||||
deathScreen();
|
|
||||||
}
|
|
||||||
if (day >= 365) {
|
|
||||||
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 (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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function userInput(question) { // Basic user input functions, takes in the question to be asked.
|
function userInput(question) { // Basic user input functions, takes in the question to be asked.
|
||||||
let answer = readline.question(question);
|
let answer = readline.question(question);
|
||||||
return(answer);
|
return(answer);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue