Civilian should not move when bought (#2621)

* Civilian cannot move when bought same as military unit

* Minor code restyling
This commit is contained in:
Jack Rainy 2020-05-16 21:57:36 +03:00 committed by GitHub
parent 4026c9b91d
commit 8877c18f31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,22 +154,22 @@ class BaseUnit : INamed, IConstruction {
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean): Boolean {
val unit = construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
if(unit==null) return false // couldn't place the unit, so there's actually no unit =(
if(this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
var XP = construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
if(construction.cityInfo.civInfo.policies.isAdopted("Total War")) XP += 15
unit.promotions.XP = XP
if(unit.type in listOf(UnitType.Melee,UnitType.Mounted,UnitType.Armor)
&& construction.cityInfo.containsBuildingUnique("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"))
unit.promotions.addPromotion("Drill I", isFree = true)
if (unit == null) return false // couldn't place the unit, so there's actually no unit =(
//movement penalty
if(!unit.hasUnique("Can move directly once bought") && wasBought)
if (wasBought && !unit.hasUnique("Can move directly once bought"))
unit.currentMovement = 0f
if (this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
var XP = construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
if (construction.cityInfo.civInfo.policies.isAdopted("Total War")) XP += 15
unit.promotions.XP = XP
if (unit.type in listOf(UnitType.Melee,UnitType.Mounted,UnitType.Armor)
&& construction.cityInfo.containsBuildingUnique("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"))
unit.promotions.addPromotion("Drill I", isFree = true)
return true
}