Finished Achievements. Needs implimentation.

This commit is contained in:
Raktbastr 2025-04-23 23:30:29 -05:00
parent 324679c4a6
commit 22975aff26
6 changed files with 762 additions and 116 deletions

View file

@ -8,11 +8,12 @@ const execPromise = promisify(exec);
import './variables.js';
import { inventoryMenuM } from './inventory.js';
import { checkPOI } from './poiscreens.js';
import './poiscreens.js';
import os from 'os';
import { exit } from 'process';
global.isRawModeEnabled = false; // Track whether raw mode is enabled
// Used for basic functions, not game specific
export function userInput(question) { // Basic user input functions, takes in the question to be asked.
let answer = readlineSync.question(question);
@ -49,43 +50,58 @@ export function eatFood() { // Calculates food amount after a day of eating
}
export function checkLose() { // Checks to see if any lose conditions have been met
if (health <= 0 || radPoints >= 100) {
death();
if (health <= 0 && food <= 0) {
death("Starvation");
}
if (radPoints >= 100) {
death("Radiation Poisoning");
}
if (health <= 0 && incombat == true) {
death("Combat Injury");
}
if (health <= 0) {
death("Injury");
}
if (day >= 365) {
timeDeath();
}
if (testDeath == true) {
death("Test Death");
}
}
export function calcLocation() {
if (walkRate == 1) {
if (path = 0) {
if (path == 0) {
location++;
}
if (path = 1) {
if (path == 1) {
locationA++;
}
if (path = 2) {
if (path == 2) {
locationB++;
}
}
if (walkRate == 2) {
if (path = 0) {
if (path == 0) {
location * 2;
}
if (path = 1) {
if (path == 1) {
locationA * 2;
}
if (path = 2) {
if (path == 2) {
locationB * 2;
}
}
if (walkRate == 3) {
if (path = 0) {
if (path == 0) {
location * 3;
}
if (path = 1) {
if (path == 1) {
locationA * 3;
}
if (path = 2) {
if (path == 2) {
locationB * 3;
}
}
@ -108,23 +124,64 @@ export async function sleep(time) {
}
}
function death() {
let random = randomNumber(1,3);
if (random = 1) { death1(); }
if (random = 2) { death2(); }
if (random = 3) { death3(); }
function death(deathCause) {
let random = randomNumber(1,100);
if (random >= 1 && random <= 33) { death1(deathCause); }
if (random >= 34 && random <= 66) { death2(deathCause); }
if (random >= 67 && random <= 99) { death3(deathCause); }
if (random == 100) { death4(deathCause); }
}
function death1() {
console.log("")
function death1(dc) {
console.clear();
sleep(2);
console.log("Your bones wither away in the wasteland...\n\n");
console.log(" \\|/");
console.log(" _/\\___<0> | ");
console.log("-------------------------------\n\n");
console.log("You have died of "+dc+"...");
console.log("Thanks for playing!\n\n");
sleep(5);
exit(0);
}
function death2() {
function death2(dc) {
console.clear();
sleep(2);
console.log("The Enclave suffers in the wake of your defeat...\n\n");
console.log(" \\|/");
console.log(" _/\\___<0> | ");
console.log("-------------------------------\n\n");
console.log("You have died of "+dc+"...");
console.log("Thanks for playing!\n\n");
sleep(5);
exit(0);
}
function death3() {
function death3(dc) {
console.clear();
sleep(2);
console.log("Not even the radscorpions are interested in your corpse...\n\n");
console.log(" \\|/");
console.log(" _/\\___<0> | ");
console.log("-------------------------------\n\n");
console.log("You have died of "+dc+"...");
console.log("Thanks for playing!\n\n");
sleep(5);
exit(0);
}
function death4(dc) {
console.clear();
sleep(2);
console.log("You have been killed, therefore you are DEAD...\n\n");
console.log(" \\|/");
console.log(" _/\\___<0> | ");
console.log("-------------------------------\n\n");
console.log("You have died of "+dc+"...");
console.log("Thanks for playing!\n\n");
sleep(5);
exit(0);
}
function timeDeath() { // The death screen for passing the time limit
@ -243,7 +300,7 @@ export function travelScreen() {
}
}
export async function walkPathA() {
export async function walkPathMain() {
enableRawMode();
if (paused) {
disableRawMode();
@ -262,8 +319,9 @@ export async function walkPathA() {
travelScreen();
checkPOI();
eatFood();
//await sleep(0.5);
walkPathA();
day++
await sleep(0.5);
walkPathMain();
}
process.stdin.resume();
@ -302,6 +360,7 @@ export function pauseScreen() {
console.log ("3) View Distances");
console.log ("4) View Stats");
console.log ("5) Scavenge");
console.log ("6) Test Death");
let pauseInput = userInput("Enter: ");
switch(pauseInput) {
case "1":
@ -328,7 +387,7 @@ export function pauseScreen() {
console.log(pois[i].name+" - "+visited[i]);
}
if (pois[i].visited == false) {
console.log("??? "+pois[i].location-location+" location points away");
console.log("??? - "+pois[i].location-location+" location points away");
}
}
if (path == 1) {
@ -372,5 +431,8 @@ export function pauseScreen() {
case "5":
scavenge();
break;
case "6":
testDeath = true;
break;
}
}