diff --git a/README.md b/README.md index 14f6a51..f56a262 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Lonesome Road -## Run "npm install readline-sync" before running! It is needed for user input! + +## NPM Dependencies +* readline-sync diff --git a/files/main.js b/files/main.js index 28edc2b..ba4954b 100644 --- a/files/main.js +++ b/files/main.js @@ -3,7 +3,6 @@ const variables = require("./variables.js"); const shops = require("./shops"); const readline = require('node:readline'); - console.clear(); console.log("__________________________________________________________________________________________________________________________________"); console.log(" _____ _ ____ "); @@ -25,11 +24,14 @@ var mainMenuInput = variables.userInput("Enter: ") switch(mainMenuInput) { case "1": startGame(); + break; case "2": - showManual(); + while (true) { console.log(variables.randomNumber(10,15)); } + break; case "3": console.log("Quitting Game..."); variables.sleep(1000); + break; } function startGame() { // So far what I have is filler and testing, feel free to change. @@ -46,4 +48,5 @@ function startGame() { // So far what I have is filler and testing, feel free to console.clear(); variables.prewarmoney = 500; + shops.trader(); } \ No newline at end of file diff --git a/files/shops.js b/files/shops.js index 81ad52c..656b08f 100644 --- a/files/shops.js +++ b/files/shops.js @@ -14,9 +14,7 @@ var rrInv = []; var vt0Inv = []; var vegasInv = []; // A mix of gunrunners, mick&ralphs, and followers var eurInv = []; -var trader1Inv = []; -var trader2Inv = []; -var trader3Inv = []; +var traderInv = ["gun", "stimpak", "radx"]; function ravenRock() { // purchasing code @@ -35,5 +33,11 @@ function eureka() { } function trader() { // One of the 3 trader inventories, chosen randomly - // purchasing code + var tempTraderInv = []; + for (var a = 0; a <= 2; a++) { + let randomPick = Math.m + tempTraderInv.push(traderInv[1]); + console.log(randomPick); + } + console.log(tempTraderInv); } \ No newline at end of file diff --git a/files/variables.js b/files/variables.js index 1bfbdec..48544c8 100644 --- a/files/variables.js +++ b/files/variables.js @@ -24,6 +24,7 @@ module.exports = { // Lets variables and functions be used in other files sleep, checkLose, userInput, + randomNumber }; var name = ''; @@ -34,7 +35,9 @@ 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 Raven Rock, 200 is CTE. +var location = 0; // Location in the world, 0 is Raven Rock, 255 is New Vegas +var locationA = 0; // Location on path A, +var locationB = 0; // Location on path B, 225 is Navarro var ammo = 0; // Used in encounters and hunting, No cap :) @@ -107,8 +110,7 @@ function checkLose() { // Checks to see if any lose conditions have been met } } -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 +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; @@ -135,4 +137,12 @@ function calcLocation() { // Calculates your location in the world using locatio function userInput(question) { // Basic user input functions, takes in the question to be asked. let answer = readline.question(question); return(answer); +} + +function randomNumber(min, max) { // Takes in two parameters, min and max, and returns a random number between those boundries. + while (true) { + var randNum = Math.floor(Math.random() * (max+1)) + if (randNum >= min) { break; } + } + return randNum; } \ No newline at end of file