Merge pull request #443 from ninjatao/free_promotions

Allow to add real free promotions to unit.
This commit is contained in:
Yair Morgenstern 2019-01-29 17:49:12 +02:00 committed by GitHub
commit 24d2a2c320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -15,10 +15,12 @@ class UnitPromotions{
fun xpForNextPromotion() = (numberOfPromotions+1)*10 fun xpForNextPromotion() = (numberOfPromotions+1)*10
fun canBePromoted() = XP >= xpForNextPromotion() fun canBePromoted() = XP >= xpForNextPromotion()
fun addPromotion(promotionName:String){ fun addPromotion(promotionName:String, isFree:Boolean = false){
XP -= xpForNextPromotion() if (!isFree) {
XP -= xpForNextPromotion()
numberOfPromotions++
}
promotions.add(promotionName) promotions.add(promotionName)
numberOfPromotions++
unit.updateUniques() unit.updateUniques()
unit.civInfo.updateViewableTiles() // some promotions give the unit bonus sight unit.civInfo.updateViewableTiles() // some promotions give the unit bonus sight
} }

View File

@ -125,7 +125,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
if(unit.type in listOf(UnitType.Melee,UnitType.Mounted,UnitType.Armor) if(unit.type in listOf(UnitType.Melee,UnitType.Mounted,UnitType.Armor)
&& construction.cityInfo.getBuildingUniques() && construction.cityInfo.getBuildingUniques()
.contains("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion")) .contains("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"))
unit.promotions.addPromotion("Drill I") unit.promotions.addPromotion("Drill I", isFree = true)
} }
fun getUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{ fun getUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{