Fixed "other civ doesn't get duration on timed trades" bug

This commit is contained in:
Yair Morgenstern 2020-03-21 21:27:11 +02:00
parent 56c547886c
commit b28a247bd0
2 changed files with 12 additions and 7 deletions

View file

@ -10,6 +10,8 @@ By rh-github-2015:
Unit purchasing limits - by EdinCitaku
Unit Action buttons stick to the left
Translation updates
## 3.6.9

View file

@ -5,16 +5,19 @@ 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, var amount:Int=1) {
data class TradeOffer(var name:String, var type: TradeType, var amount:Int=1, var duration:Int=0) {
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()
init {
// Duration needs to be part of the variables defined at the top, so that it will be copied over with copy()
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()
}
}
}
constructor() : this("", TradeType.Gold) // so that the json deserializer can work
fun equals(offer: TradeOffer): Boolean {
return offer.name==name
&& offer.type==type