Created
January 22, 2012 11:35
-
-
Save arturaz/1656657 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -23,25 +23,27 @@ package models.healing | |
public var cooldown: int = 0; | |
public static function calculateRepairPrice(building: Building): HealPrice | |
{ | |
var priceMod : Number = tech.repairPriceMod; | |
var cooldownMod: Number = tech.repairCooldownMod; | |
- price.metal = Math.round(Upgradable.calculateCost(UpgradableType.BUILDINGS, | |
- building.type, ResourceType.METAL, {'level': building.level}) | |
- * priceMod * building.damagePercentage); | |
- price.energy = Math.round(Upgradable.calculateCost(UpgradableType.BUILDINGS, | |
- building.type, ResourceType.ENERGY, {'level': building.level}) | |
- * priceMod * building.damagePercentage); | |
- price.zetium = Math.round(Upgradable.calculateCost(UpgradableType.BUILDINGS, | |
- building.type, ResourceType.ZETIUM, {'level': building.level}) | |
- * priceMod * building.damagePercentage); | |
- price.cooldown = Math.round((building.hpMax - building.hp) * cooldownMod); | |
- price.cooldown = Math.max(1, price.cooldown); | |
+ | |
+ var calcRes: Function = function(resource: String) { | |
+ return Math.round(Upgradable.calculateCost( | |
+ UpgradableType.BUILDINGS, building.type, resource, {'level': 1} | |
+ ) * priceMod * building.damagePercentage); | |
+ } | |
+ price.metal = calcRes(ResourceType.METAL); | |
+ price.energy = calcRes(ResourceType.ENERGY); | |
+ price.zetium = calcRes(ResourceType.ZETIUM); | |
+ | |
+ price.cooldown = Math.max( | |
+ 1, Math.round((building.hpMax - building.hp) * cooldownMod) | |
+ ); | |
return price; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment