mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-12 10:59:55 +07:00
Resolved #2789 - losing a resource no longer cancells all trades with that resource, only as many as is necessary to reach equilibrium
This commit is contained in:
parent
20772a5b6d
commit
e1aaa88e3d
@ -124,6 +124,8 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
|||||||
fun loadGame(gameInfo: GameInfo) {
|
fun loadGame(gameInfo: GameInfo) {
|
||||||
this.gameInfo = gameInfo
|
this.gameInfo = gameInfo
|
||||||
ImageGetter.ruleset = gameInfo.ruleSet
|
ImageGetter.ruleset = gameInfo.ruleSet
|
||||||
|
Gdx.input.inputProcessor = null // Since we will set the world screen when we're ready,
|
||||||
|
// This is to avoid ANRs when loading.
|
||||||
ImageGetter.refreshAtlas()
|
ImageGetter.refreshAtlas()
|
||||||
worldScreen = WorldScreen(gameInfo.getPlayerToViewAs())
|
worldScreen = WorldScreen(gameInfo.getPlayerToViewAs())
|
||||||
setWorldScreen()
|
setWorldScreen()
|
||||||
|
@ -237,19 +237,24 @@ class DiplomacyManager() {
|
|||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region state-changing functions
|
//region state-changing functions
|
||||||
fun removeUntenebleTrades(){
|
fun removeUntenebleTrades() {
|
||||||
val negativeCivResources = civInfo.getCivResources()
|
|
||||||
.filter { it.amount<0 }.map { it.resource.name }
|
for (trade in trades.toList()) {
|
||||||
|
|
||||||
|
// Every cancelled trade can change this - if 1 resource is missing,
|
||||||
|
// don't cancel all trades of that resource, only cancel one (the first one, as it happens, since they're added chronologically)
|
||||||
|
val negativeCivResources = civInfo.getCivResources()
|
||||||
|
.filter { it.amount < 0 }.map { it.resource.name }
|
||||||
|
|
||||||
for(trade in trades.toList()) {
|
|
||||||
for (offer in trade.ourOffers) {
|
for (offer in trade.ourOffers) {
|
||||||
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
||||||
&& offer.name in negativeCivResources){
|
&& offer.name in negativeCivResources) {
|
||||||
trades.remove(trade)
|
trades.remove(trade)
|
||||||
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
|
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
|
||||||
otherCivTrades.removeAll{ it.equals(trade.reverse()) }
|
otherCivTrades.removeAll { it.equals(trade.reverse()) }
|
||||||
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short",null, Color.GOLD)
|
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", null, Color.GOLD)
|
||||||
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short",null, Color.GOLD)
|
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", null, Color.GOLD)
|
||||||
|
civInfo.updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user