mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Fix uninitialized lateinit access in TradeOffer (#4159)
This commit is contained in:
parent
d0227a2306
commit
625c4c9139
@ -12,12 +12,17 @@ data class TradeOffer(val name:String, val type:TradeType, var amount:Int = 1, v
|
|||||||
init {
|
init {
|
||||||
// Duration needs to be part of the variables defined in the primary constructor,
|
// Duration needs to be part of the variables defined in the primary constructor,
|
||||||
// so that it will be copied over with the automatically generated copy()
|
// so that it will be copied over with the automatically generated copy()
|
||||||
val gameSpeed = UncivGame.Current.gameInfo.gameParameters.gameSpeed
|
|
||||||
duration = when {
|
duration =
|
||||||
type.isImmediate -> -1 // -1 for offers that are immediate (e.g. gold transfer)
|
if (type.isImmediate) -1 // -1 for offers that are immediate (e.g. gold transfer)
|
||||||
name == Constants.peaceTreaty -> 10
|
else {
|
||||||
gameSpeed == GameSpeed.Quick -> 25
|
// Do *not* access UncivGame.Current.gameInfo in the default constructor!
|
||||||
else -> (30 * gameSpeed.modifier).toInt()
|
val gameSpeed = UncivGame.Current.gameInfo.gameParameters.gameSpeed
|
||||||
|
when {
|
||||||
|
name == Constants.peaceTreaty -> 10
|
||||||
|
gameSpeed == GameSpeed.Quick -> 25
|
||||||
|
else -> (30 * gameSpeed.modifier).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user