diff --git a/android/assets/jsons/translationsByLanguage/French.properties b/android/assets/jsons/translationsByLanguage/French.properties index 18c03ade56..36b573e4c9 100644 --- a/android/assets/jsons/translationsByLanguage/French.properties +++ b/android/assets/jsons/translationsByLanguage/French.properties @@ -834,6 +834,9 @@ Happiness = Bonheur Production = Production Culture = Culture Food = Nourriture +Crop Yield = Récolte +Land = Territoire +Force = Puissance GOLDEN AGE = ÂGE D'OR Golden Age = Age d'or [year] BC = [year] avant J.C. @@ -986,6 +989,7 @@ Built Apollo Program = Construit le programme Apollo Destroy [civName] = Détruire [civName] Our status = Notre situation Global status = Situation globale +Rankings = Classements Spaceship parts remaining = Parties de Vaisseau spatial manquantes Branches completed = Branches complêtées Undefeated civs = Civilization invaincues diff --git a/android/assets/jsons/translationsByLanguage/Russian.properties b/android/assets/jsons/translationsByLanguage/Russian.properties index c2e1b15743..a6cd0e3c51 100644 --- a/android/assets/jsons/translationsByLanguage/Russian.properties +++ b/android/assets/jsons/translationsByLanguage/Russian.properties @@ -834,6 +834,9 @@ Happiness = Счастье Production = Производство Culture = Культура Food = Еда +Crop Yield = Урожай +Land = Земля +Force = Сила GOLDEN AGE = ЗОЛОТОЙ ВЕК Golden Age = Золотой век [year] BC = [year] до н.э. @@ -987,6 +990,7 @@ Built Apollo Program = Построена Программа Аполлон Destroy [civName] = Уничтожить [civName] Our status = Наш статус Global status = Глобальный статус +Rankings = Рейтинги Spaceship parts remaining = Осталось частей КК Branches completed = Ветвей завершено Undefeated civs = Непобеждённые цивилизации diff --git a/android/assets/jsons/translationsByLanguage/Ukrainian.properties b/android/assets/jsons/translationsByLanguage/Ukrainian.properties index 3203997429..808dd8d94a 100644 --- a/android/assets/jsons/translationsByLanguage/Ukrainian.properties +++ b/android/assets/jsons/translationsByLanguage/Ukrainian.properties @@ -838,6 +838,9 @@ Happiness = Щастя Production = Виробництво Culture = Культура Food = Їжа +Crop Yield = Врожай +Land = Земля +Force = Сила GOLDEN AGE = ЗОЛОТА ДОБА Golden Age = Золота доба [year] BC = [year] до н.е. @@ -991,6 +994,7 @@ Built Apollo Program = Здійснити Програму Аполлон Destroy [civName] = Знищити [civName] Our status = Наш стан Global status = Глобальний стан +Rankings = Рейтинги Spaceship parts remaining = Залишилось частин космічного корабля Branches completed = Галузей завершено Undefeated civs = Непереможені цивілізації diff --git a/android/assets/jsons/translationsByLanguage/template.properties b/android/assets/jsons/translationsByLanguage/template.properties index d48a9ecd61..5352065076 100644 --- a/android/assets/jsons/translationsByLanguage/template.properties +++ b/android/assets/jsons/translationsByLanguage/template.properties @@ -834,6 +834,9 @@ Happiness = Production = Culture = Food = +Crop Yield = +Land = +Force = GOLDEN AGE = Golden Age = [year] BC = @@ -987,6 +990,7 @@ Built Apollo Program = Destroy [civName] = Our status = Global status = +Rankings = Spaceship parts remaining = Branches completed = Undefeated civs = diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index d042531e80..5a998b242d 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -25,6 +25,7 @@ import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.stats.Stats import com.unciv.models.translations.tr +import com.unciv.ui.victoryscreen.RankingType import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap @@ -41,7 +42,7 @@ class CivilizationInfo { * Instead, we create a copy list with the change, and replace this list. * The other solution, casting toList() every "get", has a performance cost */ - @Transient private var units=listOf() + @Transient private var units = listOf() @Transient var viewableTiles = setOf() @Transient var viewableInvisibleUnitsTiles = setOf() @@ -165,8 +166,6 @@ class CivilizationInfo { statsForNextTurn = stats().getStatMapForNextTurn().values.toList().reduce{a,b->a+b} } - - fun getHappiness() = stats().getHappinessBreakdown().values.sum().roundToInt() @@ -329,6 +328,21 @@ class CivilizationInfo { && !diplomacyManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.ResearchAgreement) && gold >= cost && otherCiv.gold >= cost } + + fun getStatForRanking(category: RankingType) : Int { + return when(category) { + RankingType.Population -> cities.sumBy { it.population.population } + RankingType.CropYield -> statsForNextTurn.food.roundToInt() + RankingType.Production -> statsForNextTurn.production.roundToInt() + RankingType.Gold -> gold + RankingType.Land -> cities.sumBy { it.tiles.size } + RankingType.Force -> units.sumBy { it.baseUnit.strength } + RankingType.Happiness -> getHappiness() + RankingType.Technologies -> tech.researchedTechnologies.size + RankingType.Culture -> policies.storedCulture + } + } + //endregion //region state-changing functions diff --git a/core/src/com/unciv/ui/victoryscreen/RankingType.kt b/core/src/com/unciv/ui/victoryscreen/RankingType.kt new file mode 100644 index 0000000000..94a4c4d621 --- /dev/null +++ b/core/src/com/unciv/ui/victoryscreen/RankingType.kt @@ -0,0 +1,13 @@ +package com.unciv.ui.victoryscreen + +enum class RankingType (val value: String) { + Population("Population"), + CropYield("Crop Yield"), + Production("Production"), + Gold("Gold"), + Land("Land"), + Force("Force"), + Happiness("Happiness"), + Technologies("Technologies"), + Culture("Culture") + } \ No newline at end of file diff --git a/core/src/com/unciv/ui/VictoryScreen.kt b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt similarity index 84% rename from core/src/com/unciv/ui/VictoryScreen.kt rename to core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt index fd249e421e..6bb58c6b2f 100644 --- a/core/src/com/unciv/ui/VictoryScreen.kt +++ b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt @@ -1,4 +1,4 @@ -package com.unciv.ui +package com.unciv.ui.victoryscreen import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Table @@ -7,6 +7,7 @@ import com.unciv.UncivGame import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.ruleset.VictoryType import com.unciv.models.translations.tr +import com.unciv.ui.EmpireOverviewScreen import com.unciv.ui.newgamescreen.NewGameScreen import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.utils.addSeparator @@ -16,14 +17,14 @@ import com.unciv.ui.utils.toLabel class VictoryScreen : PickerScreen() { - val playerCivInfo = UncivGame.Current.gameInfo.getPlayerToViewAs() + private val playerCivInfo = UncivGame.Current.gameInfo.getPlayerToViewAs() val victoryTypes = playerCivInfo.gameInfo.gameParameters.victoryTypes - val scientificVictoryEnabled = victoryTypes.contains(VictoryType.Scientific) - val culturalVictoryEnabled = victoryTypes.contains(VictoryType.Cultural) - val dominationVictoryEnabled = victoryTypes.contains(VictoryType.Domination) + private val scientificVictoryEnabled = victoryTypes.contains(VictoryType.Scientific) + private val culturalVictoryEnabled = victoryTypes.contains(VictoryType.Cultural) + private val dominationVictoryEnabled = victoryTypes.contains(VictoryType.Domination) - val contentsTable = Table() + private val contentsTable = Table() init { val tabsTable = Table().apply { defaults().pad(10f) } @@ -33,6 +34,9 @@ class VictoryScreen : PickerScreen() { val setGlobalVictoryButton = TextButton("Global status".tr(),skin) setGlobalVictoryButton .onClick { setGlobalVictoryTable() } tabsTable.add(setGlobalVictoryButton) + val setCivRankingsButton = TextButton("Rankings".tr(),skin) + setCivRankingsButton.onClick { setCivRankingsTable() } + tabsTable.add(setCivRankingsButton) topTable.add(tabsTable) topTable.addSeparator() topTable.add(contentsTable) @@ -72,7 +76,7 @@ class VictoryScreen : PickerScreen() { } - fun wonOrLost(description: String) { + private fun wonOrLost(description: String) { val endGameMessage = when(description){ "You have won a cultural victory!" -> "You have achieved victory through the awesome power of your Culture. Your civilization's greatness - the magnificence of its monuments and the power of its artists - have astounded the world! Poets will honor you as long as beauty brings gladness to a weary heart." @@ -98,7 +102,7 @@ class VictoryScreen : PickerScreen() { } - fun setMyVictoryTable(){ + private fun setMyVictoryTable() { val myVictoryStatusTable = Table() myVictoryStatusTable.defaults().pad(10f) if(scientificVictoryEnabled) myVictoryStatusTable.add("Science victory".toLabel()) @@ -117,7 +121,7 @@ class VictoryScreen : PickerScreen() { contentsTable.add(myVictoryStatusTable) } - fun scienceVictoryColumn():Table{ + private fun scienceVictoryColumn():Table { val t = Table() t.defaults().pad(5f) t.add(getMilestone("Built Apollo Program",playerCivInfo.containsBuildingUnique("Enables construction of Spaceship parts"))).row() @@ -131,7 +135,7 @@ class VictoryScreen : PickerScreen() { return t } - fun culturalVictoryColumn():Table{ + private fun culturalVictoryColumn():Table { val t=Table() t.defaults().pad(5f) for(branch in playerCivInfo.gameInfo.ruleSet.policyBranches.values) { @@ -141,7 +145,7 @@ class VictoryScreen : PickerScreen() { return t } - fun conquestVictoryColumn():Table{ + private fun conquestVictoryColumn():Table { val table=Table() table.defaults().pad(5f) for (civ in playerCivInfo.gameInfo.civilizations) { @@ -201,7 +205,7 @@ class VictoryScreen : PickerScreen() { .sortedByDescending { it.branchesCompleted } for (entry in civsToBranchesCompleted) { - val civToBranchesHaveCompleted=EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo) + val civToBranchesHaveCompleted= EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo) policyVictoryColumn.add(civToBranchesHaveCompleted).row() } return policyVictoryColumn @@ -226,4 +230,24 @@ class VictoryScreen : PickerScreen() { return scientificVictoryColumn } + private fun setCivRankingsTable() { + val majorCivs = game.gameInfo.civilizations.filter { it.isMajorCiv() } + val civRankingsTable = Table().apply { defaults().pad(5f) } + + for( category in RankingType.values()) { + val column = Table().apply { defaults().pad(5f) } + column.add(category.value.toLabel()).row() + column.addSeparator() + + for (civ in majorCivs.sortedByDescending { it.getStatForRanking(category) }) { + column.add(EmpireOverviewScreen.getCivGroup(civ, " : " + civ.getStatForRanking(category).toString(), playerCivInfo)).row() + } + + civRankingsTable.add(column) + } + + contentsTable.clear() + contentsTable.add(civRankingsTable) + } + } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index c5aa7b9e1a..705ac84c35 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -20,7 +20,7 @@ import com.unciv.models.UncivSound import com.unciv.models.ruleset.tile.ResourceType import com.unciv.models.ruleset.unit.UnitType import com.unciv.models.translations.tr -import com.unciv.ui.VictoryScreen +import com.unciv.ui.victoryscreen.VictoryScreen import com.unciv.ui.cityscreen.CityScreen import com.unciv.ui.pickerscreens.GreatPersonPickerScreen import com.unciv.ui.pickerscreens.PolicyPickerScreen diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt index 8d5166528e..41a60166bb 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/WorldScreenMenuPopup.kt @@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color import com.unciv.UncivGame import com.unciv.models.translations.tr import com.unciv.ui.CivilopediaScreen -import com.unciv.ui.VictoryScreen +import com.unciv.ui.victoryscreen.VictoryScreen import com.unciv.ui.MultiplayerScreen import com.unciv.ui.mapeditor.LoadMapScreen import com.unciv.ui.mapeditor.NewMapScreen