Added display of Human / AI for othe civs

This commit is contained in:
Yair Morgenstern 2019-08-08 19:44:05 +03:00
parent 05e4e33a3d
commit 327eea7b13
4 changed files with 42 additions and 28 deletions

View File

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

View File

@ -167,6 +167,8 @@ class CivilizationInfo {
fun containsBuildingUnique(unique:String) = cities.any { it.containsBuildingUnique(unique) } fun containsBuildingUnique(unique:String) = cities.any { it.containsBuildingUnique(unique) }
//region Units
fun getCivUnits(): List<MapUnit> = units fun getCivUnits(): List<MapUnit> = units
fun addUnit(mapUnit: MapUnit, updateCivInfo:Boolean=true){ fun addUnit(mapUnit: MapUnit, updateCivInfo:Boolean=true){
@ -194,9 +196,6 @@ class CivilizationInfo {
fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() } fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() }
fun shouldOpenTechPicker() = tech.freeTechs != 0
|| tech.currentTechnology()==null && cities.isNotEmpty()
fun shouldGoToDueUnit() = UnCivGame.Current.settings.checkForDueUnits && getDueUnits().isNotEmpty() fun shouldGoToDueUnit() = UnCivGame.Current.settings.checkForDueUnits && getDueUnits().isNotEmpty()
fun getNextDueUnit(): MapUnit? { fun getNextDueUnit(): MapUnit? {
@ -208,6 +207,12 @@ class CivilizationInfo {
} }
return null return null
} }
//endregion
fun shouldOpenTechPicker() = tech.freeTechs != 0
|| tech.currentTechnology()==null && cities.isNotEmpty()
fun getEquivalentBuilding(buildingName:String): Building { fun getEquivalentBuilding(buildingName:String): Building {
val baseBuilding = GameBasics.Buildings[buildingName]!!.getBaseBuilding() val baseBuilding = GameBasics.Buildings[buildingName]!!.getBaseBuilding()
@ -232,7 +237,7 @@ class CivilizationInfo {
override fun toString(): String {return civName} // for debug override fun toString(): String {return civName} // for debug
fun isDefeated()= cities.isEmpty() && (citiesCreated > 0 || !getCivUnits().any{it.name== Constants.settler}) fun isDefeated()= cities.isEmpty() && (citiesCreated > 0 || !getCivUnits().any {it.name== Constants.settler})
fun getEra(): TechEra { fun getEra(): TechEra {
val maxEraOfTech = tech.researchedTechnologies val maxEraOfTech = tech.researchedTechnologies
@ -251,6 +256,16 @@ class CivilizationInfo {
} }
fun isAtWar() = diplomacy.values.any { it.diplomaticStatus== DiplomaticStatus.War && !it.otherCiv().isDefeated() } fun isAtWar() = diplomacy.values.any { it.diplomaticStatus== DiplomaticStatus.War && !it.otherCiv().isDefeated() }
fun getLeaderDisplayName(): String {
var leaderName = getTranslatedNation().getLeaderDisplayName()
if (playerType == PlayerType.AI)
leaderName += " (" + "AI".tr() + ")"
else if (gameInfo.civilizations.count { it.playerType == PlayerType.Human } > 1)
leaderName += " (" + "Human".tr() + " - " + "Hotseat".tr() + ")"
else leaderName += " (" + "Human".tr() + " - " + UnCivGame.Current.settings.userName + ")"
return leaderName
}
//endregion //endregion
//region state-changing functions //region state-changing functions

View File

@ -95,7 +95,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
val diplomacyTable = Table() val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f) diplomacyTable.defaults().pad(10f)
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel()).row() diplomacyTable.add(otherCiv.getLeaderDisplayName().toLabel().setFontSize(24)).row()
diplomacyTable.add(("Type: " + otherCiv.getCityStateType().toString()).toLabel()).row() diplomacyTable.add(("Type: " + otherCiv.getCityStateType().toString()).toLabel()).row()
diplomacyTable.add(("Influence: " + otherCivDiplomacyManager.influence.toInt() + "/30").toLabel()).row() diplomacyTable.add(("Influence: " + otherCivDiplomacyManager.influence.toInt() + "/30").toLabel()).row()
@ -161,8 +161,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
val diplomacyTable = Table() val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f) diplomacyTable.defaults().pad(10f)
diplomacyTable.add(otherCiv.getLeaderDisplayName().toLabel().setFontSize(24)).row()
val translatedNation = otherCiv.getTranslatedNation() val translatedNation = otherCiv.getTranslatedNation()
diplomacyTable.add(translatedNation.getLeaderDisplayName().toLabel().setFontSize(24)).row()
if(otherCivDiplomacyManager.relationshipLevel()<=RelationshipLevel.Enemy) if(otherCivDiplomacyManager.relationshipLevel()<=RelationshipLevel.Enemy)
diplomacyTable.add(translatedNation.hateHello.toLabel()).row() diplomacyTable.add(translatedNation.hateHello.toLabel()).row()
else else
@ -328,7 +328,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
private fun setRightSideFlavorText(otherCiv: CivilizationInfo, flavorText:String, response: String){ private fun setRightSideFlavorText(otherCiv: CivilizationInfo, flavorText:String, response: String){
val diplomacyTable = Table() val diplomacyTable = Table()
diplomacyTable.defaults().pad(10f) diplomacyTable.defaults().pad(10f)
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel()) diplomacyTable.add(otherCiv.getLeaderDisplayName().toLabel())
diplomacyTable.addSeparator() diplomacyTable.addSeparator()
diplomacyTable.add(flavorText.toLabel()).row() diplomacyTable.add(flavorText.toLabel()).row()

View File

@ -3,8 +3,8 @@ package com.unciv.ui.worldscreen
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.logic.civilization.AlertType import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.PopupAlert import com.unciv.logic.civilization.PopupAlert
import com.unciv.models.gamebasics.Nation
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.addSeparator import com.unciv.ui.utils.addSeparator
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
@ -22,8 +22,8 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
return button return button
} }
fun addLeaderName(translatedNation: Nation){ fun addLeaderName(civInfo : CivilizationInfo){
val otherCivLeaderName = translatedNation.getLeaderDisplayName() val otherCivLeaderName = civInfo.getLeaderDisplayName()
add(otherCivLeaderName.toLabel()) add(otherCivLeaderName.toLabel())
addSeparator() addSeparator()
} }
@ -32,29 +32,29 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
when(popupAlert.type){ when(popupAlert.type){
AlertType.WarDeclaration -> { AlertType.WarDeclaration -> {
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation() val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
addLeaderName(translatedNation) addLeaderName(civInfo)
addGoodSizedLabel(translatedNation.declaringWar).row() addGoodSizedLabel(civInfo.getTranslatedNation().declaringWar).row()
val responseTable = Table() val responseTable = Table()
responseTable.add(getCloseButton("You'll pay for this!")) responseTable.add(getCloseButton("You'll pay for this!"))
responseTable.add(getCloseButton("Very well.")) responseTable.add(getCloseButton("Very well."))
add(responseTable) add(responseTable)
} }
AlertType.Defeated -> { AlertType.Defeated -> {
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation() val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
addLeaderName(translatedNation) addLeaderName(civInfo)
addGoodSizedLabel(translatedNation.defeated).row() addGoodSizedLabel(civInfo.getTranslatedNation().defeated).row()
add(getCloseButton("Farewell.")) add(getCloseButton("Farewell."))
} }
AlertType.FirstContact -> { AlertType.FirstContact -> {
val civ = worldScreen.gameInfo.getCivilization(popupAlert.value) val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
val translatedNation = civ.getTranslatedNation() val translatedNation = civInfo.getTranslatedNation()
if (civ.isCityState()) { if (civInfo.isCityState()) {
addLeaderName(translatedNation) addLeaderName(civInfo)
addGoodSizedLabel("We have encountered the City-State of [${translatedNation.getNameTranslation()}]!").row() addGoodSizedLabel("We have encountered the City-State of [${translatedNation.getNameTranslation()}]!").row()
add(getCloseButton("Excellent!")) add(getCloseButton("Excellent!"))
} else { } else {
addLeaderName(translatedNation) addLeaderName(civInfo)
addGoodSizedLabel(translatedNation.introduction).row() addGoodSizedLabel(translatedNation.introduction).row()
add(getCloseButton("A pleasure to meet you.")) add(getCloseButton("A pleasure to meet you."))
} }
@ -69,8 +69,8 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
}) })
} }
AlertType.BorderConflict -> { AlertType.BorderConflict -> {
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation() val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
addLeaderName(translatedNation) addLeaderName(civInfo)
addGoodSizedLabel("Remove your troops in our border immediately!").row() addGoodSizedLabel("Remove your troops in our border immediately!").row()
val responseTable = Table() val responseTable = Table()
responseTable.add(getCloseButton("Sorry.")) responseTable.add(getCloseButton("Sorry."))
@ -81,7 +81,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value) val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value)
val playerDiploManager = worldScreen.viewingCiv.getDiplomacyManager(otherciv) val playerDiploManager = worldScreen.viewingCiv.getDiplomacyManager(otherciv)
val translatedNation = otherciv.getTranslatedNation() val translatedNation = otherciv.getTranslatedNation()
addLeaderName(translatedNation) addLeaderName(otherciv)
addGoodSizedLabel("Please don't settle new cities near us.").row() addGoodSizedLabel("Please don't settle new cities near us.").row()
add(getCloseButton("Very well, we shall look for new lands to settle."){ add(getCloseButton("Very well, we shall look for new lands to settle."){
playerDiploManager.agreeNotToSettleNear() playerDiploManager.agreeNotToSettleNear()
@ -92,8 +92,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
} }
AlertType.CitySettledNearOtherCivDespiteOurPromise -> { AlertType.CitySettledNearOtherCivDespiteOurPromise -> {
val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value) val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value)
val translatedNation = otherciv.getTranslatedNation() addLeaderName(otherciv)
addLeaderName(translatedNation)
addGoodSizedLabel("We noticed your new city near our borders, despite your promise. This will have....implications.").row() addGoodSizedLabel("We noticed your new city near our borders, despite your promise. This will have....implications.").row()
add(getCloseButton("Very well.")) add(getCloseButton("Very well."))
} }