mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Merge remote-tracking branch 'refs/remotes/yairm210/master'
This commit is contained in:
commit
76d80b30ca
@ -823,6 +823,10 @@
|
|||||||
Romanian:"Sa născut un [greatPerson]!"
|
Romanian:"Sa născut un [greatPerson]!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"We have encountered [civName]!":{}
|
||||||
|
|
||||||
|
"Cannot provide upkeep for [unitName] - unit has been disbanded!":{}
|
||||||
|
|
||||||
|
|
||||||
// Save and load game
|
// Save and load game
|
||||||
|
|
||||||
@ -2399,11 +2403,11 @@
|
|||||||
} // EG Rationalism policy branch unlocked!
|
} // EG Rationalism policy branch unlocked!
|
||||||
|
|
||||||
// Trade
|
// Trade
|
||||||
"Trade with [otherCiv]":{
|
"Trade":{
|
||||||
Italian:"Scambia con [otherCiv]"
|
Italian:"Scambia"
|
||||||
Russian:"Торговать с [otherCiv]"
|
Russian:"Торговля"
|
||||||
French:"Échanger avec [otherCiv]"
|
French:"Échanger"
|
||||||
Romanian:"Comerțul cu [otherCiv]"
|
Romanian:"Comerțul"
|
||||||
}
|
}
|
||||||
"Offer trade":{
|
"Offer trade":{
|
||||||
Italian:"Offerta commerciale"
|
Italian:"Offerta commerciale"
|
||||||
@ -2424,16 +2428,16 @@
|
|||||||
Romanian:"Articolele noastre"
|
Romanian:"Articolele noastre"
|
||||||
}
|
}
|
||||||
"Our trade offer":{
|
"Our trade offer":{
|
||||||
Italian:"La nostra offerta commerciale"
|
Italian:"La nostra \n offerta commerciale"
|
||||||
Russian:"Наше предложение обмена"
|
Russian:"Наше предложение\n обмена"
|
||||||
French:"Notre offre commerciale"
|
French:"Notre offre \n commerciale"
|
||||||
Romanian:"Oferta noastră comercială"
|
Romanian:"Oferta noastră \n comercială"
|
||||||
}
|
}
|
||||||
"[otherCiv]'s trade offer":{
|
"[otherCiv]'s trade offer":{
|
||||||
Italian:"Offerta commerciale di [otherCiv]"
|
Italian:"Offerta commerciale \n di [otherCiv]"
|
||||||
Russian:"Предложение обмена цивилизации [otherCiv]"
|
Russian:"Предложение обмена \n цивилизации [otherCiv]"
|
||||||
French:"L'offre commerciale de [otherCiv]"
|
French:"L'offre commerciale \n de [otherCiv]"
|
||||||
Romanian:"ofertă de schimb a [otherCiv]"
|
Romanian:"ofertă de \n schimb a [otherCiv]"
|
||||||
}
|
}
|
||||||
"[otherCiv]'s items":{
|
"[otherCiv]'s items":{
|
||||||
Italian:"Gli articoli di [otherCiv]"
|
Italian:"Gli articoli di [otherCiv]"
|
||||||
@ -2465,6 +2469,11 @@
|
|||||||
French:"Accept"
|
French:"Accept"
|
||||||
Romanian:"Accepta"
|
Romanian:"Accepta"
|
||||||
}
|
}
|
||||||
|
"There's nothing on the table":{}
|
||||||
|
|
||||||
|
|
||||||
|
"Peace treaty":{}
|
||||||
|
"Gold per turn":{}
|
||||||
|
|
||||||
|
|
||||||
//civilisations
|
//civilisations
|
||||||
@ -2609,6 +2618,11 @@
|
|||||||
Romanian:"Diplomaţie"
|
Romanian:"Diplomaţie"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"War":{}
|
||||||
|
"Peace":{}
|
||||||
|
|
||||||
|
"Declare war":{}
|
||||||
|
|
||||||
// Overview screen
|
// Overview screen
|
||||||
"Overview":{
|
"Overview":{
|
||||||
Italian:"Panoramica"
|
Italian:"Panoramica"
|
||||||
|
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 115
|
versionCode 116
|
||||||
versionName "2.7.3.2"
|
versionName "2.7.4"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -51,7 +51,9 @@ class GameInfo {
|
|||||||
|
|
||||||
player.startTurn()
|
player.startTurn()
|
||||||
|
|
||||||
val enemyUnitsCloseToTerritory = player.getViewableTiles().filter { it.militaryUnit!=null && it.militaryUnit!!.civInfo!=player
|
val enemyUnitsCloseToTerritory = player.getViewableTiles()
|
||||||
|
.filter { it.militaryUnit!=null && it.militaryUnit!!.civInfo!=player
|
||||||
|
&& player.isAtWarWith(it.militaryUnit!!.civInfo)
|
||||||
&& (it.getOwner()==player || it.neighbors.any { neighbor -> neighbor.getOwner()==player }) }
|
&& (it.getOwner()==player || it.neighbors.any { neighbor -> neighbor.getOwner()==player }) }
|
||||||
for(enemyUnitTile in enemyUnitsCloseToTerritory) {
|
for(enemyUnitTile in enemyUnitsCloseToTerritory) {
|
||||||
val inOrNear = if(enemyUnitTile.getOwner()==player) "in" else "near"
|
val inOrNear = if(enemyUnitTile.getOwner()==player) "in" else "near"
|
||||||
|
@ -81,6 +81,7 @@ class Automation {
|
|||||||
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() }
|
||||||
.groupBy { getMinDistanceBetweenCities(civInfo,it) }
|
.groupBy { getMinDistanceBetweenCities(civInfo,it) }
|
||||||
|
.toSortedMap()
|
||||||
val ourCombatStrength = evaluteCombatStrength(civInfo)
|
val ourCombatStrength = evaluteCombatStrength(civInfo)
|
||||||
for (group in enemyCivsByDistanceToOurs){
|
for (group in enemyCivsByDistanceToOurs){
|
||||||
if(group.key>7) break
|
if(group.key>7) break
|
||||||
|
@ -12,13 +12,64 @@ import com.unciv.logic.map.MapUnit
|
|||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
|
import com.unciv.ui.worldscreen.unit.UnitAction
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActions
|
import com.unciv.ui.worldscreen.unit.UnitActions
|
||||||
|
|
||||||
class UnitAutomation{
|
class UnitAutomation{
|
||||||
|
|
||||||
|
fun automateUnitMoves(unit: MapUnit) {
|
||||||
|
|
||||||
|
if (unit.name == "Settler") {
|
||||||
|
automateSettlerActions(unit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unit.name == "Worker") {
|
||||||
|
WorkerAutomation(unit).automateWorkerAction()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(unit.name.startsWith("Great")) return // I don't know what to do with you yet.
|
||||||
|
|
||||||
|
val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
|
||||||
|
|
||||||
|
if (tryUpgradeUnit(unit, unitActions)) return
|
||||||
|
|
||||||
|
// Accompany settlers
|
||||||
|
if (tryAccompanySettler(unit)) return
|
||||||
|
|
||||||
|
if (unit.health < 50) {
|
||||||
|
healUnit(unit)
|
||||||
|
return
|
||||||
|
} // do nothing but heal
|
||||||
|
|
||||||
|
// if there is an attackable unit in the vicinity, attack!
|
||||||
|
if (tryAttackNearbyEnemy(unit)) return
|
||||||
|
|
||||||
|
if (tryGarrisoningUnit(unit)) return
|
||||||
|
|
||||||
|
if (unit.health < 80) {
|
||||||
|
healUnit(unit)
|
||||||
|
return
|
||||||
|
} // do nothing but heal until 80 health
|
||||||
|
|
||||||
|
// find the closest enemy unit that we know of within 5 spaces and advance towards it
|
||||||
|
if (tryAdvanceTowardsCloseEnemy(unit)) return
|
||||||
|
|
||||||
|
if (unit.health < 100) {
|
||||||
|
healUnit(unit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focus all units without a specific target on the enemy city closest to one of our cities
|
||||||
|
if (tryHeadTowardsEnemyCity(unit)) return
|
||||||
|
|
||||||
|
// else, go to a random space
|
||||||
|
randomWalk(unit)
|
||||||
|
// if both failed, then... there aren't any reachable tiles. Which is possible.
|
||||||
|
}
|
||||||
|
|
||||||
fun healUnit(unit:MapUnit) {
|
fun healUnit(unit:MapUnit) {
|
||||||
// If we're low on health then heal
|
|
||||||
// todo: go to a more defensible place if there is one
|
|
||||||
val tilesInDistance = unit.getDistanceToTiles().keys
|
val tilesInDistance = unit.getDistanceToTiles().keys
|
||||||
val unitTile = unit.getTile()
|
val unitTile = unit.getTile()
|
||||||
|
|
||||||
@ -70,22 +121,33 @@ class UnitAutomation{
|
|||||||
return attackableTiles
|
return attackableTiles
|
||||||
}
|
}
|
||||||
|
|
||||||
fun automateUnitMoves(unit: MapUnit) {
|
private fun tryAdvanceTowardsCloseEnemy(unit: MapUnit): Boolean {
|
||||||
|
var closeEnemies = unit.getTile().getTilesInDistance(5)
|
||||||
|
.filter{ containsAttackableEnemy(it, unit.civInfo) && unit.movementAlgs().canReach(it)}
|
||||||
|
if(unit.getBaseUnit().unitType.isRanged())
|
||||||
|
closeEnemies = closeEnemies.filterNot { it.isCityCenter() && it.getCity()!!.health==1 }
|
||||||
|
|
||||||
if (unit.name == "Settler") {
|
val closestEnemy = closeEnemies.minBy { it.arialDistanceTo(unit.getTile()) }
|
||||||
automateSettlerActions(unit)
|
|
||||||
return
|
if (closestEnemy != null) {
|
||||||
|
unit.movementAlgs().headTowards(closestEnemy)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.name == "Worker") {
|
private fun tryAccompanySettler(unit: MapUnit): Boolean {
|
||||||
WorkerAutomation(unit).automateWorkerAction()
|
val closeTileWithSettler = unit.getDistanceToTiles().keys.firstOrNull {
|
||||||
return
|
it.civilianUnit != null && it.civilianUnit!!.name == "Settler"
|
||||||
|
}
|
||||||
|
if (closeTileWithSettler != null && unit.canMoveTo(closeTileWithSettler)) {
|
||||||
|
unit.movementAlgs().headTowards(closeTileWithSettler)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.name.startsWith("Great")) return // I don't know what to do with you yet.
|
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
||||||
|
|
||||||
val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
|
|
||||||
|
|
||||||
if (unit.getBaseUnit().upgradesTo != null) {
|
if (unit.getBaseUnit().upgradesTo != null) {
|
||||||
val upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
|
val upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
|
||||||
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
||||||
@ -93,54 +155,18 @@ class UnitAutomation{
|
|||||||
val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") }
|
val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") }
|
||||||
if (upgradeAction != null && unit.civInfo.gold > goldCostOfUpgrade) {
|
if (upgradeAction != null && unit.civInfo.gold > goldCostOfUpgrade) {
|
||||||
upgradeAction.action()
|
upgradeAction.action()
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
// Accompany settlers
|
|
||||||
val closeTileWithSettler = unit.getDistanceToTiles().keys.firstOrNull{
|
|
||||||
it.civilianUnit!=null && it.civilianUnit!!.name=="Settler"}
|
|
||||||
if(closeTileWithSettler != null && unit.canMoveTo(closeTileWithSettler)){
|
|
||||||
unit.movementAlgs().headTowards(closeTileWithSettler)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.health < 50) {
|
private fun tryHeadTowardsEnemyCity(unit: MapUnit): Boolean {
|
||||||
healUnit(unit)
|
var enemyCities = unit.civInfo.exploredTiles.map { unit.civInfo.gameInfo.tileMap[it] }
|
||||||
return
|
|
||||||
} // do nothing but heal
|
|
||||||
|
|
||||||
// if there is an attackable unit in the vicinity, attack!
|
|
||||||
if (tryAttackNearbyEnemy(unit)) return
|
|
||||||
|
|
||||||
if (tryGarrisoningUnit(unit)) return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (unit.health < 80) {
|
|
||||||
healUnit(unit)
|
|
||||||
return
|
|
||||||
} // do nothing but heal until 80 health
|
|
||||||
|
|
||||||
|
|
||||||
// find the closest enemy unit that we know of within 5 spaces and advance towards it
|
|
||||||
val closestEnemy = unit.getTile().getTilesInDistance(5)
|
|
||||||
.firstOrNull { containsAttackableEnemy(it,unit.civInfo) && unit.movementAlgs().canReach(it) }
|
|
||||||
|
|
||||||
if (closestEnemy != null) {
|
|
||||||
unit.movementAlgs().headTowards(closestEnemy)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unit.health < 100) {
|
|
||||||
healUnit(unit)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Focus all units without a specific target on the enemy city closest to one of our cities
|
|
||||||
val enemyCities = unit.civInfo.exploredTiles.map { unit.civInfo.gameInfo.tileMap[it] }
|
|
||||||
.filter { it.isCityCenter() && it.getOwner() != unit.civInfo }
|
.filter { it.isCityCenter() && it.getOwner() != unit.civInfo }
|
||||||
|
if(unit.getBaseUnit().unitType.isRanged())
|
||||||
|
enemyCities = enemyCities.filterNot { it.getCity()!!.health==1 }
|
||||||
if (enemyCities.isNotEmpty() && unit.civInfo.cities.isNotEmpty()) {
|
if (enemyCities.isNotEmpty() && unit.civInfo.cities.isNotEmpty()) {
|
||||||
val closestReachableEnemyCity = enemyCities
|
val closestReachableEnemyCity = enemyCities
|
||||||
.filter { unit.movementAlgs().canReach(it) }
|
.filter { unit.movementAlgs().canReach(it) }
|
||||||
@ -149,13 +175,10 @@ class UnitAutomation{
|
|||||||
}
|
}
|
||||||
if (closestReachableEnemyCity != null) {
|
if (closestReachableEnemyCity != null) {
|
||||||
unit.movementAlgs().headTowards(closestReachableEnemyCity)
|
unit.movementAlgs().headTowards(closestReachableEnemyCity)
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
// else, go to a random space
|
|
||||||
randomWalk(unit)
|
|
||||||
// if both failed, then... there aren't any reachable tiles. Which is possible.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryAttackNearbyEnemy(unit: MapUnit): Boolean {
|
private fun tryAttackNearbyEnemy(unit: MapUnit): Boolean {
|
||||||
@ -177,7 +200,6 @@ class UnitAutomation{
|
|||||||
if (unit.getBaseUnit().unitType.isMelee() && capturableCity!=null)
|
if (unit.getBaseUnit().unitType.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
|
||||||
enemyTileToAttack = nonCityTilesToAttack.minBy { Battle().getMapCombatantOfTile(it.tileToAttack)!!.getHealth() }
|
enemyTileToAttack = nonCityTilesToAttack.minBy { Battle().getMapCombatantOfTile(it.tileToAttack)!!.getHealth() }
|
||||||
else if (cityWithHealthLeft!=null) enemyTileToAttack = cityWithHealthLeft// third priority, city
|
else if (cityWithHealthLeft!=null) enemyTileToAttack = cityWithHealthLeft// third priority, city
|
||||||
@ -196,6 +218,7 @@ class UnitAutomation{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun tryGarrisoningUnit(unit: MapUnit): Boolean {
|
private fun tryGarrisoningUnit(unit: MapUnit): Boolean {
|
||||||
|
if(unit.getBaseUnit().unitType.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()
|
||||||
unit.canMoveTo(centerTile)
|
unit.canMoveTo(centerTile)
|
||||||
|
@ -106,6 +106,8 @@ class Battle(val gameInfo:GameInfo=UnCivGame.Current.gameInfo) {
|
|||||||
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
|
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
|
||||||
val enemyCiv = city.civInfo
|
val enemyCiv = city.civInfo
|
||||||
attacker.getCivilization().addNotification("We have conquered the city of [${city.name}]!",city.location, Color.RED)
|
attacker.getCivilization().addNotification("We have conquered the city of [${city.name}]!",city.location, Color.RED)
|
||||||
|
val currentPopulation = city.population.population
|
||||||
|
if(currentPopulation>1) city.population.population -= 1 + currentPopulation/4 // so from 2-4 population, remove 1, from 5-8, remove 2, etc.
|
||||||
city.moveToCiv(attacker.getCivilization())
|
city.moveToCiv(attacker.getCivilization())
|
||||||
city.health = city.getMaxHealth() / 2 // I think that cities recover to half health when conquered?
|
city.health = city.getMaxHealth() / 2 // I think that cities recover to half health when conquered?
|
||||||
city.getCenterTile().apply {
|
city.getCenterTile().apply {
|
||||||
|
@ -43,14 +43,14 @@ class CityConstructions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCityProductionTextForCityButton(): String {
|
fun getCityProductionTextForCityButton(): String {
|
||||||
var result = currentConstruction
|
var result = currentConstruction.tr()
|
||||||
if (SpecialConstruction.getSpecialConstructions().none { it.name==result })
|
if (SpecialConstruction.getSpecialConstructions().none { it.name==result })
|
||||||
result += "\r\n" + turnsToConstruction(currentConstruction) + " {turns}".tr()
|
result += "\r\n" + turnsToConstruction(currentConstruction) + " {turns}".tr()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getProductionForTileInfo(): String {
|
fun getProductionForTileInfo(): String {
|
||||||
var result = currentConstruction
|
var result = currentConstruction.tr()
|
||||||
if (SpecialConstruction.getSpecialConstructions().none { it.name==result })
|
if (SpecialConstruction.getSpecialConstructions().none { it.name==result })
|
||||||
result += "\r\n{in} ".tr() + turnsToConstruction(currentConstruction) + " {turns}".tr()
|
result += "\r\n{in} ".tr() + turnsToConstruction(currentConstruction) + " {turns}".tr()
|
||||||
return result
|
return result
|
||||||
|
@ -27,9 +27,10 @@ class MapUnit {
|
|||||||
|
|
||||||
fun getBaseUnit(): BaseUnit = GameBasics.Units[name]!!
|
fun getBaseUnit(): BaseUnit = GameBasics.Units[name]!!
|
||||||
fun getMovementString(): String = DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + maxMovement
|
fun getMovementString(): String = DecimalFormat("0.#").format(currentMovement.toDouble()) + "/" + maxMovement
|
||||||
fun getTile(): TileInfo {
|
|
||||||
return civInfo.gameInfo.tileMap.values.first{it.militaryUnit==this || it.civilianUnit==this}
|
@Transient
|
||||||
}
|
internal lateinit var currentTile :TileInfo
|
||||||
|
fun getTile(): TileInfo = currentTile
|
||||||
|
|
||||||
fun getDistanceToTiles(): HashMap<TileInfo, Float> {
|
fun getDistanceToTiles(): HashMap<TileInfo, Float> {
|
||||||
val tile = getTile()
|
val tile = getTile()
|
||||||
@ -187,6 +188,7 @@ class MapUnit {
|
|||||||
if(getBaseUnit().unitType== UnitType.Civilian)
|
if(getBaseUnit().unitType== UnitType.Civilian)
|
||||||
tile.civilianUnit=this
|
tile.civilianUnit=this
|
||||||
else tile.militaryUnit=this
|
else tile.militaryUnit=this
|
||||||
|
currentTile = tile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +65,8 @@ class TileMap {
|
|||||||
fun setTransients() {
|
fun setTransients() {
|
||||||
for (tileInfo in values){
|
for (tileInfo in values){
|
||||||
tileInfo.tileMap = this
|
tileInfo.tileMap = this
|
||||||
|
if(tileInfo.militaryUnit!=null) tileInfo.militaryUnit!!.currentTile = tileInfo
|
||||||
|
if(tileInfo.civilianUnit!=null) tileInfo.civilianUnit!!.currentTile = tileInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.unciv.ui.trade
|
package com.unciv.ui.trade
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -14,7 +11,7 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
val rightSideTable = Table()
|
val rightSideTable = Table()
|
||||||
|
|
||||||
init{
|
init{
|
||||||
val splitPane = SplitPane(leftSideTable,rightSideTable,false, skin)
|
val splitPane = SplitPane(ScrollPane(leftSideTable),rightSideTable,false, skin)
|
||||||
splitPane.setSplitAmount(0.2f)
|
splitPane.setSplitAmount(0.2f)
|
||||||
|
|
||||||
updateLeftSideTable()
|
updateLeftSideTable()
|
||||||
@ -64,7 +61,6 @@ class DiplomacyScreen():CameraStageBaseScreen(){
|
|||||||
}
|
}
|
||||||
civTable.add(declareWarButton).row()
|
civTable.add(declareWarButton).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
leftSideTable.add(civTable).row()
|
leftSideTable.add(civTable).row()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,23 +34,17 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
if(selectedUnit!=null)
|
if(selectedUnit!=null) {
|
||||||
{
|
|
||||||
if (selectedUnit!!.civInfo != worldScreen.civInfo) { // The unit that was selected, was captured. It exists but is no longer ours.
|
if (selectedUnit!!.civInfo != worldScreen.civInfo) { // The unit that was selected, was captured. It exists but is no longer ours.
|
||||||
selectedUnit = null
|
selectedUnit = null
|
||||||
currentlyExecutingAction = null
|
currentlyExecutingAction = null
|
||||||
selectedUnitHasChanged = true
|
selectedUnitHasChanged = true
|
||||||
}
|
} else if (selectedUnit!! !in selectedUnit!!.getTile().getUnits()) { // The unit that was there no longer exists}
|
||||||
else {
|
|
||||||
try {
|
|
||||||
selectedUnit!!.getTile()
|
|
||||||
} catch (ex: Exception) { // The unit that was there no longer exists}
|
|
||||||
selectedUnit = null
|
selectedUnit = null
|
||||||
currentlyExecutingAction = null
|
currentlyExecutingAction = null
|
||||||
selectedUnitHasChanged = true
|
selectedUnitHasChanged = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(prevIdleUnitButton.getTilesWithIdleUnits().isNotEmpty()) { // more efficient to do this check once for both
|
if(prevIdleUnitButton.getTilesWithIdleUnits().isNotEmpty()) { // more efficient to do this check once for both
|
||||||
prevIdleUnitButton.enable()
|
prevIdleUnitButton.enable()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user