Changed "Combat Unit" to Military Unit" for naming consistency

This commit is contained in:
Yair Morgenstern 2019-03-23 22:04:50 +02:00
parent a751ed6e31
commit bba6f43943
3 changed files with 12 additions and 12 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app" applicationId "com.unciv.app"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 28 targetSdkVersion 28
versionCode 218 versionCode 219
versionName "2.14.0" versionName "2.14.1"
} }
// Had to add this crap for Travis to build, it wanted to sign the app // Had to add this crap for Travis to build, it wanted to sign the app

View File

@ -45,21 +45,21 @@ class Automation {
return rank return rank
} }
fun trainCombatUnit(city: CityInfo) { fun trainMilitaryUnit(city: CityInfo) {
val name = chooseCombatUnit(city) val name = chooseMilitaryUnit(city)
city.cityConstructions.currentConstruction = name city.cityConstructions.currentConstruction = name
} }
fun chooseCombatUnit(city: CityInfo) : String { fun chooseMilitaryUnit(city: CityInfo) : String {
val combatUnits = city.cityConstructions.getConstructableUnits().filter { !it.unitType.isCivilian() } val militaryUnits = city.cityConstructions.getConstructableUnits().filter { !it.unitType.isCivilian() }
val chosenUnit: BaseUnit val chosenUnit: BaseUnit
if(!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit==null} if(!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit==null}
&& combatUnits.any { it.unitType== UnitType.Ranged }) // this is for city defence so get an archery unit if we can && militaryUnits.any { it.unitType== UnitType.Ranged }) // this is for city defence so get an archery unit if we can
chosenUnit = combatUnits.filter { it.unitType== UnitType.Ranged }.maxBy { it.cost }!! chosenUnit = militaryUnits.filter { it.unitType== UnitType.Ranged }.maxBy { it.cost }!!
else{ // randomize type of unit and take the most expensive of its kind else{ // randomize type of unit and take the most expensive of its kind
val chosenUnitType = combatUnits.map { it.unitType }.distinct().filterNot{it==UnitType.Scout}.getRandom() val chosenUnitType = militaryUnits.map { it.unitType }.distinct().filterNot{it==UnitType.Scout}.getRandom()
chosenUnit = combatUnits.filter { it.unitType==chosenUnitType }.maxBy { it.cost }!! chosenUnit = militaryUnits.filter { it.unitType==chosenUnitType }.maxBy { it.cost }!!
} }
return chosenUnit.name return chosenUnit.name
} }
@ -162,7 +162,7 @@ class Automation {
} }
//Army //Army
val militaryUnit = chooseCombatUnit(cityInfo) val militaryUnit = chooseMilitaryUnit(cityInfo)
val unitsToCitiesRatio = militaryUnits / cities.toFloat() val unitsToCitiesRatio = militaryUnits / cities.toFloat()
// most buildings and civ units contribute the the civ's growth, military units are anti-growth // most buildings and civ units contribute the the civ's growth, military units are anti-growth
val militaryChoice = ConstructionChoice(militaryUnit,unitsToCitiesRatio/5) val militaryChoice = ConstructionChoice(militaryUnit,unitsToCitiesRatio/5)

View File

@ -242,7 +242,7 @@ class NextTurnAutomation{
Automation().chooseNextConstruction(city.cityConstructions) Automation().chooseNextConstruction(city.cityConstructions)
if (city.health < city.getMaxHealth()) if (city.health < city.getMaxHealth())
Automation().trainCombatUnit(city) // override previous decision if city is under attack Automation().trainMilitaryUnit(city) // override previous decision if city is under attack
} }
} }