City states influence, Bugfix Greece (#1512)

* Fix Greece Unique wasn't effective + Added CityState relation notifications

* Greece influence to CityState benefits from unique
* Added notifications when you are about to lose (or lost) friendship and alliance with a city state. Closes #1168
* Introduced restingPoint in DiplomacyManager to support constant shifts in influence

* Autogeneration translation files
This commit is contained in:
r3versi 2019-12-22 22:08:46 +01:00 committed by Yair Morgenstern
parent c568601e56
commit a1aec212bd
20 changed files with 119 additions and 15 deletions

View file

@ -686,6 +686,10 @@ We have lost alliance with [nation]. = Ztratili jsme alianci s civilizací [nati
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -1149,6 +1149,10 @@ We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -1224,6 +1224,10 @@ We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -685,6 +685,10 @@ We have lost alliance with [nation]. = Notre alliance est terminée avec le/la/l
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -691,6 +691,10 @@ We have lost alliance with [nation]. = Wir haben die Alianz mit [nation] verlore
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -681,6 +681,10 @@ We have lost alliance with [nation]. = Non siamo più alleati di [nation].
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -709,6 +709,10 @@ We have lost alliance with [nation]. = [nation]와(과)의 동맹 관계가 끝
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -1113,6 +1113,10 @@ We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -680,6 +680,10 @@ We have allied with [nation]. = Jesteśmy sojusznikami z [nation].
We have lost alliance with [nation]. = Nie jesteśmy już w sojuszu z [nation].
We have discovered [naturalWonder]! = Odkryliśmy [naturlWonder]!
We have received [goldAmount] Gold for discovering [naturalWonder] = Otrzymaliśmy [goldAmount] Złota za odkrycie [naturalWonder]
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -804,6 +804,10 @@ We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -1007,6 +1007,10 @@ We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -689,6 +689,10 @@ We have lost alliance with [nation]. = Наш альянс с [nation] был р
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -687,6 +687,10 @@ We have lost alliance with [nation]. = 我们和[nation]不再是同盟关系
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -692,6 +692,10 @@ We have lost alliance with [nation]. = Ya no estamos aliados con [nation].
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -687,6 +687,10 @@ We have lost alliance with [nation]. = 我們和[nation]不再是同盟關係
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -749,6 +749,10 @@ We have lost alliance with [nation]. = Тепер ми не союзники з
We have discovered [naturalWonder]! =
# Requires translation!
We have received [goldAmount] Gold for discovering [naturalWonder] =
# Requires translation!
Your relationship with [cityStateName] is about to degrade =
# Requires translation!
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -1,16 +1,16 @@
Traditional_Chinese = 97
Italian = 98
Polish = 99
Russian = 97
Polish = 99
Romanian = 49
Korean = 95
Simplified_Chinese = 97
German = 97
German = 96
English = 0
Ukrainian = 85
French = 98
French = 97
Portuguese = 77
Czech = 97
Malay = 13
Spanish = 92
Malay = 13
Czech = 97
Dutch = 22

View file

@ -679,6 +679,8 @@ We have allied with [nation]. =
We have lost alliance with [nation]. =
We have discovered [naturalWonder]! =
We have received [goldAmount] Gold for discovering [naturalWonder] =
Your relationship with [cityStateName] is about to degrade =
Your relationship with [cityStateName] degraded =
# World Screen UI

View file

@ -9,6 +9,9 @@ import com.unciv.logic.civilization.PopupAlert
import com.unciv.logic.trade.Trade
import com.unciv.logic.trade.TradeType
import com.unciv.models.ruleset.tile.ResourceSupplyList
import kotlin.math.max
import kotlin.math.min
import kotlin.math.ceil
enum class RelationshipLevel{
Unforgivable,
@ -78,12 +81,16 @@ class DiplomacyManager() {
/** For city-states. Influence is saved in the CITY STATE -> major civ Diplomacy, NOT in the major civ -> cty state diplomacy. */
var influence = 0f
/** For city-states. Resting point is the value of Influence at which it ceases changing by itself */
var restingPoint = 0f
fun clone(): DiplomacyManager {
val toReturn = DiplomacyManager()
toReturn.otherCivName=otherCivName
toReturn.diplomaticStatus=diplomaticStatus
toReturn.trades.addAll(trades.map { it.clone() })
toReturn.influence = influence
toReturn.restingPoint = restingPoint
toReturn.flagsCountdown.putAll(flagsCountdown)
toReturn.diplomaticModifiers.putAll(diplomaticModifiers)
return toReturn
@ -146,6 +153,26 @@ class DiplomacyManager() {
return RelationshipLevel.Neutral
}
/** Returns the number of turns to degrade from Ally or from Friend */
fun getTurnsToRelationshipChange(): Int {
if (otherCiv().isCityState())
return otherCivDiplomacy().getTurnsToRelationshipChange()
if (civInfo.isCityState() && !otherCiv().isCityState()) {
val hasCityStateInfluenceBonus =
otherCiv().nation.unique == "City-State Influence degrades at half and recovers at twice the normal rate"
val dropPerTurn = if(hasCityStateInfluenceBonus) .5f else 1f
if (relationshipLevel() >= RelationshipLevel.Ally)
return ceil((influence - 60f) / dropPerTurn).toInt() + 1
else if (relationshipLevel() >= RelationshipLevel.Friend)
return ceil((influence - 30f) / dropPerTurn).toInt() + 1
else
return 0
}
return 0
}
fun canDeclareWar() = (turnsToPeaceTreaty()==0 && diplomaticStatus != DiplomaticStatus.War)
fun goldPerTurn():Int{
@ -214,19 +241,29 @@ class DiplomacyManager() {
updateHasOpenBorders()
nextTurnDiplomaticModifiers()
nextTurnFlags()
nextTurnCityStateInfluence()
if (civInfo.isCityState() && !otherCiv().isCityState())
nextTurnCityStateInfluence()
}
private fun nextTurnCityStateInfluence() {
val initialRelationshipLevel = relationshipLevel()
val hasCityStateInfluenceBonus =
civInfo.nation.unique == "City-State Influence degrades at half and recovers at twice the normal rate"
if (influence > 1) {
if (hasCityStateInfluenceBonus) influence -= 0.5f
else influence -= 1
} else if (influence < 1) {
if (hasCityStateInfluenceBonus) influence += 2
else influence += 1
} else influence = 0f
otherCiv().nation.unique == "City-State Influence degrades at half and recovers at twice the normal rate"
val increment = if (hasCityStateInfluenceBonus) 2f else 1f
val decrement = if (hasCityStateInfluenceBonus) .5f else 1f
if (influence > restingPoint)
influence = max(restingPoint, influence - decrement)
else if (influence < restingPoint)
influence = min(restingPoint, influence + increment)
else influence = restingPoint
if (getTurnsToRelationshipChange() == 1)
otherCiv().addNotification("Your relationship with [${civInfo.civName}] is about to degrade", null, Color.GOLD)
if (initialRelationshipLevel >= RelationshipLevel.Friend && initialRelationshipLevel != relationshipLevel())
otherCiv().addNotification("Your relationship with [${civInfo.civName}] degraded", null, Color.GOLD)
}
private fun nextTurnFlags() {

View file

@ -125,7 +125,8 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
val friendBonusLabelColor:Color
if (otherCivDiplomacyManager.relationshipLevel() >= RelationshipLevel.Friend) {
friendBonusLabelColor = Color.GREEN
val turnsToRelationshipChange = otherCivDiplomacyManager.influence.toInt() - 30 + 1
// RelationshipChange = Ally -> Friend or Friend -> Favorable
val turnsToRelationshipChange = otherCivDiplomacyManager.getTurnsToRelationshipChange()
diplomacyTable.add("Relationship changes in another [$turnsToRelationshipChange] turns".toLabel()).row()
} else
friendBonusLabelColor = Color.GRAY