A lot, i dont rembr
This commit is contained in:
parent
fdd58af63e
commit
82565a2be9
6 changed files with 547 additions and 45 deletions
|
|
@ -5,6 +5,11 @@ var readlineSync = require('readline-sync');
|
|||
const { exec } = require("child_process");
|
||||
import { promisify } from "util";
|
||||
const execPromise = promisify(exec);
|
||||
import './variables.js';
|
||||
import { inventoryMenuM } from './inventory.js';
|
||||
import { checkPOI } from './poiscreens.js';
|
||||
|
||||
global.isRawModeEnabled = false; // Track whether raw mode is enabled
|
||||
|
||||
|
||||
|
||||
|
|
@ -30,12 +35,14 @@ export function healthCapCalc() { // Calculates HP cap given current radPoints
|
|||
}
|
||||
|
||||
export function radPointsCalc() { // Calculates radPoints given walk/foodrate
|
||||
radPoints = radPoints + 0.5 * (radSeverity * 10 + 5 * (walkRate + foodRate))
|
||||
if (isRadiated == true) {
|
||||
radPoints = radPoints + 0.5 * (radSeverity * 10 + 5 * (walkRate + foodRate));
|
||||
}
|
||||
}
|
||||
|
||||
export function eatFood() { // Calculates food amount after a day of eating
|
||||
if (food == 0) {
|
||||
health = health - 3*walkRate
|
||||
health = health - 0.25*walkRate
|
||||
} else {
|
||||
food = food - walkRate * foodRate
|
||||
}
|
||||
|
|
@ -93,10 +100,10 @@ export async function sleep(time) {
|
|||
}
|
||||
|
||||
function death() {
|
||||
let random = variables.randomNumber(1,3);
|
||||
if (random = 1) { deathScreen1(); }
|
||||
if (random = 2) { deathScreen2(); }
|
||||
if (random = 3) { deathScreen3(); }
|
||||
let random = randomNumber(1,3);
|
||||
if (random = 1) { death1(); }
|
||||
if (random = 2) { death2(); }
|
||||
if (random = 3) { death3(); }
|
||||
}
|
||||
|
||||
function death1() {
|
||||
|
|
@ -127,4 +134,234 @@ function timeDeath() { // The death screen for passing the time limit
|
|||
console.log("Please return to the nearest active Enclave Military Installation immeditely\n\n");
|
||||
console.log("Signed, Enclave Internal Messager");
|
||||
console.clear;
|
||||
}
|
||||
|
||||
var travelFrame = 0;
|
||||
|
||||
|
||||
|
||||
export function travelScreen() {
|
||||
if (travelFrame < 0 || travelFrame > 3) {
|
||||
travelFrame = 0;
|
||||
} else if (travelFrame == 0) {
|
||||
console.clear();
|
||||
console.log("┌──────────────────────────────────────┐");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ ◜─◝ │");
|
||||
console.log("│ ◟_◞ │");
|
||||
console.log("│ /║\\ │");
|
||||
console.log("│ \\V/ │");
|
||||
console.log("│ / \\ │");
|
||||
console.log("│ ▁\\ ▔╹ │");
|
||||
console.log("│======================================│");
|
||||
console.log("│ . . - . . - . . . - │");
|
||||
console.log("│ - . . . . . . - . .│");
|
||||
console.log("└──────────────────────────────────────┘");
|
||||
console.log("Press [ENTER] to open Pip-Boy");
|
||||
console.log("Current Health: "+health);
|
||||
console.log("Food Amt: "+food);
|
||||
console.log("Distance to next POI: ");
|
||||
travelFrame++
|
||||
} else if (travelFrame == 1) {
|
||||
console.clear();
|
||||
console.log("┌──────────────────────────────────────┐");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ ◜─◝ │");
|
||||
console.log("│ ◟_◞ │");
|
||||
console.log("│ /║\\ │");
|
||||
console.log("│ \\V/ │");
|
||||
console.log("│ \\ │");
|
||||
console.log("│ ▁│▔╹ │");
|
||||
console.log("│======================================│");
|
||||
console.log("│ - . - . . . - . - . │");
|
||||
console.log("│ - . . - . . . - .│");
|
||||
console.log("└──────────────────────────────────────┘");
|
||||
console.log("Press [ENTER] to open Pip-Boy");
|
||||
console.log("Current Health: "+health);
|
||||
console.log("Food Amt: "+food);
|
||||
console.log("Distance to next POI: ");
|
||||
travelFrame++
|
||||
} else if (travelFrame == 2) {
|
||||
console.clear();
|
||||
console.log("┌──────────────────────────────────────┐");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ ◜─◝ │");
|
||||
console.log("│ ◟_◞ │");
|
||||
console.log("│ /║\\ │");
|
||||
console.log("│ \\V/ │");
|
||||
console.log("│ ╳ │");
|
||||
console.log("│ _/_\\ │");
|
||||
console.log("│======================================│");
|
||||
console.log("│ - . - . . . - . - . │");
|
||||
console.log("│ - . . - . . . - .│");
|
||||
console.log("└──────────────────────────────────────┘");
|
||||
console.log("Press [ENTER] to open Pip-Boy");
|
||||
console.log("Current Health: "+health);
|
||||
console.log("Food Amt: "+food);
|
||||
console.log("Distance to next POI: ");
|
||||
travelFrame++
|
||||
} else if (travelFrame == 3) {
|
||||
console.clear();
|
||||
console.log("┌──────────────────────────────────────┐");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ │");
|
||||
console.log("│ ◜─◝ │");
|
||||
console.log("│ ◟_◞ │");
|
||||
console.log("│ /║\\ │");
|
||||
console.log("│ \\V/ │");
|
||||
console.log("│ \\ │");
|
||||
console.log("│ ▁│▔╹ │");
|
||||
console.log("│======================================│");
|
||||
console.log("│ - . - . . . - . - . │");
|
||||
console.log("│ - . . - . . . - .│");
|
||||
console.log("└──────────────────────────────────────┘");
|
||||
console.log("Press [ENTER] to open Pip-Boy");
|
||||
console.log("Current Health: "+health);
|
||||
console.log("Food Amt: "+food);
|
||||
console.log("Distance to next POI: ");
|
||||
travelFrame=0;
|
||||
}
|
||||
}
|
||||
|
||||
export async function walkPathA() {
|
||||
enableRawMode();
|
||||
if (paused) {
|
||||
disableRawMode();
|
||||
pauseScreen();
|
||||
enableRawMode();
|
||||
}
|
||||
|
||||
if (location > 255) {
|
||||
disableRawMode();
|
||||
return;
|
||||
}
|
||||
calcLocation();
|
||||
radPointsCalc();
|
||||
healthCapCalc();
|
||||
checkLose();
|
||||
travelScreen();
|
||||
checkPOI();
|
||||
eatFood();
|
||||
//await sleep(0.5);
|
||||
walkPathA();
|
||||
}
|
||||
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', (key) => {
|
||||
if (key.toString() === ' ') {
|
||||
paused = true; // Pause the game
|
||||
} else if (key.toString() === '\u0003') { // Handle Ctrl+C (ASCII code for Ctrl+C)
|
||||
console.log("\nExiting game...");
|
||||
process.exit(); // Exit the program
|
||||
}
|
||||
});
|
||||
|
||||
export function enableRawMode() {
|
||||
if (!isRawModeEnabled) {
|
||||
process.stdin.setRawMode(true);
|
||||
process.stdin.resume();
|
||||
isRawModeEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function disableRawMode() {
|
||||
if (isRawModeEnabled) {
|
||||
process.stdin.setRawMode(false);
|
||||
process.stdin.pause();
|
||||
isRawModeEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
var paused = false;
|
||||
export function pauseScreen() {
|
||||
console.clear();
|
||||
console.log ("What would you like to do?");
|
||||
console.log ("--------------------------");
|
||||
console.log ("1) Resume");
|
||||
console.log ("2) View Inventory");
|
||||
console.log ("3) View Distances");
|
||||
console.log ("4) View Stats");
|
||||
console.log ("5) Scavenge");
|
||||
let pauseInput = userInput("Enter: ");
|
||||
switch(pauseInput) {
|
||||
case "1":
|
||||
paused = false;
|
||||
break;
|
||||
case "2":
|
||||
inventoryMenuM();
|
||||
break;
|
||||
case "3":
|
||||
console.clear();
|
||||
console.log("Current Location: "+location);
|
||||
if (path == 0) {
|
||||
console.log("Current Path: Main");
|
||||
}
|
||||
if (path == 1) {
|
||||
console.log("Current Path: A (Southern)");
|
||||
}
|
||||
if (path == 2) {
|
||||
console.log("Current Path: B (Northern)");
|
||||
}
|
||||
console.log("------------------------");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (pois[i].visited == true) {
|
||||
console.log(pois[i].name+" - "+visited[i]);
|
||||
}
|
||||
if (pois[i].visited == false) {
|
||||
console.log("??? "+pois[i].location-location+" location points away");
|
||||
}
|
||||
}
|
||||
if (path == 1) {
|
||||
for (let i = poiCounter; i < 14; i++) {
|
||||
if (pois[i].visited == true) {
|
||||
console.log(pois[i].name+" - "+visited[i]);
|
||||
}
|
||||
if (pois[i].visited == false) {
|
||||
console.log("??? "+pois[i].location-location+" location points away");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (path == 2) {
|
||||
for (let i = poiCounter; i < pois.length; i++) {
|
||||
if (pois[i].visited == true) {
|
||||
console.log(pois[i].name+" - "+visited[i]);
|
||||
}
|
||||
if (pois[i].visited == false) {
|
||||
console.log("??? "+pois[i].location-location+" location points away");
|
||||
}
|
||||
}
|
||||
}
|
||||
userInput("\n[Press Enter to return]");
|
||||
break;
|
||||
case "4":
|
||||
console.clear();
|
||||
console.log("Player Stats");
|
||||
console.log("-------------");
|
||||
console.log("Name: "+name);
|
||||
console.log("Level: "+level);
|
||||
console.log("Current Health: "+health+"/"+healthCap);
|
||||
console.log("Radiation Points: "+radPoints);
|
||||
console.log("Radiation Severity: "+radSeverity);
|
||||
console.log("Walk Rate: "+walkRate);
|
||||
console.log("Food Amt: "+food);
|
||||
console.log("Food Rate: "+foodRate);
|
||||
console.log("Current Location: "+location);
|
||||
console.log("Current Path: "+path);
|
||||
userInput("\n[Press Enter to return]");
|
||||
break;
|
||||
case "5":
|
||||
scavenge();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue