mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
New AI resource cost uniques also work for Strategic and Bonus resources, assuming they even want to buy
This commit is contained in:
parent
b4cfb50ca7
commit
f922dcbc75
@ -140,6 +140,12 @@ class TradeEvaluation {
|
||||
TradeOfferType.Luxury_Resource -> {
|
||||
if (civInfo.getDiplomacyManager(tradePartner)!!.hasFlag(DiplomacyFlags.ResourceTradesCutShort))
|
||||
return 0 // We don't trust you for resources
|
||||
|
||||
val lowestExplicitBuyCost = civInfo.gameInfo.ruleset.tileResources[offer.name]!!
|
||||
.getMatchingUniques(UniqueType.AiWillBuyAt, StateForConditionals(civInfo))
|
||||
.minOfOrNull { it.params[0].toInt() }
|
||||
|
||||
if (lowestExplicitBuyCost != null) return lowestExplicitBuyCost
|
||||
|
||||
val weLoveTheKingPotential = civInfo.cities.count { it.demandedResource == offer.name } * 50
|
||||
return if(!civInfo.hasResource(offer.name)) { // we can't trade on resources, so we are only interested in 1 copy for ourselves
|
||||
@ -159,6 +165,12 @@ class TradeEvaluation {
|
||||
if (amountWillingToBuy <= 0) return 0 // we already have enough.
|
||||
val amountToBuyInOffer = min(amountWillingToBuy, offer.amount)
|
||||
|
||||
|
||||
val lowestExplicitBuyCost = civInfo.gameInfo.ruleset.tileResources[offer.name]!!
|
||||
.getMatchingUniques(UniqueType.AiWillBuyAt, StateForConditionals(civInfo))
|
||||
.minOfOrNull { it.params[0].toInt() }
|
||||
if (lowestExplicitBuyCost != null) return lowestExplicitBuyCost
|
||||
|
||||
val canUseForBuildings = civInfo.cities
|
||||
.any { city -> city.cityConstructions.getBuildableBuildings().any {
|
||||
it.getResourceRequirementsPerTurn(city.state).containsKey(offer.name) } }
|
||||
@ -260,6 +272,12 @@ class TradeEvaluation {
|
||||
}
|
||||
}
|
||||
TradeOfferType.Luxury_Resource -> {
|
||||
val lowestExplicitSellCost = civInfo.gameInfo.ruleset.tileResources[offer.name]!!
|
||||
.getMatchingUniques(UniqueType.AiWillSellAt, StateForConditionals(civInfo))
|
||||
.minOfOrNull { it.params[0].toInt() }
|
||||
|
||||
if (lowestExplicitSellCost != null) return lowestExplicitSellCost
|
||||
|
||||
return when {
|
||||
civInfo.getResourceAmount(offer.name) > 1 -> 250 // fair price
|
||||
civInfo.hasUnique(UniqueType.RetainHappinessFromLuxury) -> // If we retain 100% happiness, value it as a duplicate lux
|
||||
@ -273,7 +291,13 @@ class TradeEvaluation {
|
||||
(civInfo.hasUnique(UniqueType.EnablesConstructionOfSpaceshipParts) ||
|
||||
tradePartner.hasUnique(UniqueType.EnablesConstructionOfSpaceshipParts))
|
||||
)
|
||||
return 10000 // We'd rather win the game, thanks
|
||||
return Int.MAX_VALUE // We'd rather win the game, thanks
|
||||
|
||||
val lowestExplicitSellCost = civInfo.gameInfo.ruleset.tileResources[offer.name]!!
|
||||
.getMatchingUniques(UniqueType.AiWillSellAt, StateForConditionals(civInfo))
|
||||
.minOfOrNull { it.params[0].toInt() }
|
||||
|
||||
if (lowestExplicitSellCost != null) return lowestExplicitSellCost
|
||||
|
||||
if (!civInfo.isAtWar()) return 50 * offer.amount
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user