mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-27 08:09:21 +07:00
Send speed for all trade offers, instead of using static - allows for 'next turn' without setting UncivGame.current
This commit is contained in:
@ -60,8 +60,8 @@ object DeclareWarTargetAutomation {
|
|||||||
|
|
||||||
// Send them an offer
|
// Send them an offer
|
||||||
val tradeLogic = TradeLogic(civInfo, thirdCiv)
|
val tradeLogic = TradeLogic(civInfo, thirdCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration, speed = civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
thirdCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
thirdCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ object DeclareWarTargetAutomation {
|
|||||||
|
|
||||||
// Send them an offer
|
// Send them an offer
|
||||||
val tradeLogic = TradeLogic(civInfo, thirdCiv)
|
val tradeLogic = TradeLogic(civInfo, thirdCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(target.civName, TradeOfferType.WarDeclaration, speed = civInfo.gameInfo.speed))
|
||||||
// TODO: Maybe add in payment requests in some situations
|
// TODO: Maybe add in payment requests in some situations
|
||||||
thirdCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
thirdCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ object DiplomacyAutomation {
|
|||||||
if ((1..10).random() < 7) continue
|
if ((1..10).random() < 7) continue
|
||||||
if (wantsToOpenBorders(civInfo, otherCiv)) {
|
if (wantsToOpenBorders(civInfo, otherCiv)) {
|
||||||
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement, speed = civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
} else {
|
} else {
|
||||||
@ -168,8 +168,8 @@ object DiplomacyAutomation {
|
|||||||
if ((1..10).random() <= 5 * civInfo.getPersonality().modifierFocus(PersonalityValue.Science, .3f)) continue
|
if ((1..10).random() <= 5 * civInfo.getPersonality().modifierFocus(PersonalityValue.Science, .3f)) continue
|
||||||
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
||||||
val cost = civInfo.diplomacyFunctions.getResearchAgreementCost(otherCiv)
|
val cost = civInfo.diplomacyFunctions.getResearchAgreementCost(otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty, cost))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty, cost, civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty, cost))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty, cost, civInfo.gameInfo.speed))
|
||||||
|
|
||||||
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
}
|
}
|
||||||
@ -192,8 +192,8 @@ object DiplomacyAutomation {
|
|||||||
if (wantsToSignDefensivePact(civInfo, otherCiv)) {
|
if (wantsToSignDefensivePact(civInfo, otherCiv)) {
|
||||||
//todo: Add more in depth evaluation here
|
//todo: Add more in depth evaluation here
|
||||||
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
} else {
|
} else {
|
||||||
@ -293,7 +293,8 @@ object DiplomacyAutomation {
|
|||||||
internal fun offerPeaceTreaty(civInfo: Civilization) {
|
internal fun offerPeaceTreaty(civInfo: Civilization) {
|
||||||
if (!civInfo.isAtWar() || civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
|
if (!civInfo.isAtWar() || civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
|
||||||
|
|
||||||
val enemiesCiv = civInfo.diplomacy.filter { it.value.diplomaticStatus == DiplomaticStatus.War }
|
val enemiesCiv = civInfo.diplomacy.asSequence()
|
||||||
|
.filter { it.value.diplomaticStatus == DiplomaticStatus.War }
|
||||||
.map { it.value.otherCiv() }
|
.map { it.value.otherCiv() }
|
||||||
.filterNot {
|
.filterNot {
|
||||||
it == civInfo || it.isBarbarian || it.cities.isEmpty()
|
it == civInfo || it.isBarbarian || it.cities.isEmpty()
|
||||||
@ -304,6 +305,7 @@ object DiplomacyAutomation {
|
|||||||
.filterNot { it.isCityState && it.getAllyCiv() != null && civInfo.isAtWarWith(civInfo.gameInfo.getCivilization(it.getAllyCiv()!!)) }
|
.filterNot { it.isCityState && it.getAllyCiv() != null && civInfo.isAtWarWith(civInfo.gameInfo.getCivilization(it.getAllyCiv()!!)) }
|
||||||
// ignore civs that we have already offered peace this turn as a counteroffer to another civ's peace offer
|
// ignore civs that we have already offered peace this turn as a counteroffer to another civ's peace offer
|
||||||
.filter { it.tradeRequests.none { tradeRequest -> tradeRequest.requestingCiv == civInfo.civName && tradeRequest.trade.isPeaceTreaty() } }
|
.filter { it.tradeRequests.none { tradeRequest -> tradeRequest.requestingCiv == civInfo.civName && tradeRequest.trade.isPeaceTreaty() } }
|
||||||
|
.toList()
|
||||||
|
|
||||||
for (enemy in enemiesCiv) {
|
for (enemy in enemiesCiv) {
|
||||||
if (hasAtLeastMotivationToAttack(civInfo, enemy, 10f) >= 10) {
|
if (hasAtLeastMotivationToAttack(civInfo, enemy, 10f) >= 10) {
|
||||||
@ -319,8 +321,8 @@ object DiplomacyAutomation {
|
|||||||
// pay for peace
|
// pay for peace
|
||||||
val tradeLogic = TradeLogic(civInfo, enemy)
|
val tradeLogic = TradeLogic(civInfo, enemy)
|
||||||
|
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
if (enemy.isMajorCiv()) {
|
if (enemy.isMajorCiv()) {
|
||||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo, enemy)
|
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo, enemy)
|
||||||
@ -330,13 +332,13 @@ object DiplomacyAutomation {
|
|||||||
moneyWeNeedToPay = civInfo.gold // As much as possible
|
moneyWeNeedToPay = civInfo.gold // As much as possible
|
||||||
}
|
}
|
||||||
tradeLogic.currentTrade.ourOffers.add(
|
tradeLogic.currentTrade.ourOffers.add(
|
||||||
TradeOffer("Gold".tr(), TradeOfferType.Gold, moneyWeNeedToPay)
|
TradeOffer("Gold".tr(), TradeOfferType.Gold, moneyWeNeedToPay, civInfo.gameInfo.speed)
|
||||||
)
|
)
|
||||||
} else if (moneyWeNeedToPay < -100) {
|
} else if (moneyWeNeedToPay < -100) {
|
||||||
val moneyTheyNeedToPay = abs(moneyWeNeedToPay).coerceAtMost(enemy.gold)
|
val moneyTheyNeedToPay = abs(moneyWeNeedToPay).coerceAtMost(enemy.gold)
|
||||||
if (moneyTheyNeedToPay > 0) {
|
if (moneyTheyNeedToPay > 0) {
|
||||||
tradeLogic.currentTrade.theirOffers.add(
|
tradeLogic.currentTrade.theirOffers.add(
|
||||||
TradeOffer("Gold".tr(), TradeOfferType.Gold, moneyTheyNeedToPay)
|
TradeOffer("Gold".tr(), TradeOfferType.Gold, moneyTheyNeedToPay, civInfo.gameInfo.speed)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +365,7 @@ object DiplomacyAutomation {
|
|||||||
|
|
||||||
val tradeLogic = TradeLogic(civInfo, civToAsk)
|
val tradeLogic = TradeLogic(civInfo, civToAsk)
|
||||||
// TODO: add gold offer here
|
// TODO: add gold offer here
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(enemyCiv.civName, TradeOfferType.WarDeclaration))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(enemyCiv.civName, TradeOfferType.WarDeclaration, speed = civInfo.gameInfo.speed))
|
||||||
civToAsk.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
civToAsk.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,15 +224,15 @@ class CityConquestFunctions(val city: City) {
|
|||||||
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv)
|
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv)
|
||||||
.addModifier(DiplomaticModifiers.CapturedOurCities, respectForLiberatingOurCity)
|
.addModifier(DiplomaticModifiers.CapturedOurCities, respectForLiberatingOurCity)
|
||||||
val openBordersTrade = TradeLogic(foundingCiv, conqueringCiv)
|
val openBordersTrade = TradeLogic(foundingCiv, conqueringCiv)
|
||||||
openBordersTrade.currentTrade.ourOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement))
|
openBordersTrade.currentTrade.ourOffers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement, speed = conqueringCiv.gameInfo.speed))
|
||||||
openBordersTrade.acceptTrade(false)
|
openBordersTrade.acceptTrade(false)
|
||||||
} else {
|
} else {
|
||||||
//Liberating a city state gives a large amount of influence, and peace
|
//Liberating a city state gives a large amount of influence, and peace
|
||||||
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv).setInfluence(90f)
|
foundingCiv.getDiplomacyManagerOrMeet(conqueringCiv).setInfluence(90f)
|
||||||
if (foundingCiv.isAtWarWith(conqueringCiv)) {
|
if (foundingCiv.isAtWarWith(conqueringCiv)) {
|
||||||
val tradeLogic = TradeLogic(foundingCiv, conqueringCiv)
|
val tradeLogic = TradeLogic(foundingCiv, conqueringCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = conqueringCiv.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = conqueringCiv.gameInfo.speed))
|
||||||
tradeLogic.acceptTrade(false)
|
tradeLogic.acceptTrade(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,8 +482,8 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
// Make the peace treaty so that the civ can't declare war immedietly
|
// Make the peace treaty so that the civ can't declare war immedietly
|
||||||
val tradeLogic = TradeLogic(thirdCiv, otherCiv)
|
val tradeLogic = TradeLogic(thirdCiv, otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
thirdCivDiplo.trades.add(tradeLogic.currentTrade)
|
thirdCivDiplo.trades.add(tradeLogic.currentTrade)
|
||||||
thirdCivDiplo.otherCivDiplomacy().trades.add(tradeLogic.currentTrade.reverse())
|
thirdCivDiplo.otherCivDiplomacy().trades.add(tradeLogic.currentTrade.reverse())
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,21 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
|
|||||||
val offers = TradeOffersList()
|
val offers = TradeOffersList()
|
||||||
if (civInfo.isCityState && otherCivilization.isCityState) return offers
|
if (civInfo.isCityState && otherCivilization.isCityState) return offers
|
||||||
if (civInfo.isAtWarWith(otherCivilization))
|
if (civInfo.isAtWarWith(otherCivilization))
|
||||||
offers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty))
|
offers.add(TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
if (!otherCivilization.getDiplomacyManager(civInfo)!!.hasOpenBorders
|
if (!otherCivilization.getDiplomacyManager(civInfo)!!.hasOpenBorders
|
||||||
&& !otherCivilization.isCityState
|
&& !otherCivilization.isCityState
|
||||||
&& civInfo.hasUnique(UniqueType.EnablesOpenBorders)
|
&& civInfo.hasUnique(UniqueType.EnablesOpenBorders)
|
||||||
&& otherCivilization.hasUnique(UniqueType.EnablesOpenBorders)) {
|
&& otherCivilization.hasUnique(UniqueType.EnablesOpenBorders)) {
|
||||||
offers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement))
|
offers.add(TradeOffer(Constants.openBorders, TradeOfferType.Agreement, speed = civInfo.gameInfo.speed))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civInfo.diplomacyFunctions.canSignResearchAgreementNoCostWith(otherCivilization))
|
if (civInfo.diplomacyFunctions.canSignResearchAgreementNoCostWith(otherCivilization))
|
||||||
offers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty, civInfo.diplomacyFunctions.getResearchAgreementCost(otherCivilization)))
|
offers.add(TradeOffer(Constants.researchAgreement, TradeOfferType.Treaty,
|
||||||
|
civInfo.diplomacyFunctions.getResearchAgreementCost(otherCivilization), civInfo.gameInfo.speed))
|
||||||
|
|
||||||
if (civInfo.diplomacyFunctions.canSignDefensivePactWith(otherCivilization))
|
if (civInfo.diplomacyFunctions.canSignDefensivePactWith(otherCivilization))
|
||||||
offers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty))
|
offers.add(TradeOffer(Constants.defensivePact, TradeOfferType.Treaty, speed = civInfo.gameInfo.speed))
|
||||||
|
|
||||||
for (entry in civInfo.getCivResourcesWithOriginsForTrade()
|
for (entry in civInfo.getCivResourcesWithOriginsForTrade()
|
||||||
.filterNot { it.resource.resourceType == ResourceType.Bonus }
|
.filterNot { it.resource.resourceType == ResourceType.Bonus }
|
||||||
@ -42,17 +43,17 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
|
|||||||
) {
|
) {
|
||||||
val resourceTradeOfferType = if (entry.resource.resourceType == ResourceType.Luxury) TradeOfferType.Luxury_Resource
|
val resourceTradeOfferType = if (entry.resource.resourceType == ResourceType.Luxury) TradeOfferType.Luxury_Resource
|
||||||
else TradeOfferType.Strategic_Resource
|
else TradeOfferType.Strategic_Resource
|
||||||
offers.add(TradeOffer(entry.resource.name, resourceTradeOfferType, entry.amount))
|
offers.add(TradeOffer(entry.resource.name, resourceTradeOfferType, entry.amount, speed = civInfo.gameInfo.speed))
|
||||||
}
|
}
|
||||||
|
|
||||||
offers.add(TradeOffer("Gold", TradeOfferType.Gold, civInfo.gold))
|
offers.add(TradeOffer("Gold", TradeOfferType.Gold, civInfo.gold, speed = civInfo.gameInfo.speed))
|
||||||
offers.add(TradeOffer("Gold per turn", TradeOfferType.Gold_Per_Turn, civInfo.stats.statsForNextTurn.gold.toInt()))
|
offers.add(TradeOffer("Gold per turn", TradeOfferType.Gold_Per_Turn, civInfo.stats.statsForNextTurn.gold.toInt(), civInfo.gameInfo.speed))
|
||||||
|
|
||||||
if (!civInfo.isOneCityChallenger() && !otherCivilization.isOneCityChallenger()
|
if (!civInfo.isOneCityChallenger() && !otherCivilization.isOneCityChallenger()
|
||||||
&& !civInfo.isCityState && !otherCivilization.isCityState
|
&& !civInfo.isCityState && !otherCivilization.isCityState
|
||||||
) {
|
) {
|
||||||
for (city in civInfo.cities.filterNot { it.isCapital() || it.isInResistance() })
|
for (city in civInfo.cities.filterNot { it.isCapital() || it.isInResistance() })
|
||||||
offers.add(TradeOffer(city.id, TradeOfferType.City))
|
offers.add(TradeOffer(city.id, TradeOfferType.City, speed = civInfo.gameInfo.speed))
|
||||||
}
|
}
|
||||||
|
|
||||||
val otherCivsWeKnow = civInfo.getKnownCivs()
|
val otherCivsWeKnow = civInfo.getKnownCivs()
|
||||||
@ -62,7 +63,7 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
|
|||||||
val civsWeKnowAndTheyDont = otherCivsWeKnow
|
val civsWeKnowAndTheyDont = otherCivsWeKnow
|
||||||
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && !it.isDefeated() }
|
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && !it.isDefeated() }
|
||||||
for (thirdCiv in civsWeKnowAndTheyDont) {
|
for (thirdCiv in civsWeKnowAndTheyDont) {
|
||||||
offers.add(TradeOffer(thirdCiv.civName, TradeOfferType.Introduction))
|
offers.add(TradeOffer(thirdCiv.civName, TradeOfferType.Introduction, speed = civInfo.gameInfo.speed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ class TradeLogic(val ourCivilization: Civilization, val otherCivilization: Civil
|
|||||||
val civsWeArentAtWarWith = civsWeBothKnow
|
val civsWeArentAtWarWith = civsWeBothKnow
|
||||||
.filter { civInfo.getDiplomacyManager(it)!!.canDeclareWar() }
|
.filter { civInfo.getDiplomacyManager(it)!!.canDeclareWar() }
|
||||||
for (thirdCiv in civsWeArentAtWarWith) {
|
for (thirdCiv in civsWeArentAtWarWith) {
|
||||||
offers.add(TradeOffer(thirdCiv.civName, TradeOfferType.WarDeclaration))
|
offers.add(TradeOffer(thirdCiv.civName, TradeOfferType.WarDeclaration, speed = civInfo.gameInfo.speed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ data class TradeOffer(val name: String, val type: TradeOfferType, var amount: In
|
|||||||
name: String,
|
name: String,
|
||||||
type: TradeOfferType,
|
type: TradeOfferType,
|
||||||
amount: Int = 1,
|
amount: Int = 1,
|
||||||
speed: Speed = UncivGame.Current.gameInfo!!.speed
|
speed: Speed
|
||||||
) : this(name, type, amount, duration = -1) {
|
) : this(name, type, amount, duration = -1) {
|
||||||
duration = when {
|
duration = when {
|
||||||
type.isImmediate -> -1 // -1 for offers that are immediate (e.g. gold transfer)
|
type.isImmediate -> -1 // -1 for offers that are immediate (e.g. gold transfer)
|
||||||
|
@ -32,7 +32,6 @@ import com.unciv.ui.components.input.onClick
|
|||||||
import com.unciv.ui.components.widgets.ColorMarkupLabel
|
import com.unciv.ui.components.widgets.ColorMarkupLabel
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.popups.ConfirmPopup
|
import com.unciv.ui.popups.ConfirmPopup
|
||||||
import kotlin.reflect.typeOf
|
|
||||||
|
|
||||||
class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
|
class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
|
||||||
val viewingCiv = diplomacyScreen.viewingCiv
|
val viewingCiv = diplomacyScreen.viewingCiv
|
||||||
@ -250,16 +249,10 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
|
|||||||
) {
|
) {
|
||||||
val tradeLogic = TradeLogic(viewingCiv, otherCiv)
|
val tradeLogic = TradeLogic(viewingCiv, otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(
|
tradeLogic.currentTrade.ourOffers.add(
|
||||||
TradeOffer(
|
TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = viewingCiv.gameInfo.speed)
|
||||||
Constants.peaceTreaty,
|
|
||||||
TradeOfferType.Treaty
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
tradeLogic.currentTrade.theirOffers.add(
|
tradeLogic.currentTrade.theirOffers.add(
|
||||||
TradeOffer(
|
TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = viewingCiv.gameInfo.speed)
|
||||||
Constants.peaceTreaty,
|
|
||||||
TradeOfferType.Treaty
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
tradeLogic.acceptTrade()
|
tradeLogic.acceptTrade()
|
||||||
diplomacyScreen.updateLeftSideTable(otherCiv)
|
diplomacyScreen.updateLeftSideTable(otherCiv)
|
||||||
|
@ -106,7 +106,7 @@ class MajorCivDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
|
|||||||
val negotiatePeaceButton = "Negotiate Peace".toTextButton()
|
val negotiatePeaceButton = "Negotiate Peace".toTextButton()
|
||||||
negotiatePeaceButton.onClick {
|
negotiatePeaceButton.onClick {
|
||||||
val tradeTable = diplomacyScreen.setTrade(otherCiv)
|
val tradeTable = diplomacyScreen.setTrade(otherCiv)
|
||||||
val peaceTreaty = TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty)
|
val peaceTreaty = TradeOffer(Constants.peaceTreaty, TradeOfferType.Treaty, speed = viewingCiv.gameInfo.speed)
|
||||||
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
||||||
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
||||||
tradeTable.offerColumnsTable.update()
|
tradeTable.offerColumnsTable.update()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.ui.screens.worldscreen.status
|
package com.unciv.ui.screens.worldscreen.status
|
||||||
|
|
||||||
import com.unciv.GUI
|
|
||||||
import com.unciv.logic.civilization.managers.TurnManager
|
import com.unciv.logic.civilization.managers.TurnManager
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
|
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
|
||||||
@ -14,14 +13,12 @@ import com.unciv.ui.images.IconTextButton
|
|||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.popups.hasOpenPopups
|
import com.unciv.ui.popups.hasOpenPopups
|
||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
import com.unciv.utils.Concurrency
|
|
||||||
|
|
||||||
class NextTurnButton(
|
class NextTurnButton(
|
||||||
private val worldScreen: WorldScreen
|
private val worldScreen: WorldScreen
|
||||||
) : IconTextButton("", null, 30) {
|
) : IconTextButton("", null, 30) {
|
||||||
private var nextTurnAction = NextTurnAction.Default
|
private var nextTurnAction = NextTurnAction.Default
|
||||||
init {
|
init {
|
||||||
// label.setFontSize(30)
|
|
||||||
labelCell.pad(10f)
|
labelCell.pad(10f)
|
||||||
onActivation { nextTurnAction.action(worldScreen) }
|
onActivation { nextTurnAction.action(worldScreen) }
|
||||||
onRightClick { NextTurnMenu(stage, this, this, worldScreen) }
|
onRightClick { NextTurnMenu(stage, this, this, worldScreen) }
|
||||||
@ -62,5 +59,5 @@ class NextTurnButton(
|
|||||||
|
|
||||||
private fun getNextTurnAction(worldScreen: WorldScreen) =
|
private fun getNextTurnAction(worldScreen: WorldScreen) =
|
||||||
// Guaranteed to return a non-null NextTurnAction because the last isChoice always returns true
|
// Guaranteed to return a non-null NextTurnAction because the last isChoice always returns true
|
||||||
NextTurnAction.values().first { it.isChoice(worldScreen) }
|
NextTurnAction.entries.first { it.isChoice(worldScreen) }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user