Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion src/thrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -43,6 +44,8 @@ thriveApp.controller('ThriveCtrl', [
return currentPrice;
}

=======
>>>>>>> Stashed changes
var maxLots = 30;

// initialize scoped variables
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());

Expand Down