mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 20:59:18 +07:00
Dev: added "type" property to MapUnit to reflect baseUnit.unitType, since that's used EVERYWHERE
This commit is contained in:
@ -54,7 +54,7 @@ class Automation {
|
|||||||
val buildableWonders = getBuildableBuildings().filter { it.isWonder }
|
val buildableWonders = getBuildableBuildings().filter { it.isWonder }
|
||||||
|
|
||||||
val civUnits = cityInfo.civInfo.getCivUnits()
|
val civUnits = cityInfo.civInfo.getCivUnits()
|
||||||
val militaryUnits = civUnits.filter { !it.baseUnit().unitType.isCivilian()}.size
|
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.size
|
||||||
val workers = civUnits.filter { it.name == CityConstructions.Worker }.size
|
val workers = civUnits.filter { it.name == CityConstructions.Worker }.size
|
||||||
val cities = cityInfo.civInfo.cities.size
|
val cities = cityInfo.civInfo.cities.size
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class NextTurnAutomation(){
|
|||||||
private fun declareWar(civInfo: CivilizationInfo) {
|
private fun declareWar(civInfo: CivilizationInfo) {
|
||||||
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()
|
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()
|
||||||
&& !civInfo.isAtWar()
|
&& !civInfo.isAtWar()
|
||||||
&& civInfo.getCivUnits().filter { !it.baseUnit.unitType.isCivilian() }.size > civInfo.cities.size * 2) {
|
&& civInfo.getCivUnits().filter { !it.type.isCivilian() }.size > civInfo.cities.size * 2) {
|
||||||
|
|
||||||
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
|
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
|
||||||
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
|
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
|
||||||
@ -101,7 +101,7 @@ class NextTurnAutomation(){
|
|||||||
unit.promotions.addPromotion(availablePromotions.getRandom().name)
|
unit.promotions.addPromotion(availablePromotions.getRandom().name)
|
||||||
}
|
}
|
||||||
|
|
||||||
val unitType = unit.baseUnit().unitType
|
val unitType = unit.type
|
||||||
if (unitType.isRanged()) rangedUnits.add(unit)
|
if (unitType.isRanged()) rangedUnits.add(unit)
|
||||||
else if (unitType.isMelee()) meleeUnits.add(unit)
|
else if (unitType.isMelee()) meleeUnits.add(unit)
|
||||||
else civilianUnits.add(unit)
|
else civilianUnits.add(unit)
|
||||||
|
@ -127,7 +127,7 @@ class UnitAutomation{
|
|||||||
|
|
||||||
fun containsAttackableEnemy(tile: TileInfo, unit: MapUnit): Boolean {
|
fun containsAttackableEnemy(tile: TileInfo, unit: MapUnit): Boolean {
|
||||||
if(unit.isEmbarked()){
|
if(unit.isEmbarked()){
|
||||||
if(unit.baseUnit.unitType.isRanged()) return false
|
if(unit.type.isRanged()) return false
|
||||||
if(tile.isWater()) return false // can't attack water units while embarked, only land
|
if(tile.isWater()) return false // can't attack water units while embarked, only land
|
||||||
}
|
}
|
||||||
val tileCombatant = Battle(unit.civInfo.gameInfo).getMapCombatantOfTile(tile)
|
val tileCombatant = Battle(unit.civInfo.gameInfo).getMapCombatantOfTile(tile)
|
||||||
@ -167,7 +167,7 @@ class UnitAutomation{
|
|||||||
// this can be sped up if we check each layer separately
|
// this can be sped up if we check each layer separately
|
||||||
var closeEnemies = unit.getTile().getTilesInDistance(5)
|
var closeEnemies = unit.getTile().getTilesInDistance(5)
|
||||||
.filter{ containsAttackableEnemy(it, unit) && unit.movementAlgs().canReach(it)}
|
.filter{ containsAttackableEnemy(it, unit) && unit.movementAlgs().canReach(it)}
|
||||||
if(unit.baseUnit().unitType.isRanged())
|
if(unit.type.isRanged())
|
||||||
closeEnemies = closeEnemies.filterNot { it.isCityCenter() && it.getCity()!!.health==1 }
|
closeEnemies = closeEnemies.filterNot { it.isCityCenter() && it.getCity()!!.health==1 }
|
||||||
|
|
||||||
val closestEnemy = closeEnemies.minBy { it.arialDistanceTo(unit.getTile()) }
|
val closestEnemy = closeEnemies.minBy { it.arialDistanceTo(unit.getTile()) }
|
||||||
@ -213,7 +213,7 @@ class UnitAutomation{
|
|||||||
.filter { it.location in unit.civInfo.exploredTiles }
|
.filter { it.location in unit.civInfo.exploredTiles }
|
||||||
.map { it.getCenterTile() }.toList()
|
.map { it.getCenterTile() }.toList()
|
||||||
|
|
||||||
if(unit.baseUnit().unitType.isRanged()) // ranged units don't harm capturable cities, waste of a turn
|
if(unit.type.isRanged()) // ranged units don't harm capturable cities, waste of a turn
|
||||||
enemyCities = enemyCities.filterNot { it.getCity()!!.health==1 }
|
enemyCities = enemyCities.filterNot { it.getCity()!!.health==1 }
|
||||||
|
|
||||||
val closestReachableEnemyCity = enemyCities
|
val closestReachableEnemyCity = enemyCities
|
||||||
@ -245,7 +245,7 @@ class UnitAutomation{
|
|||||||
val cityWithHealthLeft = cityTilesToAttack.filter { it.tileToAttack.getCity()!!.health != 1 } // don't want ranged units to attack defeated cities
|
val cityWithHealthLeft = cityTilesToAttack.filter { it.tileToAttack.getCity()!!.health != 1 } // don't want ranged units to attack defeated cities
|
||||||
.minBy { it.tileToAttack.getCity()!!.health }
|
.minBy { it.tileToAttack.getCity()!!.health }
|
||||||
|
|
||||||
if (unit.baseUnit().unitType.isMelee() && capturableCity!=null)
|
if (unit.type.isMelee() && capturableCity!=null)
|
||||||
enemyTileToAttack = capturableCity // enter it quickly, top priority!
|
enemyTileToAttack = capturableCity // enter it quickly, top priority!
|
||||||
|
|
||||||
else if (nonCityTilesToAttack.isNotEmpty()) // second priority, units
|
else if (nonCityTilesToAttack.isNotEmpty()) // second priority, units
|
||||||
@ -266,7 +266,7 @@ class UnitAutomation{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tryGarrisoningUnit(unit: MapUnit): Boolean {
|
private fun tryGarrisoningUnit(unit: MapUnit): Boolean {
|
||||||
if(unit.baseUnit().unitType.isMelee()) return false // don't garrison melee units, they're not that good at it
|
if(unit.type.isMelee()) return false // don't garrison melee units, they're not that good at it
|
||||||
val reachableCitiesWithoutUnits = unit.civInfo.cities.filter {
|
val reachableCitiesWithoutUnits = unit.civInfo.cities.filter {
|
||||||
val centerTile = it.getCenterTile()
|
val centerTile = it.getCenterTile()
|
||||||
centerTile.militaryUnit==null
|
centerTile.militaryUnit==null
|
||||||
|
@ -45,7 +45,7 @@ class BattleDamage{
|
|||||||
|
|
||||||
if(combatant.getCivilization().policies.isAdopted("Discipline") && combatant.isMelee()
|
if(combatant.getCivilization().policies.isAdopted("Discipline") && combatant.isMelee()
|
||||||
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
||||||
.any { it.civInfo==combatant.getCivilization() && !it.baseUnit.unitType.isCivilian()})
|
.any { it.civInfo==combatant.getCivilization() && !it.type.isCivilian()})
|
||||||
modifiers["Discipline"] = 0.15f
|
modifiers["Discipline"] = 0.15f
|
||||||
|
|
||||||
val requiredResource = combatant.unit.baseUnit.requiredResource
|
val requiredResource = combatant.unit.baseUnit.requiredResource
|
||||||
|
@ -28,7 +28,7 @@ class MapUnitCombatant(val unit: MapUnit) : ICombatant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getUnitType(): UnitType {
|
override fun getUnitType(): UnitType {
|
||||||
return unit.baseUnit().unitType
|
return unit.type
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
@ -283,7 +283,7 @@ class CivilizationInfo {
|
|||||||
// disband units until there are none left OR the gold values are normal
|
// disband units until there are none left OR the gold values are normal
|
||||||
if(!isBarbarianCivilization() && gold < -100 && nextTurnStats.gold.toInt() < 0) {
|
if(!isBarbarianCivilization() && gold < -100 && nextTurnStats.gold.toInt() < 0) {
|
||||||
for (i in 1 until (gold / -100)) {
|
for (i in 1 until (gold / -100)) {
|
||||||
var civMilitaryUnits = getCivUnits().filter { !it.baseUnit().unitType.isCivilian() }
|
var civMilitaryUnits = getCivUnits().filter { !it.type.isCivilian() }
|
||||||
if (civMilitaryUnits.isNotEmpty()) {
|
if (civMilitaryUnits.isNotEmpty()) {
|
||||||
val unitToDisband = civMilitaryUnits.first()
|
val unitToDisband = civMilitaryUnits.first()
|
||||||
unitToDisband.destroy()
|
unitToDisband.destroy()
|
||||||
|
@ -7,6 +7,7 @@ import com.unciv.logic.automation.WorkerAutomation
|
|||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||||
|
import com.unciv.models.gamebasics.unit.UnitType
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -38,6 +39,9 @@ class MapUnit {
|
|||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val type:UnitType
|
||||||
|
get()=baseUnit.unitType
|
||||||
|
|
||||||
fun baseUnit(): BaseUnit = baseUnit
|
fun baseUnit(): BaseUnit = baseUnit
|
||||||
fun getMovementString(): String = DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + getMaxMovement()
|
fun getMovementString(): String = DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + getMaxMovement()
|
||||||
fun getTile(): TileInfo = currentTile
|
fun getTile(): TileInfo = currentTile
|
||||||
@ -47,7 +51,7 @@ class MapUnit {
|
|||||||
var movement = baseUnit.movement
|
var movement = baseUnit.movement
|
||||||
movement += getUniques().count{it=="+1 Movement"}
|
movement += getUniques().count{it=="+1 Movement"}
|
||||||
|
|
||||||
if(baseUnit.unitType.isWaterUnit() && !baseUnit.unitType.isCivilian()
|
if(type.isWaterUnit() && !type.isCivilian()
|
||||||
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
|
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
|
||||||
movement += 1
|
movement += 1
|
||||||
|
|
||||||
@ -83,7 +87,7 @@ class MapUnit {
|
|||||||
if(hasUnique("Limited Visibility")) visibilityRange-=1
|
if(hasUnique("Limited Visibility")) visibilityRange-=1
|
||||||
if(civInfo.getNation().unique=="All land military units have +1 sight, 50% discount when purchasing tiles")
|
if(civInfo.getNation().unique=="All land military units have +1 sight, 50% discount when purchasing tiles")
|
||||||
visibilityRange += 1
|
visibilityRange += 1
|
||||||
if(baseUnit.unitType.isWaterUnit() && !baseUnit.unitType.isCivilian()
|
if(type.isWaterUnit() && !type.isCivilian()
|
||||||
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
|
&& civInfo.getBuildingUniques().contains("All military naval units receive +1 movement and +1 sight"))
|
||||||
visibilityRange += 1
|
visibilityRange += 1
|
||||||
val tile = getTile()
|
val tile = getTile()
|
||||||
@ -108,14 +112,14 @@ class MapUnit {
|
|||||||
|
|
||||||
fun canPassThrough(tile: TileInfo):Boolean{
|
fun canPassThrough(tile: TileInfo):Boolean{
|
||||||
val tileOwner = tile.getOwner()
|
val tileOwner = tile.getOwner()
|
||||||
if(tile.isWater() && baseUnit.unitType.isLandUnit()){
|
if(tile.isWater() && type.isLandUnit()){
|
||||||
val techUniques = civInfo.tech.getUniques()
|
val techUniques = civInfo.tech.getUniques()
|
||||||
if(!techUniques.contains("Enables embarkation for land units"))
|
if(!techUniques.contains("Enables embarkation for land units"))
|
||||||
return false
|
return false
|
||||||
if(tile.baseTerrain == "Ocean" && !techUniques.contains("Enables embarked units to enter ocean tiles"))
|
if(tile.baseTerrain == "Ocean" && !techUniques.contains("Enables embarked units to enter ocean tiles"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(tile.isLand() && baseUnit.unitType.isWaterUnit())
|
if(tile.isLand() && type.isWaterUnit())
|
||||||
return false
|
return false
|
||||||
if(tile.baseTerrain=="Ocean" && baseUnit.uniques.contains("Cannot enter ocean tiles until Astronomy")
|
if(tile.baseTerrain=="Ocean" && baseUnit.uniques.contains("Cannot enter ocean tiles until Astronomy")
|
||||||
&& !civInfo.tech.isResearched("Astronomy"))
|
&& !civInfo.tech.isResearched("Astronomy"))
|
||||||
@ -132,7 +136,7 @@ class MapUnit {
|
|||||||
fun canMoveTo(tile: TileInfo): Boolean {
|
fun canMoveTo(tile: TileInfo): Boolean {
|
||||||
if(!canPassThrough(tile)) return false
|
if(!canPassThrough(tile)) return false
|
||||||
|
|
||||||
if (baseUnit().unitType.isCivilian())
|
if (type.isCivilian())
|
||||||
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
||||||
else return tile.militaryUnit==null && (tile.civilianUnit==null || tile.civilianUnit!!.owner==owner)
|
else return tile.militaryUnit==null && (tile.civilianUnit==null || tile.civilianUnit!!.owner==owner)
|
||||||
}
|
}
|
||||||
@ -154,7 +158,7 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getRange(): Int {
|
fun getRange(): Int {
|
||||||
if(baseUnit().unitType.isMelee()) return 1
|
if(type.isMelee()) return 1
|
||||||
var range = baseUnit().range
|
var range = baseUnit().range
|
||||||
if(hasUnique("+1 Range")) range++
|
if(hasUnique("+1 Range")) range++
|
||||||
return range
|
return range
|
||||||
@ -162,7 +166,7 @@ class MapUnit {
|
|||||||
|
|
||||||
|
|
||||||
fun isEmbarked(): Boolean {
|
fun isEmbarked(): Boolean {
|
||||||
if(!baseUnit.unitType.isLandUnit()) return false
|
if(!type.isLandUnit()) return false
|
||||||
return currentTile.baseTerrain=="Ocean"||currentTile.baseTerrain=="Coast"
|
return currentTile.baseTerrain=="Ocean"||currentTile.baseTerrain=="Coast"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,13 +302,13 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun removeFromTile(){
|
fun removeFromTile(){
|
||||||
if (baseUnit().unitType.isCivilian()) getTile().civilianUnit=null
|
if (type.isCivilian()) getTile().civilianUnit=null
|
||||||
else getTile().militaryUnit=null
|
else getTile().militaryUnit=null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun putInTile(tile:TileInfo){
|
fun putInTile(tile:TileInfo){
|
||||||
if(!canMoveTo(tile)) throw Exception("I can't go there!")
|
if(!canMoveTo(tile)) throw Exception("I can't go there!")
|
||||||
if(baseUnit().unitType.isCivilian())
|
if(type.isCivilian())
|
||||||
tile.civilianUnit=this
|
tile.civilianUnit=this
|
||||||
else tile.militaryUnit=this
|
else tile.militaryUnit=this
|
||||||
currentTile = tile
|
currentTile = tile
|
||||||
@ -336,7 +340,7 @@ class MapUnit {
|
|||||||
civInfo.addNotification("A [$chosenUnit] has joined us!",null, Color.BLUE)
|
civInfo.addNotification("A [$chosenUnit] has joined us!",null, Color.BLUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!baseUnit.unitType.isCivilian())
|
if(!type.isCivilian())
|
||||||
actions.add {
|
actions.add {
|
||||||
promotions.XP+=10
|
promotions.XP+=10
|
||||||
civInfo.addNotification("An ancient tribe trains our [$name] in their ways of combat!",null, Color.RED)
|
civInfo.addNotification("An ancient tribe trains our [$name] in their ways of combat!",null, Color.RED)
|
||||||
|
@ -24,7 +24,7 @@ class UnitPromotions{
|
|||||||
|
|
||||||
fun getAvailablePromotions(): List<Promotion> {
|
fun getAvailablePromotions(): List<Promotion> {
|
||||||
return GameBasics.UnitPromotions.values
|
return GameBasics.UnitPromotions.values
|
||||||
.filter { unit.baseUnit().unitType.toString() in it.unitTypes && it.name !in promotions }
|
.filter { unit.type.toString() in it.unitTypes && it.name !in promotions }
|
||||||
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() {
|
|||||||
|
|
||||||
val availablePromotionsGroup = VerticalGroup()
|
val availablePromotionsGroup = VerticalGroup()
|
||||||
availablePromotionsGroup.space(10f)
|
availablePromotionsGroup.space(10f)
|
||||||
val unitType = mapUnit.baseUnit().unitType
|
val unitType = mapUnit.type
|
||||||
val promotionsForUnitType = GameBasics.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
|
val promotionsForUnitType = GameBasics.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
|
||||||
val unitAvailablePromotions = mapUnit.promotions.getAvailablePromotions()
|
val unitAvailablePromotions = mapUnit.promotions.getAvailablePromotions()
|
||||||
for (promotion in promotionsForUnitType) {
|
for (promotion in promotionsForUnitType) {
|
||||||
|
@ -24,7 +24,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
val whiteHalo = if(unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")
|
val whiteHalo = if(unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")
|
||||||
else ImageGetter.getImage("OtherIcons/Circle.png")
|
else ImageGetter.getImage("OtherIcons/Circle.png")
|
||||||
whiteHalo.setSize(30f,30f)
|
whiteHalo.setSize(30f,30f)
|
||||||
val unitImage = if(unit.baseUnit().unitType.isCivilian()) civilianUnitImage
|
val unitImage = if(unit.type.isCivilian()) civilianUnitImage
|
||||||
else militaryUnitImage
|
else militaryUnitImage
|
||||||
if(unitImage==null) //Stuff has changed since we requested this, the unit is no longer here...
|
if(unitImage==null) //Stuff has changed since we requested this, the unit is no longer here...
|
||||||
return
|
return
|
||||||
|
@ -153,7 +153,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
if(unit.canMoveTo(tile))
|
if(unit.canMoveTo(tile))
|
||||||
tileGroups[tile]!!.showCircle(colorFromRGB(0, 120, 215))
|
tileGroups[tile]!!.showCircle(colorFromRGB(0, 120, 215))
|
||||||
|
|
||||||
val unitType = unit.baseUnit().unitType
|
val unitType = unit.type
|
||||||
val attackableTiles: List<TileInfo> = when{
|
val attackableTiles: List<TileInfo> = when{
|
||||||
unitType.isCivilian() -> unit.getDistanceToTiles().keys.toList()
|
unitType.isCivilian() -> unit.getDistanceToTiles().keys.toList()
|
||||||
else -> UnitAutomation().getAttackableEnemies(unit, unit.getDistanceToTiles()).map { it.tileToAttack }
|
else -> UnitAutomation().getAttackableEnemies(unit, unit.getDistanceToTiles()).map { it.tileToAttack }
|
||||||
@ -164,14 +164,14 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
it.getUnits().isNotEmpty()
|
it.getUnits().isNotEmpty()
|
||||||
&& it.getUnits().first().owner != unit.owner
|
&& it.getUnits().first().owner != unit.owner
|
||||||
&& (playerViewableTilePositions.contains(it.position) || UnCivGame.Current.viewEntireMapForDebug)}) {
|
&& (playerViewableTilePositions.contains(it.position) || UnCivGame.Current.viewEntireMapForDebug)}) {
|
||||||
if(unit.baseUnit().unitType.isCivilian()) tileGroups[tile]!!.hideCircle()
|
if(unit.type.isCivilian()) tileGroups[tile]!!.hideCircle()
|
||||||
else {
|
else {
|
||||||
tileGroups[tile]!!.showCircle(colorFromRGB(237, 41, 57))
|
tileGroups[tile]!!.showCircle(colorFromRGB(237, 41, 57))
|
||||||
tileGroups[tile]!!.showCrosshair()
|
tileGroups[tile]!!.showCrosshair()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val fadeout = if(unit.baseUnit.unitType.isCivilian()) 1f
|
val fadeout = if(unit.type.isCivilian()) 1f
|
||||||
else 0.5f
|
else 0.5f
|
||||||
|
|
||||||
for(tile in tileGroups.values){
|
for(tile in tileGroups.values){
|
||||||
|
@ -280,7 +280,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
displayTutorials("EnemyCity")
|
displayTutorials("EnemyCity")
|
||||||
if("Enables construction of Spaceship parts" in civInfo.getBuildingUniques())
|
if("Enables construction of Spaceship parts" in civInfo.getBuildingUniques())
|
||||||
displayTutorials("ApolloProgram")
|
displayTutorials("ApolloProgram")
|
||||||
if(civInfo.getCivUnits().any { it.baseUnit.unitType == UnitType.Siege })
|
if(civInfo.getCivUnits().any { it.type == UnitType.Siege })
|
||||||
displayTutorials("SiegeUnitTrained")
|
displayTutorials("SiegeUnitTrained")
|
||||||
if(civInfo.tech.getUniques().contains("Enables embarkation for land units"))
|
if(civInfo.tech.getUniques().contains("Enables embarkation for land units"))
|
||||||
displayTutorials("CanEmbark")
|
displayTutorials("CanEmbark")
|
||||||
|
@ -31,7 +31,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
fun update() {
|
fun update() {
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomBar.unitTable
|
||||||
if (unitTable.selectedUnit == null
|
if (unitTable.selectedUnit == null
|
||||||
|| unitTable.selectedUnit!!.baseUnit().unitType.isCivilian()){
|
|| unitTable.selectedUnit!!.type.isCivilian()){
|
||||||
hide()
|
hide()
|
||||||
return
|
return
|
||||||
} // no attacker
|
} // no attacker
|
||||||
|
@ -41,7 +41,7 @@ class UnitActions {
|
|||||||
},true)
|
},true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!unit.baseUnit().unitType.isCivilian() && !unit.isEmbarked() && !unit.baseUnit.unitType.isWaterUnit()
|
if(!unit.type.isCivilian() && !unit.isEmbarked() && !unit.type.isWaterUnit()
|
||||||
&& !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified()) {
|
&& !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified()) {
|
||||||
actionList += UnitAction("Fortify", { unit.action = "Fortify 0" }, unit.currentMovement != 0f)
|
actionList += UnitAction("Fortify", { unit.action = "Fortify 0" }, unit.currentMovement != 0f)
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ class UnitActions {
|
|||||||
actionList += UnitAction("Sleep", { unit.action = "Sleep" }, unit.currentMovement != 0f)
|
actionList += UnitAction("Sleep", { unit.action = "Sleep" }, unit.currentMovement != 0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.baseUnit.unitType == UnitType.Scout){
|
if(unit.type == UnitType.Scout){
|
||||||
if(unit.action != "explore")
|
if(unit.action != "explore")
|
||||||
actionList += UnitAction("Explore", { UnitAutomation().automatedExplore(unit); unit.action = "explore" },
|
actionList += UnitAction("Explore", { UnitAutomation().automatedExplore(unit); unit.action = "explore" },
|
||||||
unit.currentMovement != 0f)
|
unit.currentMovement != 0f)
|
||||||
@ -58,7 +58,7 @@ class UnitActions {
|
|||||||
actionList += UnitAction("Stop exploration", { unit.action = null }, true)
|
actionList += UnitAction("Stop exploration", { unit.action = null }, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!unit.baseUnit().unitType.isCivilian() && unit.promotions.canBePromoted()){
|
if(!unit.type.isCivilian() && unit.promotions.canBePromoted()){
|
||||||
actionList += UnitAction("Promote",
|
actionList += UnitAction("Promote",
|
||||||
{UnCivGame.Current.screen = PromotionPickerScreen(unit)},
|
{UnCivGame.Current.screen = PromotionPickerScreen(unit)},
|
||||||
unit.currentMovement != 0f)
|
unit.currentMovement != 0f)
|
||||||
|
@ -64,13 +64,13 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
unitNameLabel.setText(nameLabelText)
|
unitNameLabel.setText(nameLabelText)
|
||||||
|
|
||||||
var unitLabelText = "Movement".tr()+": " + unit.getMovementString()
|
var unitLabelText = "Movement".tr()+": " + unit.getMovementString()
|
||||||
if (!unit.baseUnit().unitType.isCivilian())
|
if (!unit.type.isCivilian())
|
||||||
unitLabelText += "\n"+"Strength".tr()+": " + unit.baseUnit().strength
|
unitLabelText += "\n"+"Strength".tr()+": " + unit.baseUnit().strength
|
||||||
|
|
||||||
if (unit.baseUnit().rangedStrength!=0)
|
if (unit.baseUnit().rangedStrength!=0)
|
||||||
unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.baseUnit().rangedStrength
|
unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.baseUnit().rangedStrength
|
||||||
|
|
||||||
if (!unit.baseUnit().unitType.isCivilian())
|
if (!unit.type.isCivilian())
|
||||||
unitLabelText += "\n"+"XP".tr()+": "+unit.promotions.XP+"/"+unit.promotions.xpForNextPromotion()
|
unitLabelText += "\n"+"XP".tr()+": "+unit.promotions.XP+"/"+unit.promotions.xpForNextPromotion()
|
||||||
|
|
||||||
if(unit.isFortified() && unit.getFortificationTurns()>0)
|
if(unit.isFortified() && unit.getFortificationTurns()>0)
|
||||||
|
Reference in New Issue
Block a user