mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-22 12:38:29 +07:00
chore: removed city state functions from civinfo
This commit is contained in:
parent
bdc239fd34
commit
2bd07652b1
@ -272,11 +272,11 @@ object NextTurnAutomation {
|
|||||||
private fun tryGainInfluence(civInfo: CivilizationInfo, cityState: CivilizationInfo) {
|
private fun tryGainInfluence(civInfo: CivilizationInfo, cityState: CivilizationInfo) {
|
||||||
if (civInfo.gold < 250) return // save up
|
if (civInfo.gold < 250) return // save up
|
||||||
if (cityState.getDiplomacyManager(civInfo).getInfluence() < 20) {
|
if (cityState.getDiplomacyManager(civInfo).getInfluence() < 20) {
|
||||||
cityState.receiveGoldGift(civInfo, 250)
|
cityState.cityStateFunctions.receiveGoldGift(civInfo, 250)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (civInfo.gold < 500) return // it's not worth it to invest now, wait until you have enough for 2
|
if (civInfo.gold < 500) return // it's not worth it to invest now, wait until you have enough for 2
|
||||||
cityState.receiveGoldGift(civInfo, 500)
|
cityState.cityStateFunctions.receiveGoldGift(civInfo, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ object NextTurnAutomation {
|
|||||||
|
|
||||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
|
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
|
||||||
for (cityState in civInfo.getKnownCivs()
|
for (cityState in civInfo.getKnownCivs()
|
||||||
.filter { it.isCityState() && it.cityStateFunctions.canGiveStat(Stat.Culture) }) {
|
.filter { it.isCityState() && it.cityStateFunctions.canProvideStat(Stat.Culture) }) {
|
||||||
val diploManager = cityState.getDiplomacyManager(civInfo)
|
val diploManager = cityState.getDiplomacyManager(civInfo)
|
||||||
if (diploManager.getInfluence() < 40) { // we want to gain influence with them
|
if (diploManager.getInfluence() < 40) { // we want to gain influence with them
|
||||||
tryGainInfluence(civInfo, cityState)
|
tryGainInfluence(civInfo, cityState)
|
||||||
@ -326,10 +326,10 @@ object NextTurnAutomation {
|
|||||||
private fun valueCityStateAlliance(civInfo: CivilizationInfo, cityState: CivilizationInfo): Int {
|
private fun valueCityStateAlliance(civInfo: CivilizationInfo, cityState: CivilizationInfo): Int {
|
||||||
var value = 0
|
var value = 0
|
||||||
|
|
||||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && cityState.canGiveStat(Stat.Culture)) {
|
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && cityState.cityStateFunctions.canProvideStat(Stat.Culture)) {
|
||||||
value += 10
|
value += 10
|
||||||
}
|
}
|
||||||
else if (civInfo.wantsToFocusOn(Victory.Focus.Science) && cityState.canGiveStat(Stat.Science)) {
|
else if (civInfo.wantsToFocusOn(Victory.Focus.Science) && cityState.cityStateFunctions.canProvideStat(Stat.Science)) {
|
||||||
// In case someone mods this in
|
// In case someone mods this in
|
||||||
value += 10
|
value += 10
|
||||||
}
|
}
|
||||||
@ -346,10 +346,10 @@ object NextTurnAutomation {
|
|||||||
else if (civInfo.wantsToFocusOn(Victory.Focus.CityStates)) {
|
else if (civInfo.wantsToFocusOn(Victory.Focus.CityStates)) {
|
||||||
value += 5 // Generally be friendly
|
value += 5 // Generally be friendly
|
||||||
}
|
}
|
||||||
if (civInfo.getHappiness() < 5 && cityState.canGiveStat(Stat.Happiness)) {
|
if (civInfo.getHappiness() < 5 && cityState.cityStateFunctions.canProvideStat(Stat.Happiness)) {
|
||||||
value += 10 - civInfo.getHappiness()
|
value += 10 - civInfo.getHappiness()
|
||||||
}
|
}
|
||||||
if (civInfo.getHappiness() > 5 && cityState.canGiveStat(Stat.Food)) {
|
if (civInfo.getHappiness() > 5 && cityState.cityStateFunctions.canProvideStat(Stat.Food)) {
|
||||||
value += 5
|
value += 5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,12 +380,12 @@ object NextTurnAutomation {
|
|||||||
for (state in civInfo.getKnownCivs().filter{!it.isDefeated() && it.isCityState()}) {
|
for (state in civInfo.getKnownCivs().filter{!it.isDefeated() && it.isCityState()}) {
|
||||||
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)
|
val diplomacyManager = state.getDiplomacyManager(civInfo.civName)
|
||||||
if(diplomacyManager.relationshipLevel() >= RelationshipLevel.Friend
|
if(diplomacyManager.relationshipLevel() >= RelationshipLevel.Friend
|
||||||
&& state.otherCivCanPledgeProtection(civInfo))
|
&& state.cityStateFunctions.otherCivCanPledgeProtection(civInfo))
|
||||||
{
|
{
|
||||||
state.addProtectorCiv(civInfo)
|
state.cityStateFunctions.addProtectorCiv(civInfo)
|
||||||
} else if (diplomacyManager.relationshipLevel() < RelationshipLevel.Friend
|
} else if (diplomacyManager.relationshipLevel() < RelationshipLevel.Friend
|
||||||
&& state.otherCivCanWithdrawProtection(civInfo)) {
|
&& state.cityStateFunctions.otherCivCanWithdrawProtection(civInfo)) {
|
||||||
state.removeProtectorCiv(civInfo)
|
state.cityStateFunctions.removeProtectorCiv(civInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,8 +396,8 @@ object NextTurnAutomation {
|
|||||||
if(diplomacyManager.relationshipLevel() < RelationshipLevel.Friend
|
if(diplomacyManager.relationshipLevel() < RelationshipLevel.Friend
|
||||||
&& diplomacyManager.diplomaticStatus == DiplomaticStatus.Peace
|
&& diplomacyManager.diplomaticStatus == DiplomaticStatus.Peace
|
||||||
&& valueCityStateAlliance(civInfo, state) <= 0
|
&& valueCityStateAlliance(civInfo, state) <= 0
|
||||||
&& state.getTributeWillingness(civInfo) >= 0) {
|
&& state.cityStateFunctions.getTributeWillingness(civInfo) >= 0) {
|
||||||
if (state.getTributeWillingness(civInfo, demandingWorker = true) > 0)
|
if (state.cityStateFunctions.getTributeWillingness(civInfo, demandingWorker = true) > 0)
|
||||||
state.cityStateFunctions.tributeWorker(civInfo)
|
state.cityStateFunctions.tributeWorker(civInfo)
|
||||||
else
|
else
|
||||||
state.cityStateFunctions.tributeGold(civInfo)
|
state.cityStateFunctions.tributeGold(civInfo)
|
||||||
@ -741,8 +741,8 @@ object NextTurnAutomation {
|
|||||||
var theirCombatStrength = otherCiv.getStatForRanking(RankingType.Force).toFloat() + baseForce + CityCombatant(otherCiv.getCapital()!!).getCityStrength()
|
var theirCombatStrength = otherCiv.getStatForRanking(RankingType.Force).toFloat() + baseForce + CityCombatant(otherCiv.getCapital()!!).getCityStrength()
|
||||||
|
|
||||||
//for city-states, also consider their protectors
|
//for city-states, also consider their protectors
|
||||||
if (otherCiv.isCityState() and otherCiv.getProtectorCivs().isNotEmpty()) {
|
if (otherCiv.isCityState() and otherCiv.cityStateFunctions.getProtectorCivs().isNotEmpty()) {
|
||||||
theirCombatStrength += otherCiv.getProtectorCivs().filterNot { it == civInfo }
|
theirCombatStrength += otherCiv.cityStateFunctions.getProtectorCivs().filterNot { it == civInfo }
|
||||||
.sumOf { it.getStatForRanking(RankingType.Force) }
|
.sumOf { it.getStatForRanking(RankingType.Force) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun turnsForGreatPersonFromCityState(): Int = ((37 + Random().nextInt(7)) * civInfo.gameInfo.speed.modifier).toInt()
|
||||||
|
|
||||||
/** Gain a random great person from the city state */
|
/** Gain a random great person from the city state */
|
||||||
fun giveGreatPersonToPatron(receivingCiv: CivilizationInfo) {
|
fun giveGreatPersonToPatron(receivingCiv: CivilizationInfo) {
|
||||||
|
|
||||||
@ -417,7 +419,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
civInfo.addFlag(CivFlags.RecentlyBullied.name, 20)
|
civInfo.addFlag(CivFlags.RecentlyBullied.name, 20)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canGiveStat(statType: Stat): Boolean {
|
fun canProvideStat(statType: Stat): Boolean {
|
||||||
if (!civInfo.isCityState())
|
if (!civInfo.isCityState())
|
||||||
return false
|
return false
|
||||||
for (bonus in getCityStateBonuses(civInfo.cityStateType, RelationshipLevel.Ally)) {
|
for (bonus in getCityStateBonuses(civInfo.cityStateType, RelationshipLevel.Ally)) {
|
||||||
@ -486,7 +488,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
private fun cityStateBullied(bully: CivilizationInfo) {
|
private fun cityStateBullied(bully: CivilizationInfo) {
|
||||||
if (!civInfo.isCityState()) return // What are we doing here?
|
if (!civInfo.isCityState()) return // What are we doing here?
|
||||||
|
|
||||||
for (protector in civInfo.getProtectorCivs()) {
|
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
|
||||||
if (!protector.knows(bully)) // Who?
|
if (!protector.knows(bully)) // Who?
|
||||||
continue
|
continue
|
||||||
val protectorDiplomacy = protector.getDiplomacyManager(bully)
|
val protectorDiplomacy = protector.getDiplomacyManager(bully)
|
||||||
@ -568,7 +570,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (protector in civInfo.getProtectorCivs()) {
|
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
|
||||||
if (!protector.knows(attacker)) // Who?
|
if (!protector.knows(attacker)) // Who?
|
||||||
continue
|
continue
|
||||||
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
|
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
|
||||||
@ -596,7 +598,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
fun cityStateDestroyed(attacker: CivilizationInfo) {
|
fun cityStateDestroyed(attacker: CivilizationInfo) {
|
||||||
if (!civInfo.isCityState()) return // What are we doing here?
|
if (!civInfo.isCityState()) return // What are we doing here?
|
||||||
|
|
||||||
for (protector in civInfo.getProtectorCivs()) {
|
for (protector in civInfo.cityStateFunctions.getProtectorCivs()) {
|
||||||
if (!protector.knows(attacker)) // Who?
|
if (!protector.knows(attacker)) // Who?
|
||||||
continue
|
continue
|
||||||
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
|
val protectorDiplomacy = protector.getDiplomacyManager(attacker)
|
||||||
|
@ -17,7 +17,7 @@ import kotlin.math.min
|
|||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
/** CivInfo class was getting too crowded */
|
/** CivInfo class was getting too crowded */
|
||||||
class CivInfoStats(val civInfo: CivilizationInfo) {
|
class CivInfoStatsForNextTurn(val civInfo: CivilizationInfo) {
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
/** Happiness for next turn */
|
/** Happiness for next turn */
|
@ -391,7 +391,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
val stats = CivInfoStats(this)
|
val stats = CivInfoStatsForNextTurn(this)
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
val cache = CivInfoTransientCache(this)
|
val cache = CivInfoTransientCache(this)
|
||||||
@ -630,7 +630,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
else
|
else
|
||||||
otherCiv.addNotification(meetString, NotificationCategory.Diplomacy, NotificationIcon.Gold)
|
otherCiv.addNotification(meetString, NotificationCategory.Diplomacy, NotificationIcon.Gold)
|
||||||
|
|
||||||
if (otherCiv.isCityState() && otherCiv.canGiveStat(Stat.Faith)){
|
if (otherCiv.isCityState() && otherCiv.cityStateFunctions.canProvideStat(Stat.Faith)){
|
||||||
otherCiv.addNotification(religionMeetString, NotificationCategory.Diplomacy, NotificationIcon.Faith)
|
otherCiv.addNotification(religionMeetString, NotificationCategory.Diplomacy, NotificationIcon.Faith)
|
||||||
|
|
||||||
for ((key, value) in faithAmount)
|
for ((key, value) in faithAmount)
|
||||||
@ -1073,7 +1073,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
&& givingCityState != null
|
&& givingCityState != null
|
||||||
) {
|
) {
|
||||||
givingCityState.cityStateFunctions.giveGreatPersonToPatron(this)
|
givingCityState.cityStateFunctions.giveGreatPersonToPatron(this)
|
||||||
flagsCountdown[flag] = turnsForGreatPersonFromCityState()
|
flagsCountdown[flag] = cityStateFunctions.turnsForGreatPersonFromCityState()
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@ -1389,29 +1389,9 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
moveCapitalTo(newCapital)
|
moveCapitalTo(newCapital)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////// City State wrapper functions ////////////////////////
|
|
||||||
|
|
||||||
fun receiveGoldGift(donorCiv: CivilizationInfo, giftAmount: Int) =
|
|
||||||
cityStateFunctions.receiveGoldGift(donorCiv, giftAmount)
|
|
||||||
fun turnsForGreatPersonFromCityState(): Int = ((37 + Random().nextInt(7)) * gameInfo.speed.modifier).toInt()
|
|
||||||
|
|
||||||
fun getProtectorCivs() = cityStateFunctions.getProtectorCivs()
|
|
||||||
fun addProtectorCiv(otherCiv: CivilizationInfo) = cityStateFunctions.addProtectorCiv(otherCiv)
|
|
||||||
fun removeProtectorCiv(otherCiv: CivilizationInfo, forced: Boolean = false) =
|
|
||||||
cityStateFunctions.removeProtectorCiv(otherCiv, forced)
|
|
||||||
fun otherCivCanPledgeProtection(otherCiv: CivilizationInfo) = cityStateFunctions.otherCivCanPledgeProtection(otherCiv)
|
|
||||||
fun otherCivCanWithdrawProtection(otherCiv: CivilizationInfo) = cityStateFunctions.otherCivCanWithdrawProtection(otherCiv)
|
|
||||||
|
|
||||||
fun updateAllyCivForCityState() = cityStateFunctions.updateAllyCivForCityState()
|
|
||||||
fun getTributeWillingness(demandingCiv: CivilizationInfo, demandingWorker: Boolean = false)
|
|
||||||
= cityStateFunctions.getTributeWillingness(demandingCiv, demandingWorker)
|
|
||||||
fun canGiveStat(statType: Stat) = cityStateFunctions.canGiveStat(statType)
|
|
||||||
|
|
||||||
fun getAllyCiv() = allyCivName
|
fun getAllyCiv() = allyCivName
|
||||||
fun setAllyCiv(newAllyName: String?) { allyCivName = newAllyName }
|
fun setAllyCiv(newAllyName: String?) { allyCivName = newAllyName }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
fun asPreview() = CivilizationInfoPreview(this)
|
fun asPreview() = CivilizationInfoPreview(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
|||||||
QuestName.GreatPerson.value -> getGreatPersonForQuest(challenger) != null
|
QuestName.GreatPerson.value -> getGreatPersonForQuest(challenger) != null
|
||||||
QuestName.FindPlayer.value -> getCivilizationToFindForQuest(challenger) != null
|
QuestName.FindPlayer.value -> getCivilizationToFindForQuest(challenger) != null
|
||||||
QuestName.FindNaturalWonder.value -> getNaturalWonderToFindForQuest(challenger) != null
|
QuestName.FindNaturalWonder.value -> getNaturalWonderToFindForQuest(challenger) != null
|
||||||
QuestName.PledgeToProtect.value -> mostRecentBully != null && challenger !in civInfo.getProtectorCivs()
|
QuestName.PledgeToProtect.value -> mostRecentBully != null && challenger !in civInfo.cityStateFunctions.getProtectorCivs()
|
||||||
QuestName.GiveGold.value -> mostRecentBully != null
|
QuestName.GiveGold.value -> mostRecentBully != null
|
||||||
QuestName.DenounceCiv.value -> mostRecentBully != null && challenger.knows(mostRecentBully)
|
QuestName.DenounceCiv.value -> mostRecentBully != null && challenger.knows(mostRecentBully)
|
||||||
&& !challenger.getDiplomacyManager(mostRecentBully).hasFlag(DiplomacyFlags.Denunciation)
|
&& !challenger.getDiplomacyManager(mostRecentBully).hasFlag(DiplomacyFlags.Denunciation)
|
||||||
@ -395,7 +395,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
|||||||
QuestName.GreatPerson.value -> assignee.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
QuestName.GreatPerson.value -> assignee.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
||||||
QuestName.FindPlayer.value -> assignee.hasMetCivTerritory(civInfo.gameInfo.getCivilization(assignedQuest.data1))
|
QuestName.FindPlayer.value -> assignee.hasMetCivTerritory(civInfo.gameInfo.getCivilization(assignedQuest.data1))
|
||||||
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
|
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
|
||||||
QuestName.PledgeToProtect.value -> assignee in civInfo.getProtectorCivs()
|
QuestName.PledgeToProtect.value -> assignee in civInfo.cityStateFunctions.getProtectorCivs()
|
||||||
QuestName.DenounceCiv.value -> assignee.getDiplomacyManager(assignedQuest.data1).hasFlag(DiplomacyFlags.Denunciation)
|
QuestName.DenounceCiv.value -> assignee.getDiplomacyManager(assignedQuest.data1).hasFlag(DiplomacyFlags.Denunciation)
|
||||||
QuestName.SpreadReligion.value -> civInfo.getCapital()!!.religion.getMajorityReligion() == civInfo.gameInfo.religions[assignedQuest.data2]
|
QuestName.SpreadReligion.value -> civInfo.getCapital()!!.religion.getMajorityReligion() == civInfo.gameInfo.religions[assignedQuest.data2]
|
||||||
else -> false
|
else -> false
|
||||||
|
@ -176,7 +176,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
if (civInfo.isCityState()) return when {
|
if (civInfo.isCityState()) return when {
|
||||||
getInfluence() <= -30 || civInfo.isAtWarWith(otherCiv()) -> RelationshipLevel.Unforgivable
|
getInfluence() <= -30 || civInfo.isAtWarWith(otherCiv()) -> RelationshipLevel.Unforgivable
|
||||||
getInfluence() < 0 -> RelationshipLevel.Enemy
|
getInfluence() < 0 -> RelationshipLevel.Enemy
|
||||||
getInfluence() < 30 && civInfo.getTributeWillingness(otherCiv()) > 0 -> RelationshipLevel.Afraid
|
getInfluence() < 30 && civInfo.cityStateFunctions.getTributeWillingness(otherCiv()) > 0 -> RelationshipLevel.Afraid
|
||||||
getInfluence() >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
|
getInfluence() >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
|
||||||
getInfluence() >= 30 -> RelationshipLevel.Friend
|
getInfluence() >= 30 -> RelationshipLevel.Friend
|
||||||
else -> RelationshipLevel.Neutral
|
else -> RelationshipLevel.Neutral
|
||||||
@ -234,7 +234,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
fun setInfluence(amount: Float) {
|
fun setInfluence(amount: Float) {
|
||||||
influence = max(amount, MINIMUM_INFLUENCE)
|
influence = max(amount, MINIMUM_INFLUENCE)
|
||||||
civInfo.updateAllyCivForCityState()
|
civInfo.cityStateFunctions.updateAllyCivForCityState()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getInfluence() = if (civInfo.isAtWarWith(otherCiv())) MINIMUM_INFLUENCE else influence
|
fun getInfluence() = if (civInfo.isAtWarWith(otherCiv())) MINIMUM_INFLUENCE else influence
|
||||||
@ -470,7 +470,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
// Potentially notify about afraid status
|
// Potentially notify about afraid status
|
||||||
if (getInfluence() < 30 // We usually don't want to bully our friends
|
if (getInfluence() < 30 // We usually don't want to bully our friends
|
||||||
&& !hasFlag(DiplomacyFlags.NotifiedAfraid)
|
&& !hasFlag(DiplomacyFlags.NotifiedAfraid)
|
||||||
&& civInfo.getTributeWillingness(otherCiv()) > 0
|
&& civInfo.cityStateFunctions.getTributeWillingness(otherCiv()) > 0
|
||||||
&& otherCiv().isMajorCiv()
|
&& otherCiv().isMajorCiv()
|
||||||
) {
|
) {
|
||||||
setFlag(DiplomacyFlags.NotifiedAfraid, 20) // Wait 20 turns until next reminder
|
setFlag(DiplomacyFlags.NotifiedAfraid, 20) // Wait 20 turns until next reminder
|
||||||
@ -645,8 +645,8 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
val civAtWarWith = otherCiv()
|
val civAtWarWith = otherCiv()
|
||||||
|
|
||||||
if (civInfo.isCityState() && civInfo.getProtectorCivs().contains(civAtWarWith)) {
|
if (civInfo.isCityState() && civInfo.cityStateFunctions.getProtectorCivs().contains(civAtWarWith)) {
|
||||||
civInfo.removeProtectorCiv(civAtWarWith, forced = true)
|
civInfo.cityStateFunctions.removeProtectorCiv(civAtWarWith, forced = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
diplomaticStatus = DiplomaticStatus.War
|
diplomaticStatus = DiplomaticStatus.War
|
||||||
@ -692,7 +692,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
// You attacked your own ally, you're a right bastard
|
// You attacked your own ally, you're a right bastard
|
||||||
if (otherCiv.getAllyCiv() == civInfo.civName) {
|
if (otherCiv.getAllyCiv() == civInfo.civName) {
|
||||||
otherCiv.updateAllyCivForCityState()
|
otherCiv.cityStateFunctions.updateAllyCivForCityState()
|
||||||
otherCivDiplomacy.setInfluence(-120f)
|
otherCivDiplomacy.setInfluence(-120f)
|
||||||
for (knownCiv in civInfo.getKnownCivs()) {
|
for (knownCiv in civInfo.getKnownCivs()) {
|
||||||
knownCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, -10f)
|
knownCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.BetrayedDeclarationOfFriendship, -10f)
|
||||||
|
@ -339,7 +339,7 @@ object UniqueTriggerActivation {
|
|||||||
CityStateCanGiftGreatPeople -> {
|
CityStateCanGiftGreatPeople -> {
|
||||||
civInfo.addFlag(
|
civInfo.addFlag(
|
||||||
CivFlags.CityStateGreatPersonGift.name,
|
CivFlags.CityStateGreatPersonGift.name,
|
||||||
civInfo.turnsForGreatPersonFromCityState() / 2
|
civInfo.cityStateFunctions.turnsForGreatPersonFromCityState() / 2
|
||||||
)
|
)
|
||||||
if (notification != null) {
|
if (notification != null) {
|
||||||
civInfo.addNotification(notification, NotificationCategory.Diplomacy, NotificationIcon.CityState)
|
civInfo.addNotification(notification, NotificationCategory.Diplomacy, NotificationIcon.CityState)
|
||||||
|
@ -215,7 +215,7 @@ class DiplomacyScreen(
|
|||||||
}
|
}
|
||||||
diplomacyTable.row().padTop(15f)
|
diplomacyTable.row().padTop(15f)
|
||||||
|
|
||||||
otherCiv.updateAllyCivForCityState()
|
otherCiv.cityStateFunctions.updateAllyCivForCityState()
|
||||||
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()
|
||||||
@ -226,7 +226,7 @@ class DiplomacyScreen(
|
|||||||
.row()
|
.row()
|
||||||
}
|
}
|
||||||
|
|
||||||
val protectors = otherCiv.getProtectorCivs()
|
val protectors = otherCiv.cityStateFunctions.getProtectorCivs()
|
||||||
if (protectors.isNotEmpty()) {
|
if (protectors.isNotEmpty()) {
|
||||||
val newProtectors = arrayListOf<String>()
|
val newProtectors = arrayListOf<String>()
|
||||||
for (protector in protectors) {
|
for (protector in protectors) {
|
||||||
@ -355,12 +355,12 @@ class DiplomacyScreen(
|
|||||||
val revokeProtectionButton = "Revoke Protection".toTextButton()
|
val revokeProtectionButton = "Revoke Protection".toTextButton()
|
||||||
revokeProtectionButton.onClick {
|
revokeProtectionButton.onClick {
|
||||||
ConfirmPopup(this, "Revoke protection for [${otherCiv.civName}]?", "Revoke Protection") {
|
ConfirmPopup(this, "Revoke protection for [${otherCiv.civName}]?", "Revoke Protection") {
|
||||||
otherCiv.removeProtectorCiv(viewingCiv)
|
otherCiv.cityStateFunctions.removeProtectorCiv(viewingCiv)
|
||||||
updateLeftSideTable(otherCiv)
|
updateLeftSideTable(otherCiv)
|
||||||
updateRightSide(otherCiv)
|
updateRightSide(otherCiv)
|
||||||
}.open()
|
}.open()
|
||||||
}
|
}
|
||||||
if (isNotPlayersTurn() || !otherCiv.otherCivCanWithdrawProtection(viewingCiv)) revokeProtectionButton.disable()
|
if (isNotPlayersTurn() || !otherCiv.cityStateFunctions.otherCivCanWithdrawProtection(viewingCiv)) revokeProtectionButton.disable()
|
||||||
return revokeProtectionButton
|
return revokeProtectionButton
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,12 +373,12 @@ class DiplomacyScreen(
|
|||||||
"Pledge to protect",
|
"Pledge to protect",
|
||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
otherCiv.addProtectorCiv(viewingCiv)
|
otherCiv.cityStateFunctions.addProtectorCiv(viewingCiv)
|
||||||
updateLeftSideTable(otherCiv)
|
updateLeftSideTable(otherCiv)
|
||||||
updateRightSide(otherCiv)
|
updateRightSide(otherCiv)
|
||||||
}.open()
|
}.open()
|
||||||
}
|
}
|
||||||
if (isNotPlayersTurn() || !otherCiv.otherCivCanPledgeProtection(viewingCiv)) protectionButton.disable()
|
if (isNotPlayersTurn() || !otherCiv.cityStateFunctions.otherCivCanPledgeProtection(viewingCiv)) protectionButton.disable()
|
||||||
return protectionButton
|
return protectionButton
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ class DiplomacyScreen(
|
|||||||
val giftButton =
|
val giftButton =
|
||||||
"Gift [$giftAmount] gold (+[$influenceAmount] influence)".toTextButton()
|
"Gift [$giftAmount] gold (+[$influenceAmount] influence)".toTextButton()
|
||||||
giftButton.onClick {
|
giftButton.onClick {
|
||||||
otherCiv.receiveGoldGift(viewingCiv, giftAmount)
|
otherCiv.cityStateFunctions.receiveGoldGift(viewingCiv, giftAmount)
|
||||||
updateLeftSideTable(otherCiv)
|
updateLeftSideTable(otherCiv)
|
||||||
updateRightSide(otherCiv)
|
updateRightSide(otherCiv)
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ class DiplomacyScreen(
|
|||||||
rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
|
rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
|
||||||
}
|
}
|
||||||
diplomacyTable.add(demandGoldButton).row()
|
diplomacyTable.add(demandGoldButton).row()
|
||||||
if (otherCiv.getTributeWillingness(viewingCiv, demandingWorker = false) < 0) demandGoldButton.disable()
|
if (otherCiv.cityStateFunctions.getTributeWillingness(viewingCiv, demandingWorker = false) < 0) demandGoldButton.disable()
|
||||||
|
|
||||||
val demandWorkerButton = "Take worker (-50 Influence)".toTextButton()
|
val demandWorkerButton = "Take worker (-50 Influence)".toTextButton()
|
||||||
demandWorkerButton.onClick {
|
demandWorkerButton.onClick {
|
||||||
@ -580,7 +580,7 @@ class DiplomacyScreen(
|
|||||||
rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
|
rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
|
||||||
}
|
}
|
||||||
diplomacyTable.add(demandWorkerButton).row()
|
diplomacyTable.add(demandWorkerButton).row()
|
||||||
if (otherCiv.getTributeWillingness(viewingCiv, demandingWorker = true) < 0) demandWorkerButton.disable()
|
if (otherCiv.cityStateFunctions.getTributeWillingness(viewingCiv, demandingWorker = true) < 0) demandWorkerButton.disable()
|
||||||
|
|
||||||
val backButton = "Back".toTextButton()
|
val backButton = "Back".toTextButton()
|
||||||
backButton.onClick {
|
backButton.onClick {
|
||||||
|
@ -312,7 +312,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
add(getCloseButton("Very well.", 'n') {
|
add(getCloseButton("Very well.", 'n') {
|
||||||
val capitalLocation = LocationAction(cityState.cities.asSequence().map { it.location }) // in practice 0 or 1 entries, that's OK
|
val capitalLocation = LocationAction(cityState.cities.asSequence().map { it.location }) // in practice 0 or 1 entries, that's OK
|
||||||
player.addNotification("You have broken your Pledge to Protect [${cityState.civName}]!", capitalLocation, NotificationCategory.Diplomacy, cityState.civName)
|
player.addNotification("You have broken your Pledge to Protect [${cityState.civName}]!", capitalLocation, NotificationCategory.Diplomacy, cityState.civName)
|
||||||
cityState.removeProtectorCiv(player, forced = true)
|
cityState.cityStateFunctions.removeProtectorCiv(player, forced = true)
|
||||||
}).row()
|
}).row()
|
||||||
}
|
}
|
||||||
AlertType.RecapturedCivilian -> addRecapturedCivilianTable()
|
AlertType.RecapturedCivilian -> addRecapturedCivilianTable()
|
||||||
|
Loading…
Reference in New Issue
Block a user