mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Started implementing Patronage branch. Parametrized some uniques, city-states can handle different resting points for different civs.
This commit is contained in:
parent
9c725d74ae
commit
4e2aaa76dc
@ -59,7 +59,7 @@
|
||||
"outerColor": [181, 232, 232],
|
||||
"innerColor": [68,142,249],
|
||||
"uniqueName": "Hellenic League",
|
||||
"uniques": ["City-State Influence degrades at half rate", "City-State Influence recovers at twice the normal rate"],
|
||||
"uniques": ["City-State Influence degrades [50]% slower", "City-State Influence recovers at twice the normal rate"],
|
||||
"cities": ["Athens","Sparta","Corinth","Argos","Knossos","Mycenae","Pharsalos","Ephesus","Halicarnassus","Rhodes",
|
||||
"Eretria","Pergamon","Miletos","Megara","Phocaea","Sicyon","Tiryns","Samos","Mytilene","Chios",
|
||||
"Paros","Elis","Syracuse","Herakleia","Gortyn","Chalkis","Pylos","Pella","Naxos","Sicyon",
|
||||
|
@ -177,14 +177,17 @@
|
||||
},/*{
|
||||
"name": "Patronage",
|
||||
"era": "Classical era",
|
||||
"uniques": ["City-State Influence degrades [25]% slower"],
|
||||
"policies": [
|
||||
{
|
||||
"name": "Philantropy",
|
||||
"uniques":["Gifts of Gold to City-States generate [25]% more Influence"],
|
||||
"row": 1,
|
||||
"column": 2
|
||||
},
|
||||
{
|
||||
"name": "Aesthetics",
|
||||
"uniques":["Resting point for Influence with City-States is increased by [20]"],
|
||||
"row": 1,
|
||||
"column": 4
|
||||
},
|
||||
|
@ -21,7 +21,6 @@ import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.ruleset.tile.TileResource
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.equalsPlaceholderText
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.victoryscreen.RankingType
|
||||
import java.util.*
|
||||
@ -597,11 +596,18 @@ class CivilizationInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fun giveGoldGift(otherCiv: CivilizationInfo, giftAmount: Int) {
|
||||
if (!otherCiv.isCityState()) throw Exception("You can only gain influence with City-States!")
|
||||
fun influenceGainedByGift(cityState: CivilizationInfo, giftAmount: Int): Int {
|
||||
var influenceGained = giftAmount / 10f
|
||||
for (unique in cityState.getMatchingUniques("Gifts of Gold to City-States generate []% more Influence"))
|
||||
influenceGained *= (100f + unique.params[0].toInt()) / 100
|
||||
return influenceGained.toInt()
|
||||
}
|
||||
|
||||
fun giveGoldGift(cityState: CivilizationInfo, giftAmount: Int) {
|
||||
if (!cityState.isCityState()) throw Exception("You can only gain influence with City-States!")
|
||||
gold -= giftAmount
|
||||
otherCiv.getDiplomacyManager(this).influence += giftAmount / 10
|
||||
otherCiv.updateAllyCivForCityState()
|
||||
cityState.getDiplomacyManager(this).influence += influenceGainedByGift(cityState, giftAmount)
|
||||
cityState.updateAllyCivForCityState()
|
||||
updateStatsForNextTurn()
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,6 @@ class DiplomacyManager() {
|
||||
var influence = 0f
|
||||
set(value) { field = max(value, MINIMUM_INFLUENCE) }
|
||||
get() = if(civInfo.isAtWarWith(otherCiv())) MINIMUM_INFLUENCE else field
|
||||
/** For city-states. Resting point is the value of Influence at which it ceases changing by itself */
|
||||
var restingPoint = 0f
|
||||
|
||||
/** Total of each turn Science during Research Agreement */
|
||||
var totalOfScienceDuringRA = 0
|
||||
@ -103,7 +101,6 @@ class DiplomacyManager() {
|
||||
toReturn.diplomaticStatus=diplomaticStatus
|
||||
toReturn.trades.addAll(trades.map { it.clone() })
|
||||
toReturn.influence = influence
|
||||
toReturn.restingPoint = restingPoint
|
||||
toReturn.flagsCountdown.putAll(flagsCountdown)
|
||||
toReturn.diplomaticModifiers.putAll(diplomaticModifiers)
|
||||
toReturn.totalOfScienceDuringRA=totalOfScienceDuringRA
|
||||
@ -176,11 +173,19 @@ class DiplomacyManager() {
|
||||
return 0
|
||||
}
|
||||
|
||||
// To be run from City-State DiplomacyManager, which holds the influence. Resting point for every major civ can be different.
|
||||
fun getCityStateInfluenceRestingPoint(): Float {
|
||||
var restingPoint = 0f
|
||||
for(unique in otherCiv().getMatchingUniques("Resting point for Influence with City-States is increased by []"))
|
||||
restingPoint += unique.params[0].toInt()
|
||||
return restingPoint
|
||||
}
|
||||
|
||||
private fun getCityStateInfluenceDegrade(): Float {
|
||||
if (influence < restingPoint)
|
||||
if (influence < getCityStateInfluenceRestingPoint())
|
||||
return 0f
|
||||
|
||||
var decrement = when (civInfo.cityStatePersonality) {
|
||||
val decrement = when (civInfo.cityStatePersonality) {
|
||||
CityStatePersonality.Hostile -> 1.5f
|
||||
else -> 1f
|
||||
}
|
||||
@ -192,17 +197,21 @@ class DiplomacyManager() {
|
||||
else -> 1f
|
||||
}
|
||||
|
||||
// Deprecated at 3.12.11 in favor of "City-State Influence degrades [50]% slower"
|
||||
if (otherCiv().hasUnique("City-State Influence degrades at half rate"))
|
||||
modifier *= .5f
|
||||
|
||||
for (unique in otherCiv().getMatchingUniques("City-State Influence degrades []% slower"))
|
||||
modifier *= (100f - unique.params[0].toInt()) / 100
|
||||
|
||||
return max(0f, decrement) * max(0f, modifier)
|
||||
}
|
||||
|
||||
private fun getCityStateInfluenceRecovery(): Float {
|
||||
if (influence > restingPoint)
|
||||
if (influence > getCityStateInfluenceRestingPoint())
|
||||
return 0f
|
||||
|
||||
var increment = 1f
|
||||
val increment = 1f
|
||||
|
||||
var modifier = when (civInfo.cityStatePersonality) {
|
||||
CityStatePersonality.Friendly -> 2f
|
||||
@ -335,6 +344,7 @@ class DiplomacyManager() {
|
||||
private fun nextTurnCityStateInfluence() {
|
||||
val initialRelationshipLevel = relationshipLevel()
|
||||
|
||||
val restingPoint = getCityStateInfluenceRestingPoint()
|
||||
if (influence > restingPoint) {
|
||||
val decrement = getCityStateInfluenceDegrade()
|
||||
influence = max(restingPoint, influence - decrement)
|
||||
|
@ -147,7 +147,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
diplomacyTable.addSeparator()
|
||||
|
||||
val giftAmount = 250
|
||||
val influenceAmount = giftAmount / 10
|
||||
val influenceAmount = viewingCiv.influenceGainedByGift(otherCiv, giftAmount)
|
||||
val giftButton = "Gift [$giftAmount] gold (+[$influenceAmount] influence)".toTextButton()
|
||||
giftButton.onClick {
|
||||
viewingCiv.giveGoldGift(otherCiv, giftAmount)
|
||||
|
Loading…
x
Reference in New Issue
Block a user