From e0a97a9c74beaa3d9484f40bc0db5c911a7d085e Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Fri, 22 Nov 2013 20:47:44 +0800 Subject: [PATCH 1/6] Added cost and resale multipliers to fix issue #117 I've added more multipliers (2, 4, 8, 16) that increase the cost of an item depending on the amount (10, 100, 1000, 10000) owned. I've added the same multipliers to the resale function to maintain the games balance. This addition should help balance the game economy during late game-play, the multipliers chosen are fairly arbitrary. --- templates/game.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/templates/game.js b/templates/game.js index 05fbd4d..8d0c810 100644 --- a/templates/game.js +++ b/templates/game.js @@ -1982,10 +1982,17 @@ function Game() { this.dump_pd = function(key) { console.log(pd[key]); } + function get_item_cost(scl) { var cst = ((scl.amount + 1) * scl.base_cost) * (scl.amount + 1); - // Double costs if > 10 are owned - if((scl.amount + 1) > 10) { + // Increase the cost by a multiplier that is dependent on amount + if((scl.amount + 1) > 10000) { + cst *= 16; + } else if((sc1.amount +1) > 1000){ + cst *= 8; + } else if((sc1.amount + 1) > 100){ + cst *= 4; + } else if ((sc1.amount + 1) > 10){ cst *= 2; } return cst; @@ -1993,15 +2000,33 @@ function Game() { function get_item_last_cost(scl) { var cst = ((scl.amount) * scl.base_cost) * (scl.amount); - // Double costs if > 10 are owned - if(scl.amount > 10) { + // Increase the cost by a multiplier that is dependent on amount + if((scl.amount + 1) > 10000) { + cst *= 16; + } else if((sc1.amount +1) > 1000){ + cst *= 8; + } else if((sc1.amount + 1) > 100){ + cst *= 4; + } else if ((sc1.amount + 1) > 10){ cst *= 2; } return cst; } + function get_item_sell_value(scl) { - return get_item_last_cost(scl) * (pd.sell_return * pd.economy_roi); + var value = get_item_last_cost(scl) * (pd.sell_return * pd.economy_roi); + // Increase the resale value by a multiplier that is dependent on amount + if((scl.amount > 10000) { + value *= 16; + } else if(sc1.amount > 1000){ + value *= 8; + } else if(sc1.amount > 100){ + value *= 4; + } else if (sc1.amount > 10){ + value *= 2; + } + return value; } function get_safe_cash() { From 8e0a11b784180de0ff93829e000c385e086a0b15 Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Fri, 22 Nov 2013 20:56:00 +0800 Subject: [PATCH 2/6] get_item_last_cost multipliers were determined with incorrect logic Previous commit contained logic errors for determining the last item cost. --- templates/game.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/game.js b/templates/game.js index 8d0c810..e9e09f6 100644 --- a/templates/game.js +++ b/templates/game.js @@ -2001,13 +2001,13 @@ function Game() { function get_item_last_cost(scl) { var cst = ((scl.amount) * scl.base_cost) * (scl.amount); // Increase the cost by a multiplier that is dependent on amount - if((scl.amount + 1) > 10000) { + if(scl.amount > 10000) { cst *= 16; - } else if((sc1.amount +1) > 1000){ + } else if(sc1.amount > 1000){ cst *= 8; - } else if((sc1.amount + 1) > 100){ + } else if(sc1.amount > 100){ cst *= 4; - } else if ((sc1.amount + 1) > 10){ + } else if ((sc1.amount > 10){ cst *= 2; } return cst; From 2eb34d86d9c92538124f960d5aeeaea5cf0196b6 Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Fri, 22 Nov 2013 20:59:39 +0800 Subject: [PATCH 3/6] Removed bonus brackets Left 2 brackets that should have been deleted in my last commit, just deleted them. --- templates/game.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/game.js b/templates/game.js index e9e09f6..406ad6d 100644 --- a/templates/game.js +++ b/templates/game.js @@ -2007,7 +2007,7 @@ function Game() { cst *= 8; } else if(sc1.amount > 100){ cst *= 4; - } else if ((sc1.amount > 10){ + } else if (sc1.amount > 10){ cst *= 2; } return cst; @@ -2017,7 +2017,7 @@ function Game() { function get_item_sell_value(scl) { var value = get_item_last_cost(scl) * (pd.sell_return * pd.economy_roi); // Increase the resale value by a multiplier that is dependent on amount - if((scl.amount > 10000) { + if(scl.amount > 10000) { value *= 16; } else if(sc1.amount > 1000){ value *= 8; From b3b96f4750bf375489b36a7716a91e372889f6da Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Sat, 23 Nov 2013 01:39:46 +0800 Subject: [PATCH 4/6] Inserted a new formula for calculating item costs New formula gradually increases the price increment, where as the previous formula decreased the increment. Users will be able to buy more early on, but will find it increasingly difficult to buy new items as they progress. --- templates/game.js | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/templates/game.js b/templates/game.js index 406ad6d..f7e93c3 100644 --- a/templates/game.js +++ b/templates/game.js @@ -1983,49 +1983,24 @@ function Game() { console.log(pd[key]); } + function get_item_cost(scl) { - var cst = ((scl.amount + 1) * scl.base_cost) * (scl.amount + 1); - // Increase the cost by a multiplier that is dependent on amount - if((scl.amount + 1) > 10000) { - cst *= 16; - } else if((sc1.amount +1) > 1000){ - cst *= 8; - } else if((sc1.amount + 1) > 100){ - cst *= 4; - } else if ((sc1.amount + 1) > 10){ - cst *= 2; - } + //cost = [base_cost^(1 + ((amount + 1) * 0.0075)^2)] * (amount + 1) + var exponent = 1 + Math.pow((sc1.amount + 1) * 0.0075, 2); + var cst = Math.pow(sc1.base_cost, exponent) * (sc1.amount + 1); return cst; } function get_item_last_cost(scl) { - var cst = ((scl.amount) * scl.base_cost) * (scl.amount); - // Increase the cost by a multiplier that is dependent on amount - if(scl.amount > 10000) { - cst *= 16; - } else if(sc1.amount > 1000){ - cst *= 8; - } else if(sc1.amount > 100){ - cst *= 4; - } else if (sc1.amount > 10){ - cst *= 2; - } + //cost = [base_cost^(1 + (amount * 0.0075)^2] * amount + var exponent = 1 + Math.pow(sc1.amount * 0.0075, 2); + var cst = Math.pow(sc1.base_cost, exponent) * sc1.amount; return cst; } function get_item_sell_value(scl) { var value = get_item_last_cost(scl) * (pd.sell_return * pd.economy_roi); - // Increase the resale value by a multiplier that is dependent on amount - if(scl.amount > 10000) { - value *= 16; - } else if(sc1.amount > 1000){ - value *= 8; - } else if(sc1.amount > 100){ - value *= 4; - } else if (sc1.amount > 10){ - value *= 2; - } return value; } From 0b3bcd0da48c14e2f9fecf02bcdfd5460181a8d7 Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Fri, 29 Nov 2013 21:57:03 +0800 Subject: [PATCH 5/6] Added code to ensure items always have a sell cost < infinity The largest possible number in Javascript is about 1.797e+308, this is the constant Number.MAX_VALUE, anything beyond this is simply identified as infinite. The inserted code checks if get_item_last_cost equals infinity, and if it does, it changes the cst value to Number.MAX_VALUE. This will hopefully help avoid a lot of butthurt from the new formula being introduced. --- templates/game.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/game.js b/templates/game.js index f7e93c3..7102b57 100644 --- a/templates/game.js +++ b/templates/game.js @@ -1995,6 +1995,10 @@ function Game() { //cost = [base_cost^(1 + (amount * 0.0075)^2] * amount var exponent = 1 + Math.pow(sc1.amount * 0.0075, 2); var cst = Math.pow(sc1.base_cost, exponent) * sc1.amount; + //To ensure an item always has a sell cost. + if(cst > Number.MAX_VALUE){ + cst = Number.MAX_VALUE + } return cst; } From 05d418ab8e8f787a638a415901e32e69fe7c3ccc Mon Sep 17 00:00:00 2001 From: jwalt333 Date: Sat, 30 Nov 2013 09:25:54 +0800 Subject: [PATCH 6/6] Inserted a forgotten semi-colon --- templates/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/game.js b/templates/game.js index 7102b57..3effd01 100644 --- a/templates/game.js +++ b/templates/game.js @@ -1997,7 +1997,7 @@ function Game() { var cst = Math.pow(sc1.base_cost, exponent) * sc1.amount; //To ensure an item always has a sell cost. if(cst > Number.MAX_VALUE){ - cst = Number.MAX_VALUE + cst = Number.MAX_VALUE; } return cst; }