Fixed sleep function issue and writing to global variables.
This commit is contained in:
parent
dbd27cfa7d
commit
fdd58af63e
4 changed files with 37 additions and 31 deletions
|
|
@ -3,8 +3,10 @@ import { createRequire } from 'module';
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
var readlineSync = require('readline-sync');
|
var readlineSync = require('readline-sync');
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
|
import { promisify } from "util";
|
||||||
|
const execPromise = promisify(exec);
|
||||||
|
|
||||||
|
|
||||||
import { food, foodRate, health, healthCap, locationA, locationB, name, radPoints, radSeverity, walkRate } from "./variables.js";
|
|
||||||
|
|
||||||
// Used for basic functions, not game specific
|
// Used for basic functions, not game specific
|
||||||
export function userInput(question) { // Basic user input functions, takes in the question to be asked.
|
export function userInput(question) { // Basic user input functions, takes in the question to be asked.
|
||||||
|
|
@ -82,9 +84,12 @@ export function calcLocation() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function sleep(time) {
|
||||||
export function sleep(time) {
|
try {
|
||||||
exec("sleep "+time);
|
await execPromise(`sleep ${time}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error executing sleep command:", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function death() {
|
function death() {
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ console.log("--------------------------");
|
||||||
console.log("1) Start new game");
|
console.log("1) Start new game");
|
||||||
console.log("2) Learn How to play");
|
console.log("2) Learn How to play");
|
||||||
console.log("3) Quit Game");
|
console.log("3) Quit Game");
|
||||||
console.log("4) Dev stuff for testing");
|
console.log("4) Dev stuff for testing\n");
|
||||||
|
|
||||||
var mainMenuInput = userInput("Enter: ")
|
var mainMenuInput = userInput("Enter: ");
|
||||||
|
|
||||||
switch(mainMenuInput) {
|
switch(mainMenuInput) {
|
||||||
case "1":
|
case "1":
|
||||||
|
|
@ -35,6 +35,7 @@ switch(mainMenuInput) {
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
console.log("Quitting Game...");
|
console.log("Quitting Game...");
|
||||||
|
await sleep(1);
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "4":
|
||||||
for(var a = 0; a < 10; a++){
|
for(var a = 0; a < 10; a++){
|
||||||
|
|
@ -50,14 +51,14 @@ switch(mainMenuInput) {
|
||||||
|
|
||||||
function startGame() { // So far what I have is filler and testing, feel free to change.
|
function startGame() { // So far what I have is filler and testing, feel free to change.
|
||||||
console.clear();
|
console.clear();
|
||||||
variableChange("name","=",userInput("What is your name? "));
|
name = userInput("What is your name? ");
|
||||||
console.log(name+" Is now your name...")
|
console.log(name+" Is now your name...")
|
||||||
console.clear();
|
console.clear();
|
||||||
console.log("Intro:");
|
console.log("Intro:");
|
||||||
console.log("You are an ordinary loyal Enclave Soldier working at Raven Rock. \nYou are typing away at your terminal, entering reports of recovered materials when a message flashes on it");
|
console.log("You are an ordinary loyal Enclave Soldier working at Raven Rock. \nYou are typing away at your terminal, entering reports of recovered materials when a message flashes on it");
|
||||||
console.log("|||||||")
|
console.log("|||||||")
|
||||||
console.log("|| Enclave Intranet Messager");
|
console.log("|| Enclave Intranet Messager");
|
||||||
console.log("")
|
console.log("|||||||")
|
||||||
console.log("|| Message From: potus");
|
console.log("|| Message From: potus");
|
||||||
console.log("|||||||\n\n")
|
console.log("|||||||\n\n")
|
||||||
console.log("Dear "+name+",\n\n This is a direct order from the Enclave High Command. \nIgnore all previous directives. Proceed to Camp Navarro immediately. \nSeek safe passage through the Brotherhood and NCR territories. \nDo not disclose your mission to anyone but Enclave Personel with \nsecurity clearance 5 or higher. Reqisition supplies before departure. \nYou have been given 1 YEAR to complete this mission or face discharge.\n\n Signed, President John Henry Eden\n\n");
|
console.log("Dear "+name+",\n\n This is a direct order from the Enclave High Command. \nIgnore all previous directives. Proceed to Camp Navarro immediately. \nSeek safe passage through the Brotherhood and NCR territories. \nDo not disclose your mission to anyone but Enclave Personel with \nsecurity clearance 5 or higher. Reqisition supplies before departure. \nYou have been given 1 YEAR to complete this mission or face discharge.\n\n Signed, President John Henry Eden\n\n");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Holds poi code, seperate from encounters.js
|
// Holds poi code, seperate from encounters.js
|
||||||
|
|
||||||
import { userInput } from "./functions.js";
|
import { userInput } from "./functions.js";
|
||||||
import { location, locationA, locationB, path } from "./variables.js";
|
import './variables.js';
|
||||||
|
|
||||||
export function checkPOI() {
|
export function checkPOI() {
|
||||||
if (path == 0) {
|
if (path == 0) {
|
||||||
|
|
@ -91,8 +91,8 @@ export function checkPOI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export var poiCounter = 0;
|
global.poiCounter = 0;
|
||||||
export var pois = [
|
global.pois = [
|
||||||
{name: "Whitespring Bunker", location: 25, path: 0, visited: false},
|
{name: "Whitespring Bunker", location: 25, path: 0, visited: false},
|
||||||
{name: "BOS Bunker Gamma", location: 100, path: 0, visited: false},
|
{name: "BOS Bunker Gamma", location: 100, path: 0, visited: false},
|
||||||
{name: "BOS Bunker Delta", location: 125, path: 0, visited: false},
|
{name: "BOS Bunker Delta", location: 125, path: 0, visited: false},
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
// Now holds only variables
|
// Now holds only variables
|
||||||
|
|
||||||
// Player Currency
|
// Player Currency
|
||||||
export var prewarmoney = 0; // Used with enclave vendors
|
global.prewarmoney = 0; // Used with enclave vendors
|
||||||
export var caps = 0; // Used with all other vendors
|
global.caps = 0; // Used with all other vendors
|
||||||
|
|
||||||
// Player Stats
|
// Player Stats
|
||||||
export var healthCap = 0; // Maximum health, raises each level
|
global.healthCap = 0; // Maximum health, raises each level
|
||||||
export var health = 0; // Players current HP
|
global.health = 0; // Players current HP
|
||||||
export var food = 0; // Amount of food player has
|
global.food = 0; // Amount of food player has
|
||||||
export var isRadiated = false;
|
global.isRadiated = false;
|
||||||
export var radSeverity = 0; // Modifies healthCapCalc. 3 Levels
|
global.radSeverity = 0; // Modifies healthCapCalc. 3 Levels
|
||||||
export var radPoints = 0; // If the player reaches 100 rad points the game ends
|
global.radPoints = 0; // If the player reaches 100 rad points the game ends
|
||||||
export var xpPerLevel = 10; // Amount of XP needed per level. Raises 50% each level
|
global.xpPerLevel = 10; // Amount of XP needed per level. Raises 50% each level
|
||||||
export var level = 0; // Level of player. Modifies enemy scaling
|
global.level = 0; // Level of player. Modifies enemy scaling
|
||||||
export var inventory = [ // Inventory of player, holds all items
|
global.inventory = [ // Inventory of player, holds all items
|
||||||
// Supplies: chems, aid
|
// Supplies: chems, aid
|
||||||
[],
|
[],
|
||||||
// Equipment: weapons, armor, tools
|
// Equipment: weapons, armor, tools
|
||||||
|
|
@ -21,20 +21,20 @@ export var inventory = [ // Inventory of player, holds all items
|
||||||
]
|
]
|
||||||
|
|
||||||
// Game Mechanics
|
// Game Mechanics
|
||||||
export var walkRate = 0; // Units the player walks per day, affects foodRateCalc and radPointsCalc
|
global.walkRate = 0; // Units the player walks per day, affects foodRateCalc and radPointsCalc
|
||||||
export var foodRate = 0; // Amount of food player eats per day, affects radPointsCalc
|
global.foodRate = 0; // Amount of food player eats per day, affects radPointsCalc
|
||||||
|
|
||||||
export var path = 0; // Path player is currently on, 0 = Main, 1 = A, 2 = B
|
global.path = 0; // Path player is currently on, 0 = Main, 1 = A, 2 = B
|
||||||
export var location = 0; // Location on main path, 0-255 = main, 500-1000 = A, 1500-2000 = B
|
global.location = 0; // Location on main path, 0-255 = main, 500-1000 = A, 1500-2000 = B
|
||||||
export var locationA = 0; // Location on path A
|
global.locationA = 0; // Location on path A
|
||||||
export var locationB =0; // Location on path B
|
global.locationB =0; // Location on path B
|
||||||
|
|
||||||
export var reputation = {mwbos: 4, legion: 4, ncr: 2, bos: 1, enclave: 10, abomination: 0, raider: 0}
|
global.reputation = {mwbos: 4, legion: 4, ncr: 2, bos: 1, enclave: 10, abomination: 0, raider: 0}
|
||||||
// Rep for each faction. Number between 0(worst) and 10(best), 5 is neutral
|
// Rep for each faction. Number between 0(worst) and 10(best), 5 is neutral
|
||||||
|
|
||||||
export var daysSinceScav = 0; // Days since player last scavenged. Must be >= 15 to scavenge again.
|
global.daysSinceScav = 0; // Days since player last scavenged. Must be >= 15 to scavenge again.
|
||||||
|
|
||||||
export var name = "placeholder"; // Player name, changed when the game starts
|
global.name = "placeholder"; // Player name, changed when the game starts
|
||||||
|
|
||||||
export function variableChange(variable, operation, value) {
|
export function variableChange(variable, operation, value) {
|
||||||
switch(operation) {
|
switch(operation) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue