mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Merge pull request #8623 from Gualdimar/politicsRealtion
Fixed diplomacy exception
This commit is contained in:
commit
be054a98fd
@ -317,7 +317,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
/** Returns only undefeated civs, aka the ones we care about */
|
/** Returns only undefeated civs, aka the ones we care about */
|
||||||
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }.filter { !it.isDefeated() }
|
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }.filter { !it.isDefeated() }
|
||||||
fun knows(otherCivName: String) = (civName == otherCivName || diplomacy.containsKey(otherCivName))
|
fun knows(otherCivName: String) = diplomacy.containsKey(otherCivName)
|
||||||
fun knows(otherCiv: Civilization) = knows(otherCiv.civName)
|
fun knows(otherCiv: Civilization) = knows(otherCiv.civName)
|
||||||
|
|
||||||
fun getCapital() = cities.firstOrNull { it.isCapital() }
|
fun getCapital() = cities.firstOrNull { it.isCapital() }
|
||||||
|
@ -168,7 +168,7 @@ class GlobalPoliticsOverviewTable (
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getCivName(otherciv: Civilization): String {
|
private fun getCivName(otherciv: Civilization): String {
|
||||||
if (viewingPlayer.knows(otherciv)){
|
if (viewingPlayer.knows(otherciv) || otherciv.civName == viewingPlayer.civName) {
|
||||||
return otherciv.civName
|
return otherciv.civName
|
||||||
}
|
}
|
||||||
return "an unknown civilization"
|
return "an unknown civilization"
|
||||||
@ -177,11 +177,11 @@ class GlobalPoliticsOverviewTable (
|
|||||||
private fun getPoliticsOfCivTable(civ: Civilization): Table {
|
private fun getPoliticsOfCivTable(civ: Civilization): Table {
|
||||||
val politicsTable = Table(skin)
|
val politicsTable = Table(skin)
|
||||||
|
|
||||||
|
if (!viewingPlayer.knows(civ) && civ.civName != viewingPlayer.civName)
|
||||||
|
return politicsTable
|
||||||
|
|
||||||
// wars
|
// wars
|
||||||
for (otherCiv in civ.getKnownCivs()) {
|
for (otherCiv in civ.getKnownCivs()) {
|
||||||
if (!viewingPlayer.knows(civ))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if(civ.isAtWarWith(otherCiv)) {
|
if(civ.isAtWarWith(otherCiv)) {
|
||||||
println(getCivName(otherCiv))
|
println(getCivName(otherCiv))
|
||||||
val warText = "At war with [${getCivName(otherCiv)}]".toLabel()
|
val warText = "At war with [${getCivName(otherCiv)}]".toLabel()
|
||||||
@ -193,9 +193,6 @@ class GlobalPoliticsOverviewTable (
|
|||||||
|
|
||||||
// declaration of friendships
|
// declaration of friendships
|
||||||
for (otherCiv in civ.getKnownCivs()) {
|
for (otherCiv in civ.getKnownCivs()) {
|
||||||
if (!viewingPlayer.knows(otherCiv))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if(civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.DeclarationOfFriendship) == true) {
|
if(civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.DeclarationOfFriendship) == true) {
|
||||||
val friendText = "Friends with [${getCivName(otherCiv)}]".toLabel()
|
val friendText = "Friends with [${getCivName(otherCiv)}]".toLabel()
|
||||||
friendText.color = Color.GREEN
|
friendText.color = Color.GREEN
|
||||||
@ -208,9 +205,6 @@ class GlobalPoliticsOverviewTable (
|
|||||||
|
|
||||||
// denounced civs
|
// denounced civs
|
||||||
for (otherCiv in civ.getKnownCivs()) {
|
for (otherCiv in civ.getKnownCivs()) {
|
||||||
if (!viewingPlayer.knows(otherCiv))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if(civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.Denunciation) == true) {
|
if(civ.diplomacy[otherCiv.civName]?.hasFlag(DiplomacyFlags.Denunciation) == true) {
|
||||||
val denouncedText = "Denounced [${getCivName(otherCiv)}]".toLabel()
|
val denouncedText = "Denounced [${getCivName(otherCiv)}]".toLabel()
|
||||||
denouncedText.color = Color.RED
|
denouncedText.color = Color.RED
|
||||||
@ -223,9 +217,6 @@ class GlobalPoliticsOverviewTable (
|
|||||||
|
|
||||||
//allied CS
|
//allied CS
|
||||||
for (cityState in gameInfo.getAliveCityStates()) {
|
for (cityState in gameInfo.getAliveCityStates()) {
|
||||||
if (!viewingPlayer.knows(cityState))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if (cityState.diplomacy[civ.civName]?.relationshipLevel() == RelationshipLevel.Ally) {
|
if (cityState.diplomacy[civ.civName]?.relationshipLevel() == RelationshipLevel.Ally) {
|
||||||
val alliedText = "Allied with [${getCivName(cityState)}]".toLabel()
|
val alliedText = "Allied with [${getCivName(cityState)}]".toLabel()
|
||||||
alliedText.color = Color.GREEN
|
alliedText.color = Color.GREEN
|
||||||
|
@ -89,7 +89,7 @@ class ReligionOverviewTab(
|
|||||||
val existingReligions: List<Religion> = gameInfo.civilizations.mapNotNull { it.religionManager.religion }
|
val existingReligions: List<Religion> = gameInfo.civilizations.mapNotNull { it.religionManager.religion }
|
||||||
for (religion in existingReligions) {
|
for (religion in existingReligions) {
|
||||||
val image = if (religion.isPantheon()) {
|
val image = if (religion.isPantheon()) {
|
||||||
if (viewingPlayer.knows(religion.foundingCivName))
|
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
||||||
ImageGetter.getNationPortrait(religion.getFounder().nation, 60f)
|
ImageGetter.getNationPortrait(religion.getFounder().nation, 60f)
|
||||||
else
|
else
|
||||||
ImageGetter.getRandomNationPortrait(60f)
|
ImageGetter.getRandomNationPortrait(60f)
|
||||||
@ -136,7 +136,7 @@ class ReligionOverviewTab(
|
|||||||
statsTable.add(religion.getReligionDisplayName().toLabel()).right().row()
|
statsTable.add(religion.getReligionDisplayName().toLabel()).right().row()
|
||||||
statsTable.add("Founding Civ:".toLabel())
|
statsTable.add("Founding Civ:".toLabel())
|
||||||
val foundingCivName =
|
val foundingCivName =
|
||||||
if (viewingPlayer.knows(religion.foundingCivName))
|
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
||||||
religion.foundingCivName
|
religion.foundingCivName
|
||||||
else Constants.unknownNationName
|
else Constants.unknownNationName
|
||||||
statsTable.add(foundingCivName.toLabel()).right().row()
|
statsTable.add(foundingCivName.toLabel()).right().row()
|
||||||
|
@ -217,7 +217,7 @@ class DiplomacyScreen(
|
|||||||
var ally = otherCiv.getAllyCiv()
|
var ally = otherCiv.getAllyCiv()
|
||||||
if (ally != null) {
|
if (ally != null) {
|
||||||
val allyInfluence = otherCiv.getDiplomacyManager(ally).getInfluence().toInt()
|
val allyInfluence = otherCiv.getDiplomacyManager(ally).getInfluence().toInt()
|
||||||
if (!viewingCiv.knows(ally))
|
if (!viewingCiv.knows(ally) && ally != viewingCiv.civName)
|
||||||
ally = "Unknown civilization"
|
ally = "Unknown civilization"
|
||||||
diplomacyTable
|
diplomacyTable
|
||||||
.add("Ally: [$ally] with [$allyInfluence] Influence".toLabel())
|
.add("Ally: [$ally] with [$allyInfluence] Influence".toLabel())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user