When unable to support units, they disband one by one instead of all at the same time

This commit is contained in:
Yair Morgenstern 2018-07-15 19:51:27 +03:00
parent 68781ed5f7
commit da3d749547
2 changed files with 4 additions and 5 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game" applicationId "com.unciv.game"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 26 targetSdkVersion 26
versionCode 99 versionCode 101
versionName "2.6.2" versionName "2.6.3.1"
} }
buildTypes { buildTypes {
release { release {

View File

@ -190,11 +190,10 @@ class CivilizationInfo {
policies.endTurn(nextTurnStats.culture.toInt()) policies.endTurn(nextTurnStats.culture.toInt())
// disband units until there are none left OR the gold values are normal
if(!isBarbarianCivilization() && gold < -100){ if(!isBarbarianCivilization() && gold < -100){
// disband units until there are none left OR the gold values are normal
val unitUpkeepBeforeDisbands = getUnitUpkeep()
var civMilitaryUnits = getCivUnits().filter { it.getBaseUnit().unitType!=UnitType.Civilian } var civMilitaryUnits = getCivUnits().filter { it.getBaseUnit().unitType!=UnitType.Civilian }
while(nextTurnStats.gold.toInt() - unitUpkeepBeforeDisbands + getUnitUpkeep() < 0 if(nextTurnStats.gold.toInt() < 0
&& civMilitaryUnits.isNotEmpty()){ && civMilitaryUnits.isNotEmpty()){
val unitToDisband = civMilitaryUnits.first() val unitToDisband = civMilitaryUnits.first()
unitToDisband.removeFromTile() unitToDisband.removeFromTile()