diff --git a/src/index.jade b/src/index.jade index 493a771..115277a 100644 --- a/src/index.jade +++ b/src/index.jade @@ -41,7 +41,9 @@ html ng-repeat='structure in HF.structures', ng-click="build(structure)", ng-show='isUnlocked(structure.name)' - ) #[i(class="fa {{structure.icon}}")] {{structure.text}} + ) + | #[i(class="fa {{structure.icon}}")] {{structure.text}} + span(ng-repeat='price in getStructurePrice(structure) | limitTo: 2') .col-sm-6 h4 Workers ul diff --git a/src/thrive.js b/src/thrive.js index 09d3044..88c13c3 100644 --- a/src/thrive.js +++ b/src/thrive.js @@ -25,6 +25,7 @@ thriveApp.controller('ThriveCtrl', [ }) || null; // returns an object with parameters of 'resource' and 'quantity' (or null) } +<<<<<<< Updated upstream function getStructurePrice(structure) { var baseStructure = _.findWhere(HF.structures, {name: structure.name}); var currentPrice = _.cloneDeep(baseStructure.cost); @@ -43,6 +44,8 @@ thriveApp.controller('ThriveCtrl', [ return currentPrice; } +======= +>>>>>>> Stashed changes var maxLots = 30; // initialize scoped variables @@ -118,7 +121,7 @@ thriveApp.controller('ThriveCtrl', [ var available = true; var purchase = []; - _.forEach(getStructurePrice(structure), function eachCostItem(costItem) { + _.forEach($s.getStructurePrice(structure), function eachCostItem(costItem) { var supplyResource = getSupplyPaletteByResource(costItem); if (supplyResource && supplyResource.quantity >= costItem.amount) { @@ -153,6 +156,23 @@ thriveApp.controller('ThriveCtrl', [ } }; + $s.getStructurePrice = function getStructurePrice(structure) { + var baseStructure = _.findWhere(HF.structures, {name: structure.name}); + var currentPrice = _.cloneDeep(baseStructure.cost); + + var existingLot = getLotByStructure(structure); + if (existingLot) { + _.forEach(existingLot.structure.cost, function eachCostItem(costItem) { + // TODO: refactor this with reduce + for (var i = 0; i < existingLot.quantity; i++) { + var currentPriceResource = _.findWhere(currentPrice, {name: costItem.name}); + currentPriceResource.amount = Math.round(currentPriceResource.amount * (1 + baseStructure.priceIncrease)); + } + }); + } + return currentPrice; + }; + $s.nextMessage = function nextMessage() { $s.messagelog.push($s.messages.shift());