Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var backpackStatus = {};
- backpackStatus.price = 100;
- backpackStatus.multiplier = 1.1
- var statStatus = {};
- statStatus.price = 500;
- statStatus.muliplier = 1.01;
- function buyStuff(type, count) {
- var priceTemp = type.price;
- var priceToPay = 0;
- for(i=0; i < count; i++) {
- priceToPay += priceTemp;
- priceTemp = Math.round(priceTemp * type.multiplier);
- }
- if (player.gold >= priceToPay) {
- type.price = priceTemp;
- player.gold -= priceToPay;
- return true;
- }
- Log("You do not have enough money to buy this. You need " + priceTemp + " gold.")
- return false;
- }
- function buyBackpack(count) {
- if(buyStuff(backpackStatus, count) {
- player.backpackUpgrade += count;
- document.getElementById("backpack").innerHTML = backpackStatus.price;
- CreateInventoryWeaponHtml();
- Log("You max inventory slots upgraded by " + count + ", now you have: " + player.inventory() + " inventory slots");
- }
- }
- function buyStat(count) {
- if(buyStuff(statStatus, count) {
- player.stats += count;
- document.getElementById("buyStat").innerHTML = statStatus.price;
- Log("Your stat points increased by " + count + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment