Can no longer see diplomatic staus of civs you haven't met in Diplomacy Overview

This commit is contained in:
Yair Morgenstern 2018-12-06 16:12:31 +02:00
parent 37dc952fe6
commit 7cacff0a37
4 changed files with 54 additions and 35 deletions

View File

@ -292,7 +292,7 @@ class CivilizationInfo {
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 civInfo cityInfo.civInfo = this // must be before the city's setTransients because it depends on the tilemap, that comes from the playerCivInfo
cityInfo.setTransients() cityInfo.setTransients()
} }
setCitiesConnectedToCapitalTransients() setCitiesConnectedToCapitalTransients()

View File

@ -20,7 +20,7 @@ import kotlin.math.roundToInt
class EmpireOverviewScreen : CameraStageBaseScreen(){ class EmpireOverviewScreen : CameraStageBaseScreen(){
val civInfo = UnCivGame.Current.gameInfo.getPlayerCivilization() val playerCivInfo = UnCivGame.Current.gameInfo.getPlayerCivilization()
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) }
@ -91,7 +91,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 civInfo.diplomacy.values) for(diplomacy in playerCivInfo.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()
@ -100,7 +100,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(civInfo,trade.ourOffers, trade.theirOffers.size)) generalTable.add(createOffersTable(playerCivInfo,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
} }
@ -127,12 +127,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 civInfo.getHappinessForNextTurn()) { for (entry in playerCivInfo.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(civInfo.getHappinessForNextTurn().values.sum().toString()) happinessTable.add(playerCivInfo.getHappinessForNextTurn().values.sum().toString())
happinessTable.pack() happinessTable.pack()
return happinessTable return happinessTable
} }
@ -143,7 +143,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 civInfo.getStatMapForNextTurn()) { for (entry in playerCivInfo.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()
@ -159,9 +159,9 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun getGreatPeopleTable(): Table { private fun getGreatPeopleTable(): Table {
val greatPeopleTable = Table(skin) val greatPeopleTable = Table(skin)
val greatPersonPoints = civInfo.greatPeople.greatPersonPoints.toHashMap() val greatPersonPoints = playerCivInfo.greatPeople.greatPersonPoints.toHashMap()
val greatPersonPointsPerTurn = civInfo.getGreatPersonPointsForNextTurn().toHashMap() val greatPersonPointsPerTurn = playerCivInfo.getGreatPersonPointsForNextTurn().toHashMap()
val pointsToGreatPerson = civInfo.greatPeople.pointsForNextGreatPerson val pointsToGreatPerson = playerCivInfo.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()
@ -170,7 +170,7 @@ 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 = civInfo.greatPeople.statToGreatPersonMapping val mapping = playerCivInfo.greatPeople.statToGreatPersonMapping
for(entry in mapping){ for(entry in mapping){
greatPeopleTable.add(entry.value) greatPeopleTable.add(entry.value)
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson) greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
@ -203,7 +203,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 civInfo.cities) { for (city in playerCivInfo.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)
@ -225,13 +225,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(civInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add()//an intended empty space cityInfoTableTotal.add()//an intended empty space
cityInfoTableTotal.add(civInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add(civInfo.cities.sumBy { it.cityStats.currentCityStats.science.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(playerCivInfo.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(civInfo.cities.sumBy { it.cityStats.currentCityStats.culture.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.culture.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add(civInfo.cities.sumBy { it.cityStats.currentCityStats.happiness.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(playerCivInfo.cities.sumBy { it.cityStats.currentCityStats.happiness.toInt() }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.pack() cityInfoTableTotal.pack()
@ -260,7 +260,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
table.row() table.row()
table.addSeparator() table.addSeparator()
for(unit in civInfo.getCivUnits()){ for(unit in playerCivInfo.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()
@ -274,8 +274,12 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
return table return table
} }
fun playerKnows(civ:CivilizationInfo) = civ.isPlayerCivilization() ||
playerCivInfo.diplomacy.containsKey(civ.civName)
fun createDiplomacyGroup(): Group { fun createDiplomacyGroup(): Group {
val relevantCivs = civInfo.gameInfo.civilizations.filter { !it.isBarbarianCivilization() } val relevantCivs = playerCivInfo.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)
@ -285,10 +289,19 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
val civGroup = Table() val civGroup = Table()
civGroup.background = ImageGetter.getDrawable("OtherIcons/civTableBackground.png") val civGroupBackground = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
.tint(civ.getNation().getColor())
val label = Label(civ.civName, CameraStageBaseScreen.skin) val label = Label(civ.civName, CameraStageBaseScreen.skin)
label.setFontColor(civ.getNation().getSecondaryColor())
if(playerKnows(civ)) {
civGroup.background = civGroupBackground.tint(civ.getNation().getColor())
label.setFontColor(civ.getNation().getSecondaryColor())
}
else {
civGroup.background = civGroupBackground.tint(Color.DARK_GRAY)
label.setText("???")
}
civGroup.add(label).pad(10f) civGroup.add(label).pad(10f)
civGroup.pack() civGroup.pack()
@ -300,8 +313,9 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
group.addActor(civGroup) group.addActor(civGroup)
} }
for(civ in relevantCivs)
for(diplomacy in civ.diplomacy.values.filter { !it.otherCiv().isBarbarianCivilization() }){ for(civ in relevantCivs.filter { playerKnows(it) })
for(diplomacy in civ.diplomacy.values.filter { !it.otherCiv().isBarbarianCivilization() && playerKnows(it.otherCiv()) }){
val civGroup = civGroups[civ]!! val civGroup = civGroups[civ]!!
val otherCivGroup = civGroups[diplomacy.otherCiv()]!! val otherCivGroup = civGroups[diplomacy.otherCiv()]!!

View File

@ -12,7 +12,9 @@ import com.unciv.ui.utils.tr
class VictoryScreen : PickerScreen() { class VictoryScreen : PickerScreen() {
val civInfo = UnCivGame.Current.gameInfo.getPlayerCivilization() // todo translate this screen
val playerCivInfo = UnCivGame.Current.gameInfo.getPlayerCivilization()
init { init {
topTable.skin=skin topTable.skin=skin
@ -31,17 +33,17 @@ class VictoryScreen : PickerScreen() {
rightSideButton.isVisible=false rightSideButton.isVisible=false
if(civInfo.scienceVictory.hasWon()){ if(playerCivInfo.scienceVictory.hasWon()){
descriptionLabel.setText("You have won a scientific victory!") descriptionLabel.setText("You have won a scientific victory!")
won() won()
} }
if(civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 3){ if(playerCivInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 3){
descriptionLabel.setText("You have won a cultural victory!") descriptionLabel.setText("You have won a cultural victory!")
won() won()
} }
if(civInfo.gameInfo.civilizations.all { it.isPlayerCivilization() || it.isDefeated() }){ if(playerCivInfo.gameInfo.civilizations.all { it.isPlayerCivilization() || it.isDefeated() }){
descriptionLabel.setText("You have won a conquest victory!") descriptionLabel.setText("You have won a conquest victory!")
won() won()
} }
@ -58,9 +60,9 @@ class VictoryScreen : PickerScreen() {
fun scienceVictoryColumn():Table{ fun scienceVictoryColumn():Table{
val t = Table() val t = Table()
t.defaults().pad(5f) t.defaults().pad(5f)
t.add(getMilestone("Built Apollo Program",civInfo.getBuildingUniques().contains("Enables construction of Spaceship parts"))).row() t.add(getMilestone("Built Apollo Program",playerCivInfo.getBuildingUniques().contains("Enables construction of Spaceship parts"))).row()
val scienceVictory = civInfo.scienceVictory val scienceVictory = playerCivInfo.scienceVictory
for (key in scienceVictory.requiredParts.keys) for (key in scienceVictory.requiredParts.keys)
for (i in 0 until scienceVictory.requiredParts[key]!!) for (i in 0 until scienceVictory.requiredParts[key]!!)
@ -74,7 +76,7 @@ class VictoryScreen : PickerScreen() {
t.defaults().pad(5f) t.defaults().pad(5f)
for(branch in GameBasics.PolicyBranches.values) { for(branch in GameBasics.PolicyBranches.values) {
val finisher = branch.policies.last().name val finisher = branch.policies.last().name
t.add(getMilestone(finisher, civInfo.policies.isAdopted(finisher))).row() t.add(getMilestone(finisher, playerCivInfo.policies.isAdopted(finisher))).row()
} }
return t return t
} }
@ -82,9 +84,12 @@ class VictoryScreen : PickerScreen() {
fun conquestVictoryColumn():Table{ fun conquestVictoryColumn():Table{
val t=Table() val t=Table()
t.defaults().pad(5f) t.defaults().pad(5f)
for (civ in civInfo.gameInfo.civilizations){ for (civ in playerCivInfo.gameInfo.civilizations) {
if(civ.isPlayerCivilization() || civ.isBarbarianCivilization()) continue if (civ.isPlayerCivilization() || civ.isBarbarianCivilization()) continue
t.add(getMilestone("Destroy "+civ.civName, civ.isDefeated())).row() val civName =
if (playerCivInfo.diplomacy.containsKey(civ.civName)) civ.civName
else "???"
t.add(getMilestone("Destroy $civName", civ.isDefeated())).row()
} }
return t return t
} }

View File

@ -57,7 +57,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 } // && civInfo.tech.isResearched(it.revealedBy!!) } .filter { it.resourceType == ResourceType.Strategic } // && playerCivInfo.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