Turn number of trade changes with game speed. (#2123)
This commit is contained in:
parent
c64b359fb5
commit
1564856391
5 changed files with 33 additions and 39 deletions
|
@ -147,7 +147,7 @@ class NextTurnAutomation{
|
|||
tradeLogic.currentTrade.theirOffers.add(theirOffer)
|
||||
} else if (ourGold / 2 >= theirValue) {
|
||||
//try to buy tech with money, not spending more than 1/3 of treasury
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, theirValue))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, theirValue))
|
||||
tradeLogic.currentTrade.theirOffers.add(theirOffer)
|
||||
ourGold -= theirValue
|
||||
}
|
||||
|
@ -322,20 +322,13 @@ class NextTurnAutomation{
|
|||
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedResearchAgreement) }
|
||||
.sortedByDescending { it.statsForNextTurn.science }
|
||||
|
||||
val duration = when (civInfo.gameInfo.gameParameters.gameSpeed) {
|
||||
GameSpeed.Quick -> 25
|
||||
GameSpeed.Standard -> 30
|
||||
GameSpeed.Epic -> 45
|
||||
GameSpeed.Marathon -> 90
|
||||
}
|
||||
|
||||
for (otherCiv in canSignResearchAgreementCiv) {
|
||||
// Default setting is 5, this will be changed according to different civ.
|
||||
if ((1..10).random() > 5) continue
|
||||
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
||||
val cost = civInfo.getResearchAgreementCost(otherCiv)
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, cost))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, cost))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost))
|
||||
|
||||
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||
}
|
||||
|
@ -360,8 +353,8 @@ class NextTurnAutomation{
|
|||
// pay for peace
|
||||
val tradeLogic = TradeLogic(civInfo, enemy)
|
||||
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
|
||||
if (civInfo.gold > 0) {
|
||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo, enemy)
|
||||
|
@ -369,7 +362,7 @@ class NextTurnAutomation{
|
|||
moneyWeNeedToPay = civInfo.gold
|
||||
}
|
||||
if (moneyWeNeedToPay > 0) {
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, moneyWeNeedToPay))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -463,8 +463,8 @@ class CityInfo {
|
|||
foundingCiv.getDiplomacyManager(conqueringCiv).influence = 90f
|
||||
if (foundingCiv.isAtWarWith(conqueringCiv)) {
|
||||
val tradeLogic = TradeLogic(foundingCiv, conqueringCiv)
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
tradeLogic.acceptTrade()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
val offers = TradeOffersList()
|
||||
if (civInfo.isCityState() && otherCivilization.isCityState()) return offers
|
||||
if(civInfo.isAtWarWith(otherCivilization))
|
||||
offers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
offers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
|
||||
if(!otherCivilization.getDiplomacyManager(civInfo).hasOpenBorders
|
||||
&& !otherCivilization.isCityState()
|
||||
|
@ -26,30 +26,30 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements")) {
|
||||
val relationshipLevel = otherCivilization.getDiplomacyManager(civInfo).relationshipLevel()
|
||||
|
||||
offers.add(TradeOffer(Constants.openBorders, TradeType.Agreement, 30))
|
||||
offers.add(TradeOffer(Constants.openBorders, TradeType.Agreement))
|
||||
}
|
||||
|
||||
for(entry in civInfo.getCivResources()
|
||||
.filterNot { it.resource.resourceType == ResourceType.Bonus }) {
|
||||
val resourceTradeType = if(entry.resource.resourceType== ResourceType.Luxury) TradeType.Luxury_Resource
|
||||
else TradeType.Strategic_Resource
|
||||
offers.add(TradeOffer(entry.resource.name, resourceTradeType, 30, entry.amount))
|
||||
offers.add(TradeOffer(entry.resource.name, resourceTradeType, entry.amount))
|
||||
}
|
||||
if (!civInfo.isCityState() && !otherCivilization.isCityState()) {
|
||||
for (entry in civInfo.tech.techsResearched
|
||||
.filterNot { otherCivilization.tech.isResearched(it) }
|
||||
.filter { otherCivilization.tech.canBeResearched(it) }) {
|
||||
offers.add(TradeOffer(entry, TradeType.Technology, 0))
|
||||
offers.add(TradeOffer(entry, TradeType.Technology))
|
||||
}
|
||||
}
|
||||
|
||||
offers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, civInfo.gold))
|
||||
offers.add(TradeOffer("Gold per turn".tr(), TradeType.Gold_Per_Turn, 30, civInfo.statsForNextTurn.gold.toInt()))
|
||||
offers.add(TradeOffer("Gold".tr(), TradeType.Gold, civInfo.gold))
|
||||
offers.add(TradeOffer("Gold per turn".tr(), TradeType.Gold_Per_Turn, civInfo.statsForNextTurn.gold.toInt()))
|
||||
|
||||
if (!civInfo.isOneCityChallenger() && !otherCivilization.isOneCityChallenger()
|
||||
&& !civInfo.isCityState() && !otherCivilization.isCityState()) {
|
||||
for (city in civInfo.cities.filterNot { it.isCapital() })
|
||||
offers.add(TradeOffer(city.id, TradeType.City, 0))
|
||||
offers.add(TradeOffer(city.id, TradeType.City))
|
||||
}
|
||||
|
||||
val otherCivsWeKnow = civInfo.getKnownCivs()
|
||||
|
@ -58,7 +58,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && !it.isDefeated() }
|
||||
|
||||
for (thirdCiv in civsWeKnowAndTheyDont) {
|
||||
offers.add(TradeOffer(thirdCiv.civName, TradeType.Introduction, 0))
|
||||
offers.add(TradeOffer(thirdCiv.civName, TradeType.Introduction))
|
||||
}
|
||||
|
||||
if (!civInfo.isCityState() && !otherCivilization.isCityState()) {
|
||||
|
@ -67,7 +67,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
val civsWeArentAtWarWith = civsWeBothKnow
|
||||
.filter { civInfo.getDiplomacyManager(it).diplomaticStatus == DiplomaticStatus.Peace }
|
||||
for (thirdCiv in civsWeArentAtWarWith) {
|
||||
offers.add(TradeOffer(thirdCiv.civName, TradeType.WarDeclaration, 0))
|
||||
offers.add(TradeOffer(thirdCiv.civName, TradeType.WarDeclaration))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package com.unciv.logic.trade
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.metadata.GameSpeed
|
||||
import com.unciv.models.translations.tr
|
||||
|
||||
data class TradeOffer(var name:String, var type: TradeType,
|
||||
/** 0 for offers that are immediate (e.g. gold transfer) */ var duration:Int, var amount:Int=1) {
|
||||
|
||||
constructor() : this("", TradeType.Gold,0,0) // so that the json deserializer can work
|
||||
data class TradeOffer(var name:String, var type: TradeType, var amount:Int=1) {
|
||||
|
||||
constructor() : this("", TradeType.Gold) // so that the json deserializer can work
|
||||
var duration = when(type){
|
||||
TradeType.Gold, TradeType.Technology, TradeType.Introduction, TradeType.WarDeclaration, TradeType.City -> 0 /** 0 for offers that are immediate (e.g. gold transfer) */
|
||||
else -> when(UncivGame.Current.gameInfo.gameParameters.gameSpeed){
|
||||
GameSpeed.Quick -> if (name==Constants.peaceTreaty) 10 else 25
|
||||
else -> ((if (name==Constants.peaceTreaty) 10 else 30) * UncivGame.Current.gameInfo.gameParameters.gameSpeed.modifier).toInt()
|
||||
}
|
||||
}
|
||||
fun equals(offer: TradeOffer): Boolean {
|
||||
return offer.name==name
|
||||
&& offer.type==type
|
||||
|
|
|
@ -153,8 +153,8 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||
peaceButton.onClick {
|
||||
YesNoPopup("Peace with [${otherCiv.civName}]?".tr(), {
|
||||
val tradeLogic = TradeLogic(viewingCiv, otherCiv)
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty))
|
||||
tradeLogic.acceptTrade()
|
||||
updateLeftSideTable()
|
||||
updateRightSide(otherCiv)
|
||||
|
@ -200,7 +200,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||
val negotiatePeaceButton = TextButton("Negotiate Peace".tr(),skin)
|
||||
negotiatePeaceButton.onClick {
|
||||
val tradeTable = setTrade(otherCiv)
|
||||
val peaceTreaty = TradeOffer(Constants.peaceTreaty,TradeType.Treaty,30)
|
||||
val peaceTreaty = TradeOffer(Constants.peaceTreaty,TradeType.Treaty)
|
||||
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
||||
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
||||
tradeTable.offerColumnsTable.update()
|
||||
|
@ -234,14 +234,8 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||
val requiredGold = viewingCiv.getResearchAgreementCost(otherCiv)
|
||||
researchAgreementButton.onClick {
|
||||
val tradeTable = setTrade(otherCiv)
|
||||
val duration = when(viewingCiv.gameInfo.gameParameters.gameSpeed) {
|
||||
GameSpeed.Quick -> 25
|
||||
GameSpeed.Standard -> 30
|
||||
GameSpeed.Epic -> 45
|
||||
GameSpeed.Marathon -> 90
|
||||
}
|
||||
val researchAgreement = TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, requiredGold)
|
||||
val goldCostOfSignResearchAgreement = TradeOffer("Gold".tr(), TradeType.Gold, 0, -requiredGold)
|
||||
val researchAgreement = TradeOffer(Constants.researchAgreement, TradeType.Treaty, requiredGold)
|
||||
val goldCostOfSignResearchAgreement = TradeOffer("Gold".tr(), TradeType.Gold, -requiredGold)
|
||||
tradeTable.tradeLogic.currentTrade.theirOffers.add(researchAgreement)
|
||||
tradeTable.tradeLogic.ourAvailableOffers.add(researchAgreement)
|
||||
tradeTable.tradeLogic.ourAvailableOffers.add(goldCostOfSignResearchAgreement)
|
||||
|
|
Loading…
Reference in a new issue