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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
import { userInput } from "./functions.js";
|
||||
import { inventory, userInput } from "./variables.js";
|
||||
import "./variables.js";
|
||||
|
||||
//Builds the main menu inventory
|
||||
function inventoryMenuM(){
|
||||
export function inventoryMenuM(){
|
||||
console.clear();
|
||||
console.log("INVENTORY");
|
||||
console.log("---------");
|
||||
console.log("1) Supplies");
|
||||
console.log("2) Equipment");
|
||||
console.log("[spacebar to exit]");
|
||||
console.log("3) Exit");
|
||||
let invChoice = userInput("Enter: ");
|
||||
switch(userInput){
|
||||
case "1":
|
||||
|
|
@ -17,6 +17,8 @@ function inventoryMenuM(){
|
|||
case "2":
|
||||
equipmentInventory();
|
||||
break;
|
||||
case "3":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { name, prewarmoney, variableChange } from './variables.js';
|
|||
import { forcedEncounter, naturalEncounter } from './encounters.js';
|
||||
|
||||
|
||||
disableRawMode();
|
||||
console.clear();
|
||||
console.log("__________________________________________________________________________________________________________________________________");
|
||||
console.log(" _____ _ ____ ");
|
||||
|
|
@ -66,12 +67,19 @@ function startGame() { // So far what I have is filler and testing, feel free to
|
|||
userInput("[Enter to open shop]");
|
||||
console.clear();
|
||||
|
||||
prewarmoney = 500;
|
||||
ravenRockShop();
|
||||
for (variables.location = 0; variables.location <= 255; variables.location++) {
|
||||
calcLocation();
|
||||
radPointsCalc();
|
||||
healthCapCalc
|
||||
checkLose();
|
||||
}
|
||||
}
|
||||
preWarMoney = 500;
|
||||
caps = 0;
|
||||
level = 1;
|
||||
health = 100;
|
||||
healthCap = 100;
|
||||
walkRate = 1;
|
||||
foodRate = 1;
|
||||
food = 0;
|
||||
radPoints = 0;
|
||||
path = 0;
|
||||
location = 0;
|
||||
locationA = 0;
|
||||
locationB = 0;
|
||||
ravenRockStore();
|
||||
walkPathA(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Holds poi code, seperate from encounters.js
|
||||
|
||||
import { userInput } from "./functions.js";
|
||||
import { userInput, pauseScreen } from "./functions.js";
|
||||
import './variables.js';
|
||||
|
||||
export function checkPOI() {
|
||||
|
|
@ -119,7 +119,27 @@ global.pois = [
|
|||
]
|
||||
|
||||
function whitespring() {
|
||||
|
||||
console.clear();
|
||||
console.log("You have arrived at the Whitespring Bunker.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Explore");
|
||||
console.log("2) Attempt to trade");
|
||||
console.log("3) Open your PIP-Boy");
|
||||
console.log("4) Leave");
|
||||
let whitespringInput = userInput("Enter: ");
|
||||
switch(whitespringInput) {
|
||||
case "1":
|
||||
console.clear();
|
||||
console.log("A robotic voice greets you.");
|
||||
console.log("MODUS Dialogue here...")
|
||||
break;
|
||||
case "2":
|
||||
whitespringStore();
|
||||
case "3":
|
||||
pauseScreen();
|
||||
case "4":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function bosGamma() {
|
||||
|
|
|
|||
245
files/shops.js
245
files/shops.js
|
|
@ -1,31 +1,203 @@
|
|||
import { randomNumber } from "./functions.js";
|
||||
import {} from "./variables.js";
|
||||
import { randomNumber, userInput } from "./functions.js";
|
||||
import "./variables.js";
|
||||
|
||||
|
||||
// Inventories for the various shops
|
||||
var rrInv = [];
|
||||
// Inventories for the various shops, based of global item lists
|
||||
// Most item prices in Raven Rock and Eureka are multiplied by 10, as they are using pre-war money
|
||||
var rrInv = [
|
||||
{item: supplyList[0], name: supplyList[0].name, price: supplyList[0].cost, amount: 1000},
|
||||
{item: supplyList[1], name: supplyList[1].name, price: supplyList[1].cost*10, amount: 100},
|
||||
{item: supplyList[2], name: supplyList[2].name, price: supplyList[2].cost*10, amount: 100},
|
||||
{item: supplyList[3], name: supplyList[3].name, price: supplyList[3].cost*10, amount: 100},
|
||||
{item: equipmentList[0], name: equipmentList[0].name, price: equipmentList[0].cost*10, amount: 10},
|
||||
{item: equipmentList[2], name: equipmentList[2].name, price: equipmentList[1].cost*10, amount: 10},
|
||||
{item: equipmentList[8], name: equipmentList[8].name, price: equipmentList[2].cost*10, amount: 10},
|
||||
];
|
||||
var vt0Inv = [];
|
||||
var vegasInv = []; // A mix of gunrunners, mick&ralphs, and followers
|
||||
var eurInv = [];
|
||||
var traderInv = ["gun", "stimpak", "radx"];
|
||||
var traderInv = [];
|
||||
|
||||
function ravenRock() {
|
||||
// purchasing code
|
||||
export function ravenRockStore() {
|
||||
while (true) {
|
||||
console.clear();
|
||||
console.log("Welcome to Raven Rock. Requisition supplies before heading out.");
|
||||
console.log("Name | Price (PW Money) | Amount in stock");
|
||||
console.log("-----------------------------------------------------");
|
||||
for (var i = 0; i < rrInv.length; i++) {
|
||||
console.log(i+"). " + rrInv[i].name + " | " + rrInv[i].price + " | " + rrInv[i].amount);
|
||||
}
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("You have " + preWarMoney + " pre-war money.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Buy supplies");
|
||||
console.log("2) Leave shop");
|
||||
var rrInput = userInput("Enter: ");
|
||||
switch(rrInput) {
|
||||
case "1":
|
||||
console.log("What would you like to buy?");
|
||||
let itemNum = userInput("Enter item number: ");
|
||||
let itemAmt = userInput("Enter amount: ");
|
||||
if (itemAmt > rrInv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
userInput("[Enter]");
|
||||
break;
|
||||
} else if (itemAmt * rrInv[itemNum].price > preWarMoney) {
|
||||
console.log("Not enough money.");
|
||||
userInput("[Enter]");
|
||||
break;
|
||||
} else {
|
||||
preWarMoney -= itemAmt * rrInv[itemNum].price;
|
||||
rrInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + rrInv[itemNum].name + "(s).");
|
||||
console.log("You have " + preWarMoney + " pre-war money left.");
|
||||
console.log("Press enter to continue...");
|
||||
userInput("[Enter]");
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
console.log("Leaving shop...");
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid input, try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function vaultZero() {
|
||||
// purchasing code
|
||||
function vaultZeroStore() {
|
||||
while (true) {
|
||||
console.clear();
|
||||
console.log("Brotherhood of Steel Requisition System - Vault 0");
|
||||
console.log("Name | Price (Caps) | Amount in stock");
|
||||
console.log("-----------------------------------------------------");
|
||||
for (var i = 0; i < vt0InvInv.length; i++) {
|
||||
console.log(i+"). " + vt0InvInv[i].item + " | " + vtInv[i].price + " | " + vtInv[i].amount);
|
||||
}
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("You have " + caps + " caps.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Buy supplies");
|
||||
console.log("2) Leave shop");
|
||||
var vt0Input = userInput("Enter: ");
|
||||
switch(vt0Input) {
|
||||
case "1":
|
||||
console.log("What would you like to buy?");
|
||||
let itemNum = userInput("Enter item number: ");
|
||||
let itemAmt = userInput("Enter amount: ");
|
||||
if (itemAmt > vt0Inv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
break;
|
||||
} else if (itemAmt * vt0Inv[itemNum].price > caps) {
|
||||
console.log("Not enough money.");
|
||||
break;
|
||||
} else {
|
||||
caps -= itemAmt * vt0Inv[itemNum].price;
|
||||
rrInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + vt0Inv[itemNum].item + "(s).");
|
||||
console.log("You have " + caps + " caps left.");
|
||||
console.log("Press enter to continue...");
|
||||
userInput("[Enter]");
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
console.log("Leaving shop...");
|
||||
return true;
|
||||
default:
|
||||
console.log("Invalid input, try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function newVegas() {
|
||||
// purchasing code
|
||||
function newVegasStore() {
|
||||
while (true) {
|
||||
console.clear();
|
||||
console.log("Welcome to New Vegas. Selection pulls from Gunrunners, Mick & Ralph's, and Followers of the Apocalypse.");
|
||||
console.log("Name | Price (Caps) | Amount in stock");
|
||||
console.log("-----------------------------------------------------");
|
||||
for (var i = 0; i < vegasInv.length; i++) {
|
||||
console.log(i+"). " + vegasInv[i].item + " | " + vegasInv[i].price + " | " + vegasInv[i].amount);
|
||||
}
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("You have " + caps + " caps.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Buy supplies");
|
||||
console.log("2) Leave shop");
|
||||
var nvInput = userInput("Enter: ");
|
||||
switch(nvInput) {
|
||||
case "1":
|
||||
console.log("What would you like to buy?");
|
||||
let itemNum = userInput("Enter item number: ");
|
||||
let itemAmt = userInput("Enter amount: ");
|
||||
if (itemAmt > vegasInv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
break;
|
||||
} else if (itemAmt * vegasInv[itemNum].price > preWarMoney) {
|
||||
console.log("Not enough money.");
|
||||
break;
|
||||
} else {
|
||||
preWarMoney -= itemAmt * vegasInv[itemNum].price;
|
||||
vegasInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + vegasInv[itemNum].item + "(s).");
|
||||
console.log("You have " + caps + " caps left.");
|
||||
console.log("Press enter to continue...");
|
||||
userInput("[Enter]");
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
console.log("Leaving shop...");
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid input, try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function eureka() {
|
||||
// purchasing code
|
||||
function eurekaStore() {
|
||||
while (true) {
|
||||
console.clear();
|
||||
console.log("Welcome to Eureka. Selection pulls from local traders and willing Enclave Veterans.");
|
||||
console.log("Name | Price (PW Money) | Amount in stock");
|
||||
console.log("-----------------------------------------------------");
|
||||
for (var i = 0; i < eurInv.length; i++) {
|
||||
console.log(i+"). " + eurInv[i].item + " | " + eurInv[i].price + " | " + eurInv[i].amount);
|
||||
}
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("You have " + preWarMoney + " pre-war money.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Buy supplies");
|
||||
console.log("2) Leave shop");
|
||||
var eurInput = userInput("Enter: ");
|
||||
switch(eurInput) {
|
||||
case "1":
|
||||
console.log("What would you like to buy?");
|
||||
let itemNum = userInput("Enter item number: ");
|
||||
let itemAmt = userInput("Enter amount: ");
|
||||
if (itemAmt > eurInv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
break;
|
||||
} else if (itemAmt * eurInv[itemNum].price > preWarMoney) {
|
||||
console.log("Not enough money.");
|
||||
break;
|
||||
} else {
|
||||
preWarMoney -= itemAmt * eurInv[itemNum].price;
|
||||
eurInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + eurInv[itemNum].item + "(s).");
|
||||
console.log("You have " + preWarMoney + " pre-war money left.");
|
||||
console.log("Press enter to continue...");
|
||||
userInput("[Enter]");
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
console.log("Leaving shop...");
|
||||
return true;
|
||||
default:
|
||||
console.log("Invalid input, try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function trader() { // Picks a selection of items from a global trader inventory
|
||||
function trader() { // Picks a selection of items from a global trader inventory, used for misc area shops
|
||||
var tempTraderInv = [];
|
||||
for (var a = 0; a <= 2; a++) {
|
||||
let randomPick = randomNumber()
|
||||
|
|
@ -33,4 +205,47 @@ function trader() { // Picks a selection of items from a global trader inventory
|
|||
console.log(randomPick);
|
||||
}
|
||||
console.log(tempTraderInv);
|
||||
|
||||
while (true) {
|
||||
console.clear();
|
||||
console.log("You attempt to trade with a local trader, this is thier selection.");
|
||||
console.log("Name | Price (Caps) | Amount in stock");
|
||||
console.log("-----------------------------------------------------");
|
||||
for (var i = 0; i < Inv.length; i++) {
|
||||
console.log(i+"). " + rrInv[i].item + " | " + rrInv[i].price + " | " + rrInv[i].amount);
|
||||
}
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("You have " + preWarMoney + " pre-war money.");
|
||||
console.log("What would you like to do?");
|
||||
console.log("1) Buy supplies");
|
||||
console.log("2) Leave shop");
|
||||
var rrInput = userInput("Enter: ");
|
||||
switch(rrInput) {
|
||||
case "1":
|
||||
console.log("What would you like to buy?");
|
||||
let itemNum = userInput("Enter item number: ");
|
||||
let itemAmt = userInput("Enter amount: ");
|
||||
if (itemAmt > rrInv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
break;
|
||||
} else if (itemAmt * rrInv[itemNum].price > preWarMoney) {
|
||||
console.log("Not enough money.");
|
||||
break;
|
||||
} else {
|
||||
preWarMoney -= itemAmt * rrInv[itemNum].price;
|
||||
rrInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + rrInv[itemNum].item + "(s).");
|
||||
console.log("You have " + preWarMoney + " pre-war money left.");
|
||||
console.log("Press enter to continue...");
|
||||
userInput("[Enter]");
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
console.log("Leaving shop...");
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid input, try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Now holds only variables
|
||||
|
||||
// Player Currency
|
||||
global.prewarmoney = 0; // Used with enclave vendors
|
||||
global.preWarMoney = 0; // Used with enclave vendors
|
||||
global.caps = 0; // Used with all other vendors
|
||||
|
||||
// Player Stats
|
||||
|
|
@ -36,12 +36,32 @@ global.daysSinceScav = 0; // Days since player last scavenged. Must be >= 15 to
|
|||
|
||||
global.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
|
||||
}
|
||||
}
|
||||
global.supplyList = [ // Supplies: chems, aid
|
||||
{name: "Food", description: "Misc foods", cost: 1, weight: 0},
|
||||
{name: "Stimpak", description: "A Stimpak syringe, heals 25 HP", cost: 5, weight: 0.5},
|
||||
{name: "RadAway", description: "A pack of RadAway, removes 20 rad-points", cost: 5, weight: 0.5},
|
||||
{name: "RadX", description: "A bottle of RadX, removes 1 rad-severity", cost: 5, weight: 0.5},
|
||||
{name: "Med-x", description: "A vial of Med-X, reduces damage by 15% for 1 fight", cost: 10, weight: 0.5},
|
||||
{name: "Psycho", description: "A vial of Psycho, boosts damage by 15% for 1 fight", cost: 10, weight: 0.5}
|
||||
];
|
||||
global.equipmentList = [ // Equipment: weapons, armor, tools
|
||||
// Type: The type of item it is, weapon, armor, or tool
|
||||
// Value: The value of the item, used for damage, dr, or dt
|
||||
// Unit: The unit of the item, slash, bash, balistic, laser, plasma, damage resistance or damage threshold (PA only)
|
||||
{name: "Combat Knife", description: "A combat knife, does 5 slash damage", type: "weapon", value: "5", unit: "slash", cost: 5, weight: 1},
|
||||
{name: "Baseball Bat", description: "A baseball bat, does 5 bash damage", type: "weapon", value: "5", unit: "bash", cost: 5, weight: 2},
|
||||
{name: "10mm Pistol", description: "A 10mm pistol, does 10 balistic damage", type: "weapon", value: "10", unit: "balistic",cost: 10, weight: 2},
|
||||
{name: "Hunting Rifle", description: "A hunting rifle, does 15 balistic damage", type: "weapon", value: "15", unit: "balistic",cost: 15, weight: 3},
|
||||
{name: "Laser Pistol", description: "A laser pistol, does 20 laser damage", type: "weapon", value: "20", unit: "laser",cost: 20, weight: 4},
|
||||
{name: "Laser Rifle", description: "A laser rifle, does 25 laser damage", type: "weapon", value: "25", unit: "laser",cost: 25, weight: 5},
|
||||
{name: "Plasma Pistol", description: "A plasma pistol, does 30 plasma damage", type: "weapon", value: "30", unit: "plasma",cost: 30, weight: 6},
|
||||
{name: "Plasma Rifle", description: "A plasma rifle, does 35 plasma damage", type: "weapon", value: "35", unit: "plasma",cost: 35, weight: 7},
|
||||
{name: "Leather Armor", description: "A set of leather armor, slightly used", type: "armor", value: "5", unit: "dr",cost: 5, weight: 5},
|
||||
{name: "Metal Armor", description: "A set of metal armor, dented in many places", type: "armor", value: "5", unit: "dr",cost: 10, weight: 10},
|
||||
{name: "Combat Armor", description: "A set of combat armor, in good condition", type: "armor", value: "5", unit: "dr",cost: 15, weight: 15},
|
||||
{name: "Recon Under Armor", description: "A set of recon armor, for use in Power Armor", type: "uarmor", value: "5", unit: "dr",cost: 20, weight: 20},
|
||||
{name: "Centurion Armor", description: "A set of Centurion armor, made for you", type: "armor", value: "5", unit: "dr",cost: 25, weight: 25},
|
||||
{name: "NCR Ranger Armor" , description: "A set of NCR Ranger armor, standard issue", type: "armor", value: "5", unit: "dr",cost: 30, weight: 30},
|
||||
{name: "Advanced Power Armor Mark II", description: "A set of APA MkII, branded with Enclave Logos", type: "parmor", value: "5", unit: "dt",cost: 25, weight: 25},
|
||||
{name: "T-51 Power Armor", description: "A set of T-51 Power Armor, a parting gift from the BOS", type: "parmor", value: "5", unit: "dt",cost: 30, weight: 30}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue