mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 17:32:57 +07:00
Added global victory status to victory status screen, so you can see how bad the AI is at actually winning... -_-
This commit is contained in:
parent
29f2474b13
commit
ea5f649d87
@ -4,30 +4,34 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.pickerscreens.PickerScreen
|
||||
import com.unciv.ui.utils.addSeparator
|
||||
import com.unciv.ui.utils.enable
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.toLabel
|
||||
|
||||
class VictoryScreen : PickerScreen() {
|
||||
|
||||
val playerCivInfo = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||
|
||||
val contentsTable = Table()
|
||||
|
||||
init {
|
||||
topTable.skin=skin
|
||||
topTable.defaults().pad(10f)
|
||||
topTable.add("Science victory".tr())
|
||||
topTable.add("Cultural victory".tr())
|
||||
topTable.add("Conquest victory".tr())
|
||||
topTable.row()
|
||||
topTable.add(scienceVictoryColumn())
|
||||
topTable.add(culturalVictoryColumn())
|
||||
topTable.add(conquestVictoryColumn())
|
||||
topTable.row()
|
||||
topTable.add("Complete all the spaceship parts\n to win!".tr())
|
||||
topTable.add("Complete 4 policy branches\n to win!".tr())
|
||||
topTable.add("Destroy all enemies\n to win!".tr())
|
||||
val tabsTable = Table().apply { defaults().pad(10f) }
|
||||
val setMyVictoryButton = TextButton("Our status",skin)
|
||||
setMyVictoryButton.onClick { setMyVictoryTable() }
|
||||
tabsTable.add(setMyVictoryButton)
|
||||
val setGlobalVictoryButton = TextButton("Global status",skin)
|
||||
setGlobalVictoryButton .onClick { setGlobalVictoryTable() }
|
||||
tabsTable.add(setGlobalVictoryButton)
|
||||
topTable.add(tabsTable)
|
||||
topTable.addSeparator()
|
||||
topTable.add(contentsTable)
|
||||
|
||||
setMyVictoryTable()
|
||||
|
||||
rightSideButton.isVisible=false
|
||||
|
||||
@ -44,6 +48,7 @@ class VictoryScreen : PickerScreen() {
|
||||
else setDefaultCloseAction()
|
||||
}
|
||||
|
||||
|
||||
fun won(description: String) {
|
||||
descriptionLabel.setText(description.tr())
|
||||
|
||||
@ -59,6 +64,26 @@ class VictoryScreen : PickerScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setMyVictoryTable(){
|
||||
val myVictoryStatusTable = Table()
|
||||
myVictoryStatusTable.defaults().pad(10f)
|
||||
myVictoryStatusTable.add("Science victory".toLabel())
|
||||
myVictoryStatusTable.add("Cultural victory".toLabel())
|
||||
myVictoryStatusTable.add("Conquest victory".toLabel())
|
||||
myVictoryStatusTable.row()
|
||||
myVictoryStatusTable.add(scienceVictoryColumn())
|
||||
myVictoryStatusTable.add(culturalVictoryColumn())
|
||||
myVictoryStatusTable.add(conquestVictoryColumn())
|
||||
myVictoryStatusTable.row()
|
||||
myVictoryStatusTable.add("Complete all the spaceship parts\n to win!".toLabel())
|
||||
myVictoryStatusTable.add("Complete 4 policy branches\n to win!".toLabel())
|
||||
myVictoryStatusTable.add("Destroy all enemies\n to win!".toLabel())
|
||||
|
||||
contentsTable.clear()
|
||||
contentsTable.add(myVictoryStatusTable)
|
||||
}
|
||||
|
||||
fun scienceVictoryColumn():Table{
|
||||
val t = Table()
|
||||
t.defaults().pad(5f)
|
||||
@ -104,4 +129,63 @@ class VictoryScreen : PickerScreen() {
|
||||
}
|
||||
|
||||
|
||||
private fun setGlobalVictoryTable() {
|
||||
val majorCivs = game.gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||
val globalVictoryTable = Table().apply { defaults().pad(10f) }
|
||||
|
||||
globalVictoryTable.add(getGlobalScientificVictoryColumn(majorCivs))
|
||||
globalVictoryTable.add(getGlobalPolicyVictoryColumn(majorCivs))
|
||||
globalVictoryTable.add(getGlobalDominationVictoryColumn(majorCivs))
|
||||
|
||||
contentsTable.clear()
|
||||
contentsTable.add(globalVictoryTable)
|
||||
}
|
||||
|
||||
private fun getGlobalDominationVictoryColumn(majorCivs: List<CivilizationInfo>): Table {
|
||||
val dominationVictoryColumn = Table().apply { defaults().pad(10f) }
|
||||
|
||||
dominationVictoryColumn.add("Undefeated civs".toLabel()).row()
|
||||
dominationVictoryColumn.addSeparator()
|
||||
|
||||
for (civ in majorCivs.filter { !it.isDefeated() })
|
||||
dominationVictoryColumn.add(TextButton(civ.civName.tr(), skin).apply { color = Color.GREEN }).row()
|
||||
|
||||
for (civ in majorCivs.filter { it.isDefeated() })
|
||||
dominationVictoryColumn.add(TextButton(civ.civName.tr(), skin).apply { color = Color.GRAY }).row()
|
||||
return dominationVictoryColumn
|
||||
}
|
||||
|
||||
private fun getGlobalPolicyVictoryColumn(majorCivs: List<CivilizationInfo>): Table {
|
||||
val policyVictoryColumn = Table().apply { defaults().pad(10f) }
|
||||
policyVictoryColumn.add("Branches completed".toLabel()).row()
|
||||
policyVictoryColumn.addSeparator()
|
||||
|
||||
data class civToBranchesCompleted(val civ: CivilizationInfo, val branchesCompleted: Int)
|
||||
|
||||
val civsToBranchesCompleted =
|
||||
majorCivs.map { civToBranchesCompleted(it, it.policies.adoptedPolicies.count { pol -> pol.endsWith("Complete") }) }
|
||||
.sortedByDescending { it.branchesCompleted }
|
||||
|
||||
for (entry in civsToBranchesCompleted)
|
||||
policyVictoryColumn.add(TextButton(entry.civ.civName.tr() + " - " + entry.branchesCompleted, skin)).row()
|
||||
return policyVictoryColumn
|
||||
}
|
||||
|
||||
private fun getGlobalScientificVictoryColumn(majorCivs: List<CivilizationInfo>): Table {
|
||||
val scientificVictoryColumn = Table().apply { defaults().pad(10f) }
|
||||
scientificVictoryColumn.add("Spaceship parts remaining".toLabel()).row()
|
||||
scientificVictoryColumn.addSeparator()
|
||||
|
||||
data class civToSpaceshipPartsRemaining(val civ: CivilizationInfo, val partsRemaining: Int)
|
||||
|
||||
val civsToPartsRemaining = majorCivs.map {
|
||||
civToSpaceshipPartsRemaining(it,
|
||||
it.victoryManager.requiredSpaceshipParts.size - it.victoryManager.currentsSpaceshipParts.size)
|
||||
}
|
||||
|
||||
for (entry in civsToPartsRemaining)
|
||||
scientificVictoryColumn.add(TextButton(entry.civ.civName.tr() + " - " + entry.partsRemaining, skin)).row()
|
||||
return scientificVictoryColumn
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user