mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 08:39:37 +07:00
multiple game support for TurnChecker (#3540)
* TurnChecker now checks every multiplayer game Not just the currently open game * Adding game saving to turn checker so multiplayerScreen stays up to date * remove unused imports * removing unused functions
This commit is contained in:
@ -77,6 +77,15 @@ object GameSaver {
|
||||
return game
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING! transitive GameInfo data not initialized
|
||||
* The returned GameInfo can not be used for most circumstances because its not initialized!
|
||||
* It is therefore stateless and save to call for Multiplayer Turn Notifier, unlike gameInfoFromString().
|
||||
*/
|
||||
fun gameInfoFromStringWithoutTransients(gameData: String): GameInfo {
|
||||
return json().fromJson(GameInfo::class.java, gameData)
|
||||
}
|
||||
|
||||
fun deleteSave(GameName: String, multiplayer: Boolean = false){
|
||||
getSave(GameName, multiplayer).delete()
|
||||
}
|
||||
@ -155,13 +164,12 @@ object GameSaver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current turn's player from GameInfo JSON-String for multiplayer.
|
||||
* Returns the gameId from a GameInfo which was saved as JSON for multiplayer
|
||||
* Does not initialize transitive GameInfo data.
|
||||
* It is therefore stateless and save to call for Multiplayer Turn Notifier, unlike gameInfoFromString().
|
||||
* It is therefore stateless and save to call for Multiplayer Turn Notifier.
|
||||
*/
|
||||
fun currentTurnCivFromString(gameData: String): CivilizationInfo {
|
||||
val game = json().fromJson(GameInfo::class.java, gameData)
|
||||
return game.getCivilization(game.currentPlayer)
|
||||
fun getGameIdFromFile(gameFile: FileHandle): String {
|
||||
return json().fromJson(GameInfo::class.java, gameFile).gameId
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,13 +127,13 @@ class OnlineMultiplayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current turn's player.
|
||||
* WARNING!
|
||||
* Does not initialize transitive GameInfo data.
|
||||
* It is therefore stateless and save to call for Multiplayer Turn Notifier, unlike tryDownloadGame().
|
||||
*/
|
||||
fun tryDownloadCurrentTurnCiv(gameId: String): CivilizationInfo {
|
||||
fun tryDownloadGameUninitialized(gameId: String): GameInfo {
|
||||
val zippedGameInfo = DropBox.downloadFileAsString(getGameLocation(gameId))
|
||||
return GameSaver.currentTurnCivFromString(Gzip.unzip(zippedGameInfo))
|
||||
return GameSaver.gameInfoFromStringWithoutTransients(Gzip.unzip(zippedGameInfo))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user