mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-29 22:29:15 +07:00
Better victory data @touhidurrr
This commit is contained in:
@ -61,6 +61,10 @@ data class CompatibilityVersion(
|
||||
|
||||
}
|
||||
|
||||
data class VictoryData(val winningCiv:String, val victoryType:String, val victoryTurn:Int){
|
||||
constructor(): this("","",0) // for serializer
|
||||
}
|
||||
|
||||
class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion {
|
||||
companion object {
|
||||
/** The current compatibility version of [GameInfo]. This number is incremented whenever changes are made to the save file structure that guarantee that
|
||||
@ -88,9 +92,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
var currentTurnStartTime = 0L
|
||||
var gameId = UUID.randomUUID().toString() // random string
|
||||
|
||||
var winningCiv:String? = null
|
||||
var victoryTurn = 0
|
||||
var victoryType:String? = null
|
||||
var victoryData:VictoryData? = null
|
||||
|
||||
// Maps a civ to the civ they voted for
|
||||
var diplomaticVictoryVotesCast = HashMap<String, String>()
|
||||
@ -154,6 +156,8 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
toReturn.diplomaticVictoryVotesCast.putAll(diplomaticVictoryVotesCast)
|
||||
toReturn.oneMoreTurnMode = oneMoreTurnMode
|
||||
toReturn.customSaveLocation = customSaveLocation
|
||||
toReturn.victoryData = victoryData
|
||||
|
||||
return toReturn
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.unciv.json.HashMapVector2
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.logic.UncivShowableException
|
||||
import com.unciv.logic.VictoryData
|
||||
import com.unciv.logic.automation.civilization.NextTurnAutomation
|
||||
import com.unciv.logic.automation.unit.WorkerAutomation
|
||||
import com.unciv.logic.city.CityInfo
|
||||
@ -973,12 +974,10 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun updateWinningCiv(){
|
||||
if (gameInfo.winningCiv == null) {
|
||||
if (gameInfo.victoryData == null) {
|
||||
val victoryType = victoryManager.getVictoryTypeAchieved()
|
||||
if (victoryType != null) {
|
||||
gameInfo.winningCiv = civName
|
||||
gameInfo.victoryType = victoryType
|
||||
gameInfo.victoryTurn = gameInfo.turns
|
||||
gameInfo.victoryData = VictoryData(civName, victoryType, gameInfo.turns)
|
||||
|
||||
for (civInfo in gameInfo.civilizations)
|
||||
civInfo.popupAlerts.add(PopupAlert(AlertType.GameHasBeenWon, civName))
|
||||
|
@ -314,9 +314,8 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
}
|
||||
AlertType.RecapturedCivilian -> addRecapturedCivilianTable()
|
||||
AlertType.GameHasBeenWon -> {
|
||||
val civInfo = worldScreen.viewingCiv
|
||||
val winningCiv = civInfo.gameInfo.winningCiv!!
|
||||
addGoodSizedLabel("[$winningCiv] has won a [${civInfo.gameInfo.victoryType}] Victory!").row()
|
||||
val victoryData = worldScreen.viewingCiv.gameInfo.victoryData!!
|
||||
addGoodSizedLabel("[${victoryData.winningCiv}] has won a [${victoryData.victoryType}] Victory!").row()
|
||||
addButton("Victory status"){ close(); worldScreen.game.pushScreen(VictoryScreen(worldScreen)) }.row()
|
||||
add(getCloseButton(Constants.close))
|
||||
}
|
||||
|
Reference in New Issue
Block a user