diff --git a/files/main.js b/files/main.js index 79ebc19..0665ef2 100644 --- a/files/main.js +++ b/files/main.js @@ -1,7 +1,7 @@ // Program is started from here, runs functions from other files. import { userInput, calcLocation, radPointsCalc, healthCapCalc, checkLose, sleep } from './functions.js'; import { pois, poiCounter } from './poiscreens.js'; -import { name, prewarmoney } from './variables.js'; +import { name, prewarmoney, variableChange } from './variables.js'; console.clear(); @@ -34,13 +34,14 @@ switch(mainMenuInput) { console.log("Quitting Game..."); break; case "4": - sleep(5); + variableChange("name","=","finn"); + console.log(name); break; } function startGame() { // So far what I have is filler and testing, feel free to change. console.clear(); - name = userInput("What is your name? "); + variableChange("name","=",userInput("What is your name? ")); console.log(name+" Is now your name...") console.clear(); console.log("Intro:"); diff --git a/files/variables.js b/files/variables.js index bd226f7..e709fbe 100644 --- a/files/variables.js +++ b/files/variables.js @@ -36,4 +36,12 @@ export var daysSinceScav = 0; // Days since player last scavenged. Must be >= 15 export var name = "placeholder"; // Player name, changed when the game starts - +export function variableChange(variable, operation, value) { + switch(operation) { + case "%": global[variable] = global[variable] % value + case "+": global[variable] = global[variable] + value + case "-": global[variable] = global[variable] - value + case "/": global[variable] = global[variable] / value + case "=": global[variable] = value + } +}