Moddable game speed backwards compatibility (#7212)

* Move GameSpeed definition to JSON files

* Minor cleanup and some corrections

* Round down tribute gold to match old when statement

* Small variable name changes

* Some typos

* Reduce number of speed modifiers plus code improvements

* Catch missing game speed

* Found a better place for the check

* More tweaks

* Added a startYear mod constant and some tweaks

* Cleanup old GameSpeed file references

* Fix tests

* Add game speeds civilopedia page

* Remove one last todo

* Fix translation

* New icon for game speeds

* More game speed modifiers

* Fix error

* Update Speeds.json files and move tutorial to docs

* Rename GameSpeed class to Speed

* Rename GameSpeed -> Speed and other reviews

* Forgot a file

* Add start year to civilopedia

* Remove decimal from default starting years

* Fix backwards compatibility

* Unused import

Co-authored-by: OptimizedForDensity <>
This commit is contained in:
OptimizedForDensity
2022-06-19 03:23:56 -04:00
committed by GitHub
parent 9683e27526
commit 4955d35efb
3 changed files with 14 additions and 0 deletions

View File

@ -218,4 +218,12 @@ object BackwardCompatibility {
} }
return false return false
} }
@Suppress("DEPRECATION")
fun GameInfo.convertOldGameSpeed() {
if (gameParameters.gameSpeed != "" && gameParameters.gameSpeed in ruleSet.speeds.keys) {
gameParameters.speed = gameParameters.gameSpeed
gameParameters.gameSpeed = ""
}
}
} }

View File

@ -3,6 +3,7 @@ package com.unciv.logic
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.logic.BackwardCompatibility.convertFortify import com.unciv.logic.BackwardCompatibility.convertFortify
import com.unciv.logic.BackwardCompatibility.convertOldGameSpeed
import com.unciv.utils.debug import com.unciv.utils.debug
import com.unciv.logic.BackwardCompatibility.guaranteeUnitPromotions import com.unciv.logic.BackwardCompatibility.guaranteeUnitPromotions
import com.unciv.logic.BackwardCompatibility.migrateBarbarianCamps import com.unciv.logic.BackwardCompatibility.migrateBarbarianCamps
@ -399,6 +400,8 @@ class GameInfo {
updateGreatGeneralUniques() updateGreatGeneralUniques()
convertOldGameSpeed()
for (baseUnit in ruleSet.units.values) for (baseUnit in ruleSet.units.values)
baseUnit.ruleset = ruleSet baseUnit.ruleset = ruleSet

View File

@ -11,6 +11,9 @@ enum class BaseRuleset(val fullName:String){
class GameParameters { // Default values are the default new game class GameParameters { // Default values are the default new game
var difficulty = "Prince" var difficulty = "Prince"
var speed = Speed.DEFAULT var speed = Speed.DEFAULT
@Deprecated("Since 4.1.11")
var gameSpeed = ""
var players = ArrayList<Player>().apply { var players = ArrayList<Player>().apply {
add(Player().apply { playerType = PlayerType.Human }) add(Player().apply { playerType = PlayerType.Human })
for (i in 1..3) add(Player()) for (i in 1..3) add(Player())