More changes to enable multiplayer - save the current player in the civInfo, distinguish between "current player" and "human player"

This commit is contained in:
Yair Morgenstern 2019-01-10 21:29:24 +02:00
parent d19861b348
commit 8bf84393fc
25 changed files with 127 additions and 118 deletions

View File

@ -16,6 +16,7 @@ class GameParameters{
var difficulty="Prince" var difficulty="Prince"
var nation="Babylon" var nation="Babylon"
var mapRadius=20 var mapRadius=20
var humanPlayers=1
var numberOfEnemies=3 var numberOfEnemies=3
var mapType= MapType.Perlin var mapType= MapType.Perlin
} }
@ -27,15 +28,19 @@ class GameStarter{
gameInfo.gameParameters = newGameParameters gameInfo.gameParameters = newGameParameters
gameInfo.tileMap = TileMap(newGameParameters.mapRadius, newGameParameters.mapType) gameInfo.tileMap = TileMap(newGameParameters.mapRadius, newGameParameters.mapType)
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
val startingLocations = getStartingLocations(newGameParameters.numberOfEnemies+1,gameInfo.tileMap) val startingLocations = getStartingLocations(
newGameParameters.numberOfEnemies+newGameParameters.humanPlayers, gameInfo.tileMap)
val playerCiv = CivilizationInfo(newGameParameters.nation) for(i in 1..newGameParameters.humanPlayers) {
gameInfo.difficulty=newGameParameters.difficulty val playerCiv = CivilizationInfo(newGameParameters.nation)
playerCiv.playerType=PlayerType.Human gameInfo.difficulty = newGameParameters.difficulty
gameInfo.civilizations.add(playerCiv) // first one is player civ playerCiv.playerType = PlayerType.Human
gameInfo.civilizations.add(playerCiv)
}
val barbarianCivilization = CivilizationInfo() val barbarianCivilization = CivilizationInfo()
barbarianCivilization.civName = "Barbarians"
gameInfo.civilizations.add(barbarianCivilization)// second is barbarian civ gameInfo.civilizations.add(barbarianCivilization)// second is barbarian civ
for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled() for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled()
@ -45,8 +50,6 @@ class GameStarter{
} }
barbarianCivilization.civName = "Barbarians"
gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set
for (civInfo in gameInfo.civilizations.filter {!it.isBarbarianCivilization() && !it.isPlayerCivilization()}) { for (civInfo in gameInfo.civilizations.filter {!it.isBarbarianCivilization() && !it.isPlayerCivilization()}) {

View File

@ -17,25 +17,27 @@ class GameInfo {
var gameParameters=GameParameters() var gameParameters=GameParameters()
var turns = 0 var turns = 0
var oneMoreTurnMode=false var oneMoreTurnMode=false
var currentPlayer=""
//region pure functions //region pure functions
fun clone(): GameInfo { fun clone(): GameInfo {
val toReturn = GameInfo() val toReturn = GameInfo()
toReturn.tileMap = tileMap.clone() toReturn.tileMap = tileMap.clone()
toReturn.civilizations.addAll(civilizations.map { it.clone() }) toReturn.civilizations.addAll(civilizations.map { it.clone() })
toReturn.currentPlayer=currentPlayer
toReturn.turns = turns toReturn.turns = turns
toReturn.difficulty=difficulty toReturn.difficulty=difficulty
toReturn.gameParameters = gameParameters toReturn.gameParameters = gameParameters
return toReturn return toReturn
} }
fun getPlayerCivilization(): CivilizationInfo = civilizations[0] fun getCurrentPlayerCivilization(): CivilizationInfo = civilizations.first { it.civName==currentPlayer }
fun getBarbarianCivilization(): CivilizationInfo = civilizations[1] fun getBarbarianCivilization(): CivilizationInfo = civilizations.first { it.civName=="Barbarians" }
fun getDifficulty() = GameBasics.Difficulties[difficulty]!! fun getDifficulty() = GameBasics.Difficulties[difficulty]!!
//endregion //endregion
fun nextTurn() { fun nextTurn() {
val player = getPlayerCivilization() val currentPlayer = getCurrentPlayerCivilization()
for (civInfo in civilizations) { for (civInfo in civilizations) {
if (civInfo.tech.techsToResearch.isEmpty()) { // should belong in automation? yes/no? if (civInfo.tech.techsToResearch.isEmpty()) { // should belong in automation? yes/no?
@ -49,7 +51,7 @@ class GameInfo {
// We need to update the stats after ALL the cities are done updating because // We need to update the stats after ALL the cities are done updating because
// maybe one of them has a wonder that affects the stats of all the rest of the cities // maybe one of them has a wonder that affects the stats of all the rest of the cities
for (civInfo in civilizations.filterNot { it == player || (it.isDefeated() && !it.isBarbarianCivilization()) }) { for (civInfo in civilizations.filterNot { it == currentPlayer || (it.isDefeated() && !it.isBarbarianCivilization()) }) {
civInfo.startTurn() civInfo.startTurn()
NextTurnAutomation().automateCivMoves(civInfo) NextTurnAutomation().automateCivMoves(civInfo)
} }
@ -60,18 +62,18 @@ class GameInfo {
// Start our turn immediately before the player can made decisions - affects whether our units can commit automated actions and then be attacked immediately etc. // Start our turn immediately before the player can made decisions - affects whether our units can commit automated actions and then be attacked immediately etc.
player.startTurn() currentPlayer.startTurn()
val enemyUnitsCloseToTerritory = player.viewableTiles val enemyUnitsCloseToTerritory = currentPlayer.viewableTiles
.filter { .filter {
it.militaryUnit != null && it.militaryUnit!!.civInfo != player it.militaryUnit != null && it.militaryUnit!!.civInfo != currentPlayer
&& player.isAtWarWith(it.militaryUnit!!.civInfo) && currentPlayer.isAtWarWith(it.militaryUnit!!.civInfo)
&& (it.getOwner() == player || it.neighbors.any { neighbor -> neighbor.getOwner() == player }) && (it.getOwner() == currentPlayer || it.neighbors.any { neighbor -> neighbor.getOwner() == currentPlayer })
} }
for (enemyUnitTile in enemyUnitsCloseToTerritory) { for (enemyUnitTile in enemyUnitsCloseToTerritory) {
val inOrNear = if (enemyUnitTile.getOwner() == player) "in" else "near" val inOrNear = if (enemyUnitTile.getOwner() == currentPlayer) "in" else "near"
val unitName = enemyUnitTile.militaryUnit!!.name val unitName = enemyUnitTile.militaryUnit!!.name
player.addNotification("An enemy [$unitName] was spotted $inOrNear our territory", enemyUnitTile.position, Color.RED) currentPlayer.addNotification("An enemy [$unitName] was spotted $inOrNear our territory", enemyUnitTile.position, Color.RED)
} }
turns++ turns++
@ -94,15 +96,17 @@ class GameInfo {
tileMap.gameInfo = this tileMap.gameInfo = this
tileMap.setTransients() tileMap.setTransients()
if(currentPlayer=="") currentPlayer=civilizations[0].civName
// this is separated into 2 loops because when we activate updateViewableTiles in civ.setTransients, // this is separated into 2 loops because when we activate updateViewableTiles in civ.setTransients,
// we try to find new civs, and we check if civ is barbarian, which we can't know unless the gameInfo is already set. // we try to find new civs, and we check if civ is barbarian, which we can't know unless the gameInfo is already set.
for (civInfo in civilizations) civInfo.gameInfo = this for (civInfo in civilizations) civInfo.gameInfo = this
// PlayerType was only added in 2.11.1, so we need to adjust for older saved games // PlayerType was only added in 2.11.1, so we need to adjust for older saved games
if(civilizations.all { it.playerType==PlayerType.AI }) if(civilizations.all { it.playerType==PlayerType.AI })
getPlayerCivilization().playerType=PlayerType.Human getCurrentPlayerCivilization().playerType=PlayerType.Human
if(getPlayerCivilization().difficulty!="Chieftain") if(getCurrentPlayerCivilization().difficulty!="Chieftain")
difficulty= getPlayerCivilization().difficulty difficulty= getCurrentPlayerCivilization().difficulty
for (civInfo in civilizations) civInfo.setTransients() for (civInfo in civilizations) civInfo.setTransients()

View File

@ -93,7 +93,7 @@ class CityStats {
val civ = cityInfo.civInfo val civ = cityInfo.civInfo
if (!civ.isPlayerCivilization()) { if (!civ.isPlayerCivilization()) {
val modifier = civ.gameInfo.getPlayerCivilization().getDifficulty().aiYieldModifier val modifier = civ.gameInfo.getCurrentPlayerCivilization().getDifficulty().aiYieldModifier
stats.production += modifier stats.production += modifier
stats.science += modifier stats.science += modifier
stats.food += modifier stats.food += modifier
@ -143,7 +143,7 @@ class CityStats {
val newHappinessList = LinkedHashMap<String,Float>() val newHappinessList = LinkedHashMap<String,Float>()
var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier
if(!civInfo.isPlayerCivilization()) if(!civInfo.isPlayerCivilization())
unhappinessModifier *= civInfo.gameInfo.getPlayerCivilization().getDifficulty().aiUnhappinessModifier unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier
newHappinessList ["Cities"] = -3f * unhappinessModifier newHappinessList ["Cities"] = -3f * unhappinessModifier

View File

@ -40,7 +40,7 @@ class PopulationManager {
// civ v math, civilization.wikia // civ v math, civilization.wikia
var foodRequired = 15 + 6 * (population - 1) + Math.floor(Math.pow((population - 1).toDouble(), 1.8)) var foodRequired = 15 + 6 * (population - 1) + Math.floor(Math.pow((population - 1).toDouble(), 1.8))
if(!cityInfo.civInfo.isPlayerCivilization()) if(!cityInfo.civInfo.isPlayerCivilization())
foodRequired *= cityInfo.civInfo.gameInfo.getPlayerCivilization().getDifficulty().aiCityGrowthModifier foodRequired *= cityInfo.civInfo.gameInfo.getDifficulty().aiCityGrowthModifier
return foodRequired.toInt() return foodRequired.toInt()
} }

View File

@ -87,13 +87,13 @@ class CivilizationInfo {
//region pure functions //region pure functions
fun getDifficulty():Difficulty { fun getDifficulty():Difficulty {
if(playerType==PlayerType.AI) return GameBasics.Difficulties["Chieftain"]!! if (isPlayerCivilization()) return gameInfo.getDifficulty()
else return gameInfo.getDifficulty() return GameBasics.Difficulties["Chieftain"]!!
} }
fun getNation() = GameBasics.Nations[civName]!! fun getNation() = GameBasics.Nations[civName]!!
fun getCapital()=cities.first { it.isCapital() } fun getCapital()=cities.first { it.isCapital() }
fun isPlayerCivilization() = gameInfo.getPlayerCivilization()==this fun isPlayerCivilization() = playerType==PlayerType.Human
fun isBarbarianCivilization() = gameInfo.getBarbarianCivilization()==this fun isBarbarianCivilization() = gameInfo.getBarbarianCivilization()==this
fun getStatsForNextTurn():Stats{ fun getStatsForNextTurn():Stats{
@ -152,7 +152,7 @@ class CivilizationInfo {
var cost = baseUnitCost*totalPaidUnits*(1+gameProgress) var cost = baseUnitCost*totalPaidUnits*(1+gameProgress)
cost = cost.pow(1+gameProgress/3) // Why 3? To spread 1 to 1.33 cost = cost.pow(1+gameProgress/3) // Why 3? To spread 1 to 1.33
if(!isPlayerCivilization()) if(!isPlayerCivilization())
cost *= gameInfo.getPlayerCivilization().getDifficulty().aiUnitMaintenanceModifier cost *= gameInfo.getDifficulty().aiUnitMaintenanceModifier
if(policies.isAdopted("Autocracy")) cost *= 0.66f if(policies.isAdopted("Autocracy")) cost *= 0.66f
return cost.toInt() return cost.toInt()
} }
@ -313,7 +313,7 @@ class CivilizationInfo {
victoryManager.currentsSpaceshipParts = scienceVictory.currentParts victoryManager.currentsSpaceshipParts = scienceVictory.currentParts
for (cityInfo in cities) { for (cityInfo in cities) {
cityInfo.civInfo = this // must be before the city's setTransients because it depends on the tilemap, that comes from the playerCivInfo cityInfo.civInfo = this // must be before the city's setTransients because it depends on the tilemap, that comes from the currentPlayerCivInfo
cityInfo.setTransients() cityInfo.setTransients()
} }
setCitiesConnectedToCapitalTransients() setCitiesConnectedToCapitalTransients()

View File

@ -237,7 +237,7 @@ open class TileInfo {
override fun toString(): String { override fun toString(): String {
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
val isViewableToPlayer = UnCivGame.Current.viewEntireMapForDebug val isViewableToPlayer = UnCivGame.Current.viewEntireMapForDebug
|| UnCivGame.Current.gameInfo.getPlayerCivilization().viewableTiles.contains(this) || UnCivGame.Current.gameInfo.getCurrentPlayerCivilization().viewableTiles.contains(this)
if (isCityCenter()) { if (isCityCenter()) {
val city = getCity()!! val city = getCity()!!
@ -249,7 +249,7 @@ open class TileInfo {
} }
lineList += baseTerrain.tr() lineList += baseTerrain.tr()
if (terrainFeature != null) lineList += terrainFeature!!.tr() if (terrainFeature != null) lineList += terrainFeature!!.tr()
if (hasViewableResource(tileMap.gameInfo.getPlayerCivilization())) lineList += resource!!.tr() if (hasViewableResource(tileMap.gameInfo.getCurrentPlayerCivilization())) lineList += resource!!.tr()
if (roadStatus !== RoadStatus.None && !isCityCenter()) lineList += roadStatus.toString().tr() if (roadStatus !== RoadStatus.None && !isCityCenter()) lineList += roadStatus.toString().tr()
if (improvement != null) lineList += improvement!!.tr() if (improvement != null) lineList += improvement!!.tr()
if (improvementInProgress != null && isViewableToPlayer) if (improvementInProgress != null && isViewableToPlayer)

View File

@ -20,10 +20,10 @@ class Technology : ICivilopedia {
lineList += impimpString.tr() lineList += impimpString.tr()
} }
val playerCiv = UnCivGame.Current.gameInfo.getPlayerCivilization().civName val currentPlayerCiv = UnCivGame.Current.gameInfo.currentPlayer
var enabledUnits = GameBasics.Units.values.filter { var enabledUnits = GameBasics.Units.values.filter {
it.requiredTech == name && it.requiredTech == name &&
(it.uniqueTo == null || it.uniqueTo == playerCiv) (it.uniqueTo == null || it.uniqueTo == currentPlayerCiv)
} }
val replacedUnits = enabledUnits.mapNotNull { it.replaces } val replacedUnits = enabledUnits.mapNotNull { it.replaces }
enabledUnits = enabledUnits.filter { it.name !in replacedUnits } enabledUnits = enabledUnits.filter { it.name !in replacedUnits }
@ -35,7 +35,7 @@ class Technology : ICivilopedia {
var enabledBuildings = GameBasics.Buildings.values.filter { var enabledBuildings = GameBasics.Buildings.values.filter {
it.requiredTech == name && it.requiredTech == name &&
(it.uniqueTo == null || it.uniqueTo == playerCiv) (it.uniqueTo == null || it.uniqueTo == currentPlayerCiv)
} }
val replacedBuildings = enabledBuildings.mapNotNull { it.replaces } val replacedBuildings = enabledBuildings.mapNotNull { it.replaces }
enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings } enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings }

View File

@ -21,7 +21,7 @@ import kotlin.math.roundToInt
class EmpireOverviewScreen : CameraStageBaseScreen(){ class EmpireOverviewScreen : CameraStageBaseScreen(){
val playerCivInfo = UnCivGame.Current.gameInfo.getPlayerCivilization() val currentPlayerCivInfo = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
init { init {
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() } onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }
val topTable = Table().apply { defaults().pad(10f) } val topTable = Table().apply { defaults().pad(10f) }
@ -92,7 +92,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun getTradesTable(): Table { private fun getTradesTable(): Table {
val tradesTable = Table().apply { defaults().pad(10f) } val tradesTable = Table().apply { defaults().pad(10f) }
for(diplomacy in playerCivInfo.diplomacy.values) for(diplomacy in currentPlayerCivInfo.diplomacy.values)
for(trade in diplomacy.trades) for(trade in diplomacy.trades)
tradesTable.add(createTradeTable(trade,diplomacy.otherCiv())).row() tradesTable.add(createTradeTable(trade,diplomacy.otherCiv())).row()
@ -101,7 +101,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun createTradeTable(trade: Trade, otherCiv:CivilizationInfo): Table { private fun createTradeTable(trade: Trade, otherCiv:CivilizationInfo): Table {
val generalTable = Table(skin) val generalTable = Table(skin)
generalTable.add(createOffersTable(playerCivInfo,trade.ourOffers, trade.theirOffers.size)) generalTable.add(createOffersTable(currentPlayerCivInfo,trade.ourOffers, trade.theirOffers.size))
generalTable.add(createOffersTable(otherCiv, trade.theirOffers, trade.ourOffers.size)) generalTable.add(createOffersTable(otherCiv, trade.theirOffers, trade.ourOffers.size))
return generalTable return generalTable
} }
@ -128,12 +128,12 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
happinessTable.defaults().pad(5f) happinessTable.defaults().pad(5f)
happinessTable.add(Label("Happiness".tr(), skin).setFontSize(24)).colspan(2).row() happinessTable.add(Label("Happiness".tr(), skin).setFontSize(24)).colspan(2).row()
happinessTable.addSeparator() happinessTable.addSeparator()
for (entry in playerCivInfo.getHappinessForNextTurn()) { for (entry in currentPlayerCivInfo.getHappinessForNextTurn()) {
happinessTable.add(entry.key.tr()) happinessTable.add(entry.key.tr())
happinessTable.add(entry.value.toString()).row() happinessTable.add(entry.value.toString()).row()
} }
happinessTable.add("Total".tr()) happinessTable.add("Total".tr())
happinessTable.add(playerCivInfo.getHappinessForNextTurn().values.sum().toString()) happinessTable.add(currentPlayerCivInfo.getHappinessForNextTurn().values.sum().toString())
happinessTable.pack() happinessTable.pack()
return happinessTable return happinessTable
} }
@ -144,7 +144,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
goldTable.add(Label("Gold".tr(), skin).setFontSize(24)).colspan(2).row() goldTable.add(Label("Gold".tr(), skin).setFontSize(24)).colspan(2).row()
goldTable.addSeparator() goldTable.addSeparator()
var total=0f var total=0f
for (entry in playerCivInfo.getStatMapForNextTurn()) { for (entry in currentPlayerCivInfo.getStatMapForNextTurn()) {
if(entry.value.gold==0f) continue if(entry.value.gold==0f) continue
goldTable.add(entry.key.tr()) goldTable.add(entry.key.tr())
goldTable.add(entry.value.gold.toString()).row() goldTable.add(entry.value.gold.toString()).row()
@ -160,9 +160,9 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun getGreatPeopleTable(): Table { private fun getGreatPeopleTable(): Table {
val greatPeopleTable = Table(skin) val greatPeopleTable = Table(skin)
val greatPersonPoints = playerCivInfo.greatPeople.greatPersonPoints.toHashMap() val greatPersonPoints = currentPlayerCivInfo.greatPeople.greatPersonPoints.toHashMap()
val greatPersonPointsPerTurn = playerCivInfo.getGreatPersonPointsForNextTurn().toHashMap() val greatPersonPointsPerTurn = currentPlayerCivInfo.getGreatPersonPointsForNextTurn().toHashMap()
val pointsToGreatPerson = playerCivInfo.greatPeople.pointsForNextGreatPerson val pointsToGreatPerson = currentPlayerCivInfo.greatPeople.pointsForNextGreatPerson
greatPeopleTable.defaults().pad(5f) greatPeopleTable.defaults().pad(5f)
greatPeopleTable.add(Label("Great person points".tr(), skin).setFontSize(24)).colspan(3).row() greatPeopleTable.add(Label("Great person points".tr(), skin).setFontSize(24)).colspan(3).row()
@ -171,14 +171,14 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
greatPeopleTable.add("Current points") greatPeopleTable.add("Current points")
greatPeopleTable.add("Points per turn").row() greatPeopleTable.add("Points per turn").row()
val mapping = playerCivInfo.greatPeople.statToGreatPersonMapping val mapping = currentPlayerCivInfo.greatPeople.statToGreatPersonMapping
for(entry in mapping){ for(entry in mapping){
greatPeopleTable.add(entry.value.tr()) greatPeopleTable.add(entry.value.tr())
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson) greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row() greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row()
} }
val pointsForGreatGeneral = playerCivInfo.greatPeople.greatGeneralPoints.toInt().toString() val pointsForGreatGeneral = currentPlayerCivInfo.greatPeople.greatGeneralPoints.toInt().toString()
val pointsForNextGreatGeneral = playerCivInfo.greatPeople.pointsForNextGreatGeneral.toInt().toString() val pointsForNextGreatGeneral = currentPlayerCivInfo.greatPeople.pointsForNextGreatGeneral.toInt().toString()
greatPeopleTable.add("Great General".tr()) greatPeopleTable.add("Great General".tr())
greatPeopleTable.add(pointsForGreatGeneral+"/"+pointsForNextGreatGeneral).row() greatPeopleTable.add(pointsForGreatGeneral+"/"+pointsForNextGreatGeneral).row()
greatPeopleTable.pack() greatPeopleTable.pack()
@ -208,7 +208,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
val cityInfoTableDetails = Table(skin) val cityInfoTableDetails = Table(skin)
cityInfoTableDetails.defaults().pad(padding).minWidth(iconSize).align(Align.left)//we need the min width so we can align the different tables cityInfoTableDetails.defaults().pad(padding).minWidth(iconSize).align(Align.left)//we need the min width so we can align the different tables
for (city in playerCivInfo.cities) { for (city in currentPlayerCivInfo.cities) {
cityInfoTableDetails.add(city.name) cityInfoTableDetails.add(city.name)
cityInfoTableDetails.add(city.cityConstructions.getCityProductionTextForCityButton()).actor!!.setAlignment(Align.left) cityInfoTableDetails.add(city.cityConstructions.getCityProductionTextForCityButton()).actor!!.setAlignment(Align.left)
cityInfoTableDetails.add(city.population.population.toString()).actor!!.setAlignment(Align.center) cityInfoTableDetails.add(city.population.population.toString()).actor!!.setAlignment(Align.center)
@ -230,13 +230,13 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
cityInfoTableTotal.defaults().pad(padding).minWidth(iconSize)//we need the min width so we can align the different tables cityInfoTableTotal.defaults().pad(padding).minWidth(iconSize)//we need the min width so we can align the different tables
cityInfoTableTotal.add("Total".tr()) cityInfoTableTotal.add("Total".tr())
cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(currentPlayerCivInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add()//an intended empty space cityInfoTableTotal.add()//an intended empty space
cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(currentPlayerCivInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.science.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(currentPlayerCivInfo.cities.sumBy { it.cityStats.currentCityStats.science.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add()//an intended empty space cityInfoTableTotal.add()//an intended empty space
cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.culture.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(currentPlayerCivInfo.cities.sumBy { it.cityStats.currentCityStats.culture.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.happiness.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(currentPlayerCivInfo.cities.sumBy { it.cityStats.currentCityStats.happiness.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.pack() cityInfoTableTotal.pack()
@ -265,7 +265,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
table.row() table.row()
table.addSeparator() table.addSeparator()
for(unit in playerCivInfo.getCivUnits()){ for(unit in currentPlayerCivInfo.getCivUnits()){
val baseUnit = unit.baseUnit() val baseUnit = unit.baseUnit()
table.add(unit.name.tr()) table.add(unit.name.tr())
if(baseUnit.strength>0) table.add(baseUnit.strength.toString()) else table.add() if(baseUnit.strength>0) table.add(baseUnit.strength.toString()) else table.add()
@ -281,10 +281,10 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
fun playerKnows(civ:CivilizationInfo) = civ.isPlayerCivilization() || fun playerKnows(civ:CivilizationInfo) = civ.isPlayerCivilization() ||
playerCivInfo.diplomacy.containsKey(civ.civName) currentPlayerCivInfo.diplomacy.containsKey(civ.civName)
fun createDiplomacyGroup(): Group { fun createDiplomacyGroup(): Group {
val relevantCivs = playerCivInfo.gameInfo.civilizations.filter { !it.isBarbarianCivilization() } val relevantCivs = currentPlayerCivInfo.gameInfo.civilizations.filter { !it.isBarbarianCivilization() }
val groupSize = 500f val groupSize = 500f
val group = Group() val group = Group()
group.setSize(groupSize,groupSize) group.setSize(groupSize,groupSize)

View File

@ -12,7 +12,7 @@ import com.unciv.ui.utils.onClick
class VictoryScreen : PickerScreen() { class VictoryScreen : PickerScreen() {
val playerCivInfo = UnCivGame.Current.gameInfo.getPlayerCivilization() val playerCivInfo = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
init { init {
topTable.skin=skin topTable.skin=skin

View File

@ -38,7 +38,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
} }
private fun updateYieldGroup() { private fun updateYieldGroup() {
yieldGroup.setStats(tileInfo.getTileStats(city, city.civInfo.gameInfo.getPlayerCivilization())) yieldGroup.setStats(tileInfo.getTileStats(city, city.civInfo.gameInfo.getCurrentPlayerCivilization()))
yieldGroup.setOrigin(Align.center) yieldGroup.setOrigin(Align.center)
yieldGroup.setScale(0.7f) yieldGroup.setScale(0.7f)
yieldGroup.toFront() yieldGroup.toFront()

View File

@ -31,7 +31,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
} }
init { init {
val civInfo = game.gameInfo.getPlayerCivilization() val currentPlayerCiv = game.gameInfo.getCurrentPlayerCivilization()
closeButton.onClick { closeButton.onClick {
game.screen = CityScreen(this@ConstructionPickerScreen.city) game.screen = CityScreen(this@ConstructionPickerScreen.city)
@ -60,7 +60,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
if (!building.isBuildable(cityConstructions) && building.name!=cityConstructions.currentConstruction) continue if (!building.isBuildable(cityConstructions) && building.name!=cityConstructions.currentConstruction) continue
val productionTextButton = getProductionButton(building.name, val productionTextButton = getProductionButton(building.name,
building.name + "\r\n" + cityConstructions.turnsToConstruction(building.name) + " {turns}".tr(), building.name + "\r\n" + cityConstructions.turnsToConstruction(building.name) + " {turns}".tr(),
building.getDescription(true, civInfo.policies.getAdoptedPolicies()), building.getDescription(true, currentPlayerCiv.policies.getAdoptedPolicies()),
"Build [${building.name}]".tr()) "Build [${building.name}]".tr())
if (building.isWonder) if (building.isWonder)
wonders.addActor(productionTextButton) wonders.addActor(productionTextButton)

View File

@ -34,9 +34,9 @@ class GreatPersonPickerScreen : PickerScreen() {
} }
rightSideButton.onClick("choir") { rightSideButton.onClick("choir") {
val civInfo = UnCivGame.Current.gameInfo.getPlayerCivilization() val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
civInfo.placeUnitNearTile(civInfo.cities[0].location, theChosenOne!!.name) currentPlayerCiv.placeUnitNearTile(currentPlayerCiv.cities[0].location, theChosenOne!!.name)
civInfo.greatPeople.freeGreatPeople-- currentPlayerCiv.greatPeople.freeGreatPeople--
UnCivGame.Current.setWorldScreen() UnCivGame.Current.setWorldScreen()
} }

View File

@ -16,12 +16,12 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
private var selectedImprovement: TileImprovement? = null private var selectedImprovement: TileImprovement? = null
init { init {
val civInfo = game.gameInfo.getPlayerCivilization() val currentPlayerCiv = game.gameInfo.getCurrentPlayerCivilization()
setDefaultCloseAction() setDefaultCloseAction()
rightSideButton.setText("Pick improvement") rightSideButton.setText("Pick improvement")
rightSideButton.onClick { rightSideButton.onClick {
tileInfo.startWorkingOnImprovement(selectedImprovement!!, civInfo) tileInfo.startWorkingOnImprovement(selectedImprovement!!, currentPlayerCiv)
if(tileInfo.civilianUnit!=null) tileInfo.civilianUnit!!.action=null // this is to "wake up" the worker if it's sleeping if(tileInfo.civilianUnit!=null) tileInfo.civilianUnit!!.action=null // this is to "wake up" the worker if it's sleeping
game.setWorldScreen() game.setWorldScreen()
dispose() dispose()
@ -30,7 +30,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
val regularImprovements = VerticalGroup() val regularImprovements = VerticalGroup()
regularImprovements.space(10f) regularImprovements.space(10f)
for (improvement in GameBasics.TileImprovements.values) { for (improvement in GameBasics.TileImprovements.values) {
if (!tileInfo.canBuildImprovement(improvement, civInfo)) continue if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
if(improvement.name == tileInfo.improvement) continue if(improvement.name == tileInfo.improvement) continue
if(improvement.name==tileInfo.improvementInProgress) continue if(improvement.name==tileInfo.improvementInProgress) continue
@ -40,7 +40,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
improvementButton.add(ImageGetter.getImage("OtherIcons/Stop.png")).size(30f).pad(10f) improvementButton.add(ImageGetter.getImage("OtherIcons/Stop.png")).size(30f).pad(10f)
else improvementButton.add(ImageGetter.getImprovementIcon(improvement.name,30f)).pad(10f) else improvementButton.add(ImageGetter.getImprovementIcon(improvement.name,30f)).pad(10f)
improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(civInfo) + " {turns}".tr(),skin) improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(currentPlayerCiv) + " {turns}".tr(),skin)
.setFontColor(Color.WHITE)).pad(10f) .setFontColor(Color.WHITE)).pad(10f)
improvementButton.onClick { improvementButton.onClick {

View File

@ -44,7 +44,8 @@ class LoadScreen : PickerScreen() {
textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt) textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt)
try{ try{
val game = GameSaver().loadGame(it) val game = GameSaver().loadGame(it)
textToSet+="\n"+game.getPlayerCivilization().civName.tr()+ val playerCivNames = game.civilizations.filter { it.isPlayerCivilization() }.joinToString{it.civName.tr()}
textToSet+="\n"+playerCivNames+
", "+game.difficulty.tr()+", {Turn} ".tr()+game.turns ", "+game.difficulty.tr()+", {Turn} ".tr()+game.turns
}catch (ex:Exception){ }catch (ex:Exception){
textToSet+="\n{Could not load game}!".tr() textToSet+="\n{Could not load game}!".tr()

View File

@ -136,7 +136,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
open fun update(isViewable: Boolean, showResourcesAndImprovements:Boolean, showSubmarine: Boolean) { open fun update(isViewable: Boolean, showResourcesAndImprovements:Boolean, showSubmarine: Boolean) {
hideCircle() hideCircle()
if (!UnCivGame.Current.viewEntireMapForDebug if (!UnCivGame.Current.viewEntireMapForDebug
&& !tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)) { && !tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization().exploredTiles.contains(tileInfo.position)) {
hexagon.color = Color.BLACK hexagon.color = Color.BLACK
return return
} }
@ -321,7 +321,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
private fun updateResourceImage(showResourcesAndImprovements: Boolean) { private fun updateResourceImage(showResourcesAndImprovements: Boolean) {
val shouldDisplayResource = showResourcesAndImprovements val shouldDisplayResource = showResourcesAndImprovements
&& tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getPlayerCivilization()) && tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization())
if (resourceImage != null && !shouldDisplayResource) { if (resourceImage != null && !shouldDisplayResource) {
resourceImage!!.remove() resourceImage!!.remove()

View File

@ -31,8 +31,9 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
&& city!!.civInfo.isPlayerCivilization()) && city!!.civInfo.isPlayerCivilization())
addPopulationIcon() addPopulationIcon()
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
if (UnCivGame.Current.viewEntireMapForDebug if (UnCivGame.Current.viewEntireMapForDebug
|| tileInfo.tileMap.gameInfo.getPlayerCivilization().exploredTiles.contains(tileInfo.position)) || currentPlayerCiv.exploredTiles.contains(tileInfo.position))
updateCityButton(city, isViewable || UnCivGame.Current.viewEntireMapForDebug) // needs to be before the update so the units will be above the city button updateCityButton(city, isViewable || UnCivGame.Current.viewEntireMapForDebug) // needs to be before the update so the units will be above the city button
super.update(isViewable || UnCivGame.Current.viewEntireMapForDebug, super.update(isViewable || UnCivGame.Current.viewEntireMapForDebug,
@ -40,7 +41,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
yieldGroup.isVisible = !UnCivGame.Current.settings.showResourcesAndImprovements yieldGroup.isVisible = !UnCivGame.Current.settings.showResourcesAndImprovements
if (yieldGroup.isVisible) if (yieldGroup.isVisible)
yieldGroup.setStats(tileInfo.getTileStats(UnCivGame.Current.gameInfo.getPlayerCivilization())) yieldGroup.setStats(tileInfo.getTileStats(currentPlayerCiv))
// order by z index! // order by z index!
cityImage?.toFront() cityImage?.toFront()

View File

@ -31,11 +31,11 @@ class DiplomacyScreen:CameraStageBaseScreen(){
private fun updateLeftSideTable() { private fun updateLeftSideTable() {
leftSideTable.clear() leftSideTable.clear()
val playerCiv = UnCivGame.Current.gameInfo.getPlayerCivilization() val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
for (civ in UnCivGame.Current.gameInfo.civilizations for (civ in UnCivGame.Current.gameInfo.civilizations
.filterNot { it.isDefeated() || it.isPlayerCivilization() || it.isBarbarianCivilization() }) { .filterNot { it.isDefeated() || it.isPlayerCivilization() || it.isBarbarianCivilization() }) {
if (!playerCiv.diplomacy.containsKey(civ.civName)) continue if (!currentPlayerCiv.diplomacy.containsKey(civ.civName)) continue
val civDiplomacy = playerCiv.diplomacy[civ.civName]!! val civDiplomacy = currentPlayerCiv.diplomacy[civ.civName]!!
val civTable = Table().apply { background = ImageGetter.getBackground(civ.getNation().getColor()) } val civTable = Table().apply { background = ImageGetter.getBackground(civ.getNation().getColor()) }
civTable.pad(10f) civTable.pad(10f)
@ -52,7 +52,7 @@ class DiplomacyScreen:CameraStageBaseScreen(){
} }
civTable.add(tradeButton).row() civTable.add(tradeButton).row()
if (!playerCiv.isAtWarWith(civ)) { if (!currentPlayerCiv.isAtWarWith(civ)) {
val declareWarButton = TextButton("Declare war".tr(), skin) val declareWarButton = TextButton("Declare war".tr(), skin)
declareWarButton.color = Color.RED declareWarButton.color = Color.RED
val turnsToPeaceTreaty = civDiplomacy.turnsToPeaceTreaty() val turnsToPeaceTreaty = civDiplomacy.turnsToPeaceTreaty()

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.UnCivGame
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.trade.TradeLogic import com.unciv.logic.trade.TradeLogic
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
@ -12,7 +11,8 @@ import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeComplete: () -> Unit): Table(CameraStageBaseScreen.skin){ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeComplete: () -> Unit): Table(CameraStageBaseScreen.skin){
var tradeLogic = TradeLogic(UnCivGame.Current.gameInfo.getPlayerCivilization(),otherCivilization) val currentPlayerCiv = otherCivilization.gameInfo.getCurrentPlayerCivilization()
var tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() } var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
var offerColumnsTableWrapper = Table() // This is so that after a trade has been traded, we can switch out the offers to start anew - this is the easiest way var offerColumnsTableWrapper = Table() // This is so that after a trade has been traded, we can switch out the offers to start anew - this is the easiest way
val tradeText = Label("What do you have in mind?".tr(), CameraStageBaseScreen.skin) val tradeText = Label("What do you have in mind?".tr(), CameraStageBaseScreen.skin)
@ -42,7 +42,7 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: Stage, onTradeC
} }
else if(offerButton.text.toString() == "Accept".tr()){ else if(offerButton.text.toString() == "Accept".tr()){
tradeLogic.acceptTrade() tradeLogic.acceptTrade()
tradeLogic = TradeLogic(UnCivGame.Current.gameInfo.getPlayerCivilization(),otherCivilization) tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() } offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
offerColumnsTableWrapper.clear() offerColumnsTableWrapper.clear()
offerColumnsTableWrapper.add(offerColumnsTable) offerColumnsTableWrapper.add(offerColumnsTable)

View File

@ -26,7 +26,7 @@ import com.unciv.ui.worldscreen.unit.UnitActionsTable
class WorldScreen : CameraStageBaseScreen() { class WorldScreen : CameraStageBaseScreen() {
val gameInfo = game.gameInfo val gameInfo = game.gameInfo
internal val civInfo: CivilizationInfo = gameInfo.getPlayerCivilization() internal val currentPlayerCiv: CivilizationInfo = gameInfo.getCurrentPlayerCivilization()
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap) val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap)
val minimapWrapper = MinimapHolder(tileMapHolder) val minimapWrapper = MinimapHolder(tileMapHolder)
@ -56,7 +56,7 @@ class WorldScreen : CameraStageBaseScreen() {
techButton.touchable=Touchable.enabled techButton.touchable=Touchable.enabled
techButton.onClick("paper") { techButton.onClick("paper") {
game.screen = TechPickerScreen(civInfo) game.screen = TechPickerScreen(currentPlayerCiv)
} }
stage.addActor(tileMapHolder) stage.addActor(tileMapHolder)
@ -80,8 +80,8 @@ class WorldScreen : CameraStageBaseScreen() {
val tileToCenterOn: Vector2 = val tileToCenterOn: Vector2 =
when { when {
civInfo.cities.isNotEmpty() -> civInfo.getCapital().location currentPlayerCiv.cities.isNotEmpty() -> currentPlayerCiv.getCapital().location
civInfo.getCivUnits().isNotEmpty() -> civInfo.getCivUnits().first().getTile().position currentPlayerCiv.getCivUnits().isNotEmpty() -> currentPlayerCiv.getCivUnits().first().getTile().position
else -> Vector2.Zero else -> Vector2.Zero
} }
tileMapHolder.setCenterPosition(tileToCenterOn) tileMapHolder.setCenterPosition(tileToCenterOn)
@ -97,9 +97,9 @@ class WorldScreen : CameraStageBaseScreen() {
val gameClone = gameInfo.clone() val gameClone = gameInfo.clone()
gameClone.setTransients() gameClone.setTransients()
val cloneCivilization = gameClone.getPlayerCivilization() val cloneCivilization = gameClone.getCurrentPlayerCivilization()
kotlin.concurrent.thread { kotlin.concurrent.thread {
civInfo.happiness = gameClone.getPlayerCivilization().getHappinessForNextTurn().values.sum().toInt() currentPlayerCiv.happiness = gameClone.getCurrentPlayerCivilization().getHappinessForNextTurn().values.sum().toInt()
gameInfo.civilizations.forEach { it.setCitiesConnectedToCapitalTransients() } gameInfo.civilizations.forEach { it.setCitiesConnectedToCapitalTransients() }
} }
@ -127,10 +127,10 @@ class WorldScreen : CameraStageBaseScreen() {
} }
} }
if(gameClone.getPlayerCivilization().getCivUnits().any { it.health<100 }) if(gameClone.getCurrentPlayerCivilization().getCivUnits().any { it.health<100 })
displayTutorials("InjuredUnits") displayTutorials("InjuredUnits")
if(gameClone.getPlayerCivilization().getCivUnits().any { it.name=="Worker" }) if(gameClone.getCurrentPlayerCivilization().getCivUnits().any { it.name=="Worker" })
displayTutorials("WorkerTrained") displayTutorials("WorkerTrained")
updateTechButton(cloneCivilization) updateTechButton(cloneCivilization)
@ -146,17 +146,17 @@ class WorldScreen : CameraStageBaseScreen() {
// if we use the clone, then when we update viewable tiles // if we use the clone, then when we update viewable tiles
// it doesn't update the explored tiles of the civ... need to think about that harder // it doesn't update the explored tiles of the civ... need to think about that harder
// it causes a bug when we move a unit to an unexplored tile (for instance a cavalry unit which can move far) // it causes a bug when we move a unit to an unexplored tile (for instance a cavalry unit which can move far)
tileMapHolder.updateTiles(civInfo) tileMapHolder.updateTiles(currentPlayerCiv)
topBar.update(cloneCivilization) topBar.update(cloneCivilization)
notificationsScroll.update(civInfo.notifications) notificationsScroll.update(currentPlayerCiv.notifications)
notificationsScroll.width = stage.width/3 notificationsScroll.width = stage.width/3
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f, notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
nextTurnButton.y - notificationsScroll.height - 5f) nextTurnButton.y - notificationsScroll.height - 5f)
if(!gameInfo.oneMoreTurnMode && civInfo.victoryManager.hasWon()) game.screen = VictoryScreen() if(!gameInfo.oneMoreTurnMode && currentPlayerCiv.victoryManager.hasWon()) game.screen = VictoryScreen()
else if(civInfo.policies.freePolicies>0) game.screen = PolicyPickerScreen(civInfo) else if(currentPlayerCiv.policies.freePolicies>0) game.screen = PolicyPickerScreen(currentPlayerCiv)
else if(civInfo.greatPeople.freeGreatPeople>0) game.screen = GreatPersonPickerScreen() else if(currentPlayerCiv.greatPeople.freeGreatPeople>0) game.screen = GreatPersonPickerScreen()
} }
private fun updateDiplomacyButton(civInfo: CivilizationInfo) { private fun updateDiplomacyButton(civInfo: CivilizationInfo) {
@ -200,16 +200,16 @@ class WorldScreen : CameraStageBaseScreen() {
private fun createNextTurnButton(): TextButton { private fun createNextTurnButton(): TextButton {
val nextTurnButton = TextButton("Next turn".tr(), CameraStageBaseScreen.skin) val nextTurnButton = TextButton("Next turn".tr(), CameraStageBaseScreen.skin)
nextTurnButton.onClick { nextTurnButton.onClick {
if (civInfo.tech.freeTechs != 0) { if (currentPlayerCiv.tech.freeTechs != 0) {
game.screen = TechPickerScreen(true, civInfo) game.screen = TechPickerScreen(true, currentPlayerCiv)
return@onClick return@onClick
} else if (civInfo.policies.shouldOpenPolicyPicker) { } else if (currentPlayerCiv.policies.shouldOpenPolicyPicker) {
game.screen = PolicyPickerScreen(civInfo) game.screen = PolicyPickerScreen(currentPlayerCiv)
civInfo.policies.shouldOpenPolicyPicker = false currentPlayerCiv.policies.shouldOpenPolicyPicker = false
return@onClick return@onClick
} }
else if (civInfo.tech.currentTechnology() == null && civInfo.cities.isNotEmpty()) { else if (currentPlayerCiv.tech.currentTechnology() == null && currentPlayerCiv.cities.isNotEmpty()) {
game.screen = TechPickerScreen(civInfo) game.screen = TechPickerScreen(currentPlayerCiv)
return@onClick return@onClick
} }
@ -270,24 +270,24 @@ class WorldScreen : CameraStageBaseScreen() {
val shownTutorials = UnCivGame.Current.settings.tutorialsShown val shownTutorials = UnCivGame.Current.settings.tutorialsShown
displayTutorials("NextTurn") displayTutorials("NextTurn")
if("BarbarianEncountered" !in shownTutorials if("BarbarianEncountered" !in shownTutorials
&& civInfo.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } }) && currentPlayerCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } })
displayTutorials("BarbarianEncountered") displayTutorials("BarbarianEncountered")
if(civInfo.cities.size > 2) displayTutorials("SecondCity") if(currentPlayerCiv.cities.size > 2) displayTutorials("SecondCity")
if(civInfo.happiness < 0) displayTutorials("Unhappiness") if(currentPlayerCiv.happiness < 0) displayTutorials("Unhappiness")
if(civInfo.goldenAges.isGoldenAge()) displayTutorials("GoldenAge") if(currentPlayerCiv.goldenAges.isGoldenAge()) displayTutorials("GoldenAge")
if(gameInfo.turns >= 100) displayTutorials("ContactMe") if(gameInfo.turns >= 100) displayTutorials("ContactMe")
val resources = civInfo.getCivResources() val resources = currentPlayerCiv.getCivResources()
if(resources.keys.any { it.resourceType==ResourceType.Luxury }) displayTutorials("LuxuryResource") if(resources.keys.any { it.resourceType==ResourceType.Luxury }) displayTutorials("LuxuryResource")
if(resources.keys.any { it.resourceType==ResourceType.Strategic}) displayTutorials("StrategicResource") if(resources.keys.any { it.resourceType==ResourceType.Strategic}) displayTutorials("StrategicResource")
if("EnemyCity" !in shownTutorials if("EnemyCity" !in shownTutorials
&& civInfo.exploredTiles.asSequence().map { gameInfo.tileMap[it] } && currentPlayerCiv.exploredTiles.asSequence().map { gameInfo.tileMap[it] }
.any { it.isCityCenter() && it.getOwner()!=civInfo }) .any { it.isCityCenter() && it.getOwner()!=currentPlayerCiv })
displayTutorials("EnemyCity") displayTutorials("EnemyCity")
if("Enables construction of Spaceship parts" in civInfo.getBuildingUniques()) if("Enables construction of Spaceship parts" in currentPlayerCiv.getBuildingUniques())
displayTutorials("ApolloProgram") displayTutorials("ApolloProgram")
if(civInfo.getCivUnits().any { it.type == UnitType.Siege }) if(currentPlayerCiv.getCivUnits().any { it.type == UnitType.Siege })
displayTutorials("SiegeUnitTrained") displayTutorials("SiegeUnitTrained")
if(civInfo.tech.getUniques().contains("Enables embarkation for land units")) if(currentPlayerCiv.tech.getUniques().contains("Enables embarkation for land units"))
displayTutorials("CanEmbark") displayTutorials("CanEmbark")
shouldUpdate=false shouldUpdate=false

View File

@ -58,7 +58,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
val resourceTable = Table() val resourceTable = Table()
resourceTable.defaults().pad(5f) resourceTable.defaults().pad(5f)
val revealedStrategicResources = GameBasics.TileResources.values val revealedStrategicResources = GameBasics.TileResources.values
.filter { it.resourceType == ResourceType.Strategic } // && playerCivInfo.tech.isResearched(it.revealedBy!!) } .filter { it.resourceType == ResourceType.Strategic } // && currentPlayerCivInfo.tech.isResearched(it.revealedBy!!) }
for (resource in revealedStrategicResources) { for (resource in revealedStrategicResources) {
val resourceImage = ImageGetter.getResourceImage(resource.name,20f) val resourceImage = ImageGetter.getResourceImage(resource.name,20f)
resourceImages[resource.name] = resourceImage resourceImages[resource.name] = resourceImage

View File

@ -18,7 +18,7 @@ import kotlin.math.max
class BattleTable(val worldScreen: WorldScreen): Table() { class BattleTable(val worldScreen: WorldScreen): Table() {
private val battle = Battle(worldScreen.civInfo.gameInfo) private val battle = Battle(worldScreen.currentPlayerCiv.gameInfo)
init{ init{
skin = CameraStageBaseScreen.skin skin = CameraStageBaseScreen.skin
background = ImageGetter.getBackground(ImageGetter.getBlue()) background = ImageGetter.getBackground(ImageGetter.getBlue())
@ -45,7 +45,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
val defender: ICombatant? = Battle(worldScreen.gameInfo).getMapCombatantOfTile(selectedTile) val defender: ICombatant? = Battle(worldScreen.gameInfo).getMapCombatantOfTile(selectedTile)
if(defender==null || if(defender==null ||
defender.getCivilization()==worldScreen.civInfo defender.getCivilization()==worldScreen.currentPlayerCiv
|| !(UnCivGame.Current.viewEntireMapForDebug || !(UnCivGame.Current.viewEntireMapForDebug
|| attacker.getCivilization().exploredTiles.contains(selectedTile.position))) { || attacker.getCivilization().exploredTiles.contains(selectedTile.position))) {
hide() hide()

View File

@ -16,7 +16,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
internal fun updateTileTable(tile: TileInfo) { internal fun updateTileTable(tile: TileInfo) {
clearChildren() clearChildren()
val civInfo = worldScreen.civInfo val civInfo = worldScreen.currentPlayerCiv
columnDefaults(0).padRight(10f) columnDefaults(0).padRight(10f)
if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) { if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
@ -34,7 +34,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
table.pad(10f) table.pad(10f)
table.defaults().pad(2f) table.defaults().pad(2f)
for (entry in tile.getTileStats(worldScreen.civInfo).toHashMap().filterNot { it.value == 0f }) { for (entry in tile.getTileStats(worldScreen.currentPlayerCiv).toHashMap().filterNot { it.value == 0f }) {
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right) table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left) table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left)
table.row() table.row()

View File

@ -33,7 +33,7 @@ class WorldScreenOptionsTable internal constructor() : PopupTable() {
addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() } addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
addButton("Social policies".tr()){ addButton("Social policies".tr()){
UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getPlayerCivilization()) UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getCurrentPlayerCivilization())
} }

View File

@ -16,7 +16,7 @@ class IdleUnitButton (internal val unitTable: UnitTable,
val image = ImageGetter.getImage("OtherIcons/BackArrow") val image = ImageGetter.getImage("OtherIcons/BackArrow")
fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values
.filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.civInfo.civName } .filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.currentPlayerCiv.civName }
init { init {
val imageSize = 25f val imageSize = 25f

View File

@ -40,7 +40,7 @@ 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.currentPlayerCiv) { // 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
@ -136,11 +136,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
currentlyExecutingAction = null currentlyExecutingAction = null
} }
else if(selectedTile.militaryUnit!=null && selectedTile.militaryUnit!!.civInfo == worldScreen.civInfo else if(selectedTile.militaryUnit!=null && selectedTile.militaryUnit!!.civInfo == worldScreen.currentPlayerCiv
&& selectedUnit!=selectedTile.militaryUnit) && selectedUnit!=selectedTile.militaryUnit)
selectedUnit = selectedTile.militaryUnit selectedUnit = selectedTile.militaryUnit
else if (selectedTile.civilianUnit!=null && selectedTile.civilianUnit!!.civInfo == worldScreen.civInfo else if (selectedTile.civilianUnit!=null && selectedTile.civilianUnit!!.civInfo == worldScreen.currentPlayerCiv
&& selectedUnit!=selectedTile.civilianUnit) && selectedUnit!=selectedTile.civilianUnit)
selectedUnit = selectedTile.civilianUnit selectedUnit = selectedTile.civilianUnit