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

View File

@ -156,6 +156,10 @@ class BaseUnit : INamed, IConstruction {
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 =(
//movement penalty
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 }
@ -166,10 +170,6 @@ class BaseUnit : INamed, IConstruction {
&& 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)
//movement penalty
if(!unit.hasUnique("Can move directly once bought") && wasBought)
unit.currentMovement = 0f
return true
}