My comments.
This commit is contained in:
parent
77cb3f4613
commit
a8c9d868be
6 changed files with 147 additions and 84 deletions
|
|
@ -131,6 +131,17 @@ var lostHillsInv = [
|
|||
{item: equipmentList[12], name: equipmentList[12].name, price: equipmentList[12].cost, amount: 10},
|
||||
];
|
||||
|
||||
// Store functions
|
||||
// Each store gets its own inventory and function, and work exactly the same for the most part.
|
||||
// It opens by giving a welcome screen and listing the items in stock, player is given choice to leave or buy items.
|
||||
// If they chose to buy, player enters the item number, amount they want, and it is then pushed to thier inventory array
|
||||
// If the item is food, the item is added to the food variable, not the inventory.
|
||||
|
||||
// Exceptions to how this works:
|
||||
|
||||
// ravenRockStore() and eurekaStore() both use Pre-War Money, multiplying the
|
||||
// prices by 10 and using the players PWM to purchase the item, not caps.
|
||||
|
||||
export function ravenRockStore() {
|
||||
while (true) {
|
||||
console.clear();
|
||||
|
|
@ -151,19 +162,23 @@ export function ravenRockStore() {
|
|||
console.log("What would you like to buy?");
|
||||
var itemNum = userInput("Enter item number: ");
|
||||
var itemAmt = userInput("Enter amount: ");
|
||||
// Making sure the item has enough in stock
|
||||
if (itemAmt > rrInv[itemNum].amount) {
|
||||
console.log("Not enough stock.");
|
||||
userInput("[Enter]");
|
||||
break;
|
||||
// Making sure the items requested are not too expensive
|
||||
} else if (itemAmt * rrInv[itemNum].price*10 > preWarMoney) {
|
||||
console.log("Not enough money.");
|
||||
userInput("[Enter]");
|
||||
break;
|
||||
// If the choice is vaild, add the item to inventory and remove stock/money
|
||||
} else {
|
||||
preWarMoney -= itemAmt * rrInv[itemNum].price*10;
|
||||
rrInv[itemNum].amount -= itemAmt;
|
||||
console.log("You bought " + itemAmt + " " + rrInv[itemNum].name + "(s).");
|
||||
console.log("You have " + preWarMoney + " pre-war money left.");
|
||||
// Check if the item is food, if so add to food variable
|
||||
if (rrInv[itemNum].name == "Food") {
|
||||
food =+ itemAmt;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue