Reorganized the way city states grant resources & rounded a float to an int (#6210)

* Reorganized the way city states grant resources & rounded a float to an int

* Reworded a string so it sounds nicer
This commit is contained in:
Xander Lenstra
2022-02-22 10:30:33 +01:00
committed by GitHub
parent 90386bd4e7
commit e0345bcb52
4 changed files with 31 additions and 17 deletions

View File

@ -237,15 +237,20 @@ Hostile =
Irrational =
Personality =
Influence =
Ally: [civilization] with [amount] Influence =
Reach 30 for friendship. =
Reach highest influence above 60 for alliance. =
When Friends: =
When Allies: =
The unique luxury is one of: =
Demand Tribute =
Tribute Willingness =
At least 0 to take gold, at least 30 and size 4 city for worker =
Take [amount] gold (-15 Influence) =
Take worker (-50 Influence) =
[civName] is afraid of your military power! =
Major Civ =
No Cities =
Base value =
@ -259,9 +264,7 @@ Influence below -30 =
Military Rank =
Military near City-State =
Sum: =
Take [amount] gold (-15 Influence) =
Take worker (-50 Influence) =
[civName] is afraid of your military power! =
# Trades

View File

@ -4,6 +4,7 @@ import com.unciv.logic.automation.NextTurnAutomation
import com.unciv.logic.civilization.diplomacy.*
import com.unciv.models.metadata.GameSpeed
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.ruleset.unique.Unique
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.stats.Stat
@ -651,4 +652,13 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
}
}
fun getCityStateResourcesForAlly(): ResourceSupplyList {
val newDetailedCivResources = ResourceSupplyList()
for (city in civInfo.cities) {
for (resourceSupply in city.getCityResources())
if (resourceSupply.amount > 0) // IGNORE the fact that they consume their own resources - #4769
newDetailedCivResources.add(resourceSupply.resource, resourceSupply.amount, "City-States")
}
return newDetailedCivResources
}
}

View File

@ -172,14 +172,12 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
var resourceBonusPercentage = 1f
for (unique in civInfo.getMatchingUniques(UniqueType.CityStateResources))
resourceBonusPercentage += unique.params[0].toFloat() / 100
for (city in civInfo.getKnownCivs().filter { it.getAllyCiv() == civInfo.civName }
.flatMap { it.cities }) {
for (resourceSupply in city.getCityResources())
if (resourceSupply.origin != "Buildings") // IGNORE the fact that they consume their own resources - #4769
newDetailedCivResources.add(
resourceSupply.resource,
(resourceSupply.amount * resourceBonusPercentage).toInt(), "City-States"
)
for (cityStateAlly in civInfo.getKnownCivs().filter { it.getAllyCiv() == civInfo.civName }) {
for (resource in CityStateFunctions(cityStateAlly).getCityStateResourcesForAlly()) {
newDetailedCivResources.add(
resource.apply { amount = (amount * resourceBonusPercentage).toInt() }
)
}
}
}

View File

@ -146,7 +146,9 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo): BaseScreen() {
if (otherCiv.detailedCivResources.any { it.resource.resourceType != ResourceType.Bonus }) {
val resourcesTable = Table()
resourcesTable.add("{Resources}: ".toLabel()).padRight(10f)
for (supplyList in otherCiv.detailedCivResources) {
val cityStateResources = CityStateFunctions(otherCiv)
.getCityStateResourcesForAlly()
for (supplyList in cityStateResources) {
if (supplyList.resource.resourceType == ResourceType.Bonus)
continue
val name = supplyList.resource.name
@ -172,9 +174,10 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo): BaseScreen() {
otherCiv.updateAllyCivForCityState()
val ally = otherCiv.getAllyCiv()
if (ally != null) {
val allyString = "{Ally}: {$ally} {Influence}: ".tr() +
otherCiv.getDiplomacyManager(ally).influence.toString()
diplomacyTable.add(allyString.toLabel()).row()
val allyInfluence = otherCiv.getDiplomacyManager(ally).influence.toInt()
diplomacyTable
.add("Ally: [$ally] with [$allyInfluence] Influence".toLabel())
.row()
}
val protectors = otherCiv.getProtectorCivs()