Resolved #251 - Choose specific victory conditions on new game
Victory screen no longer 'reveals' civs you haven't met
This commit is contained in:
parent
be7baaa117
commit
3f3dd0193e
8 changed files with 76 additions and 58 deletions
|
@ -100,7 +100,7 @@ class Automation {
|
|||
&& cityInfo.getTiles().any { it.isWater && it.hasViewableResource(cityInfo.civInfo) && it.improvement == null }
|
||||
|
||||
val isAtWar = cityInfo.civInfo.isAtWar()
|
||||
val preferredVictoryType = cityInfo.civInfo.getNation().preferredVictoryType
|
||||
val preferredVictoryType = cityInfo.civInfo.victoryType()
|
||||
|
||||
data class ConstructionChoice(val choice:String, var choiceModifier:Float){
|
||||
val remainingWork:Int = getRemainingWork(choice)
|
||||
|
|
|
@ -146,7 +146,7 @@ class NextTurnAutomation{
|
|||
val adoptablePolicies = GameBasics.PolicyBranches.values.flatMap { it.policies.union(listOf(it)) }
|
||||
.filter { civInfo.policies.isAdoptable(it) }
|
||||
|
||||
val preferredVictoryType = civInfo.getNation().preferredVictoryType
|
||||
val preferredVictoryType = civInfo.victoryType()
|
||||
val policyBranchPriority =
|
||||
when(preferredVictoryType) {
|
||||
VictoryType.Cultural -> listOf("Piety", "Freedom", "Tradition", "Rationalism")
|
||||
|
@ -243,7 +243,7 @@ class NextTurnAutomation{
|
|||
|
||||
for (enemy in enemiesCiv) {
|
||||
val enemiesStrength = Automation().evaluteCombatStrength(enemy)
|
||||
if (civInfo.getNation().preferredVictoryType!=VictoryType.Cultural
|
||||
if (civInfo.victoryType()!=VictoryType.Cultural
|
||||
&& enemiesStrength < ourCombatStrength*2 ) {
|
||||
continue //We're losing, but can still fight. Refuse peace.
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ class NextTurnAutomation{
|
|||
if (enemy.isPlayerCivilization())
|
||||
enemy.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||
else {
|
||||
if (enemy.getNation().preferredVictoryType!=VictoryType.Cultural
|
||||
if (enemy.victoryType()!=VictoryType.Cultural
|
||||
&& enemy.getCivUnits().filter { !it.type.isCivilian() }.size > enemy.cities.size
|
||||
&& enemy.happiness > 0) {
|
||||
continue //enemy AI has too large army and happiness. It continues to fight for profit.
|
||||
|
@ -296,7 +296,7 @@ class NextTurnAutomation{
|
|||
|
||||
private fun declareWar(civInfo: CivilizationInfo) {
|
||||
if (civInfo.isCityState()) return
|
||||
if(civInfo.getNation().preferredVictoryType==VictoryType.Cultural)
|
||||
if (civInfo.victoryType()==VictoryType.Cultural)
|
||||
return
|
||||
|
||||
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
|
||||
|
@ -369,7 +369,7 @@ class NextTurnAutomation{
|
|||
private fun trainSettler(civInfo: CivilizationInfo) {
|
||||
if(civInfo.isCityState()) return
|
||||
if(civInfo.isAtWar()) return // don't train settlers when you could be training troops.
|
||||
if(civInfo.getNation().preferredVictoryType==VictoryType.Cultural && civInfo.cities.size >3) return
|
||||
if(civInfo.victoryType()==VictoryType.Cultural && civInfo.cities.size >3) return
|
||||
if (civInfo.cities.any()
|
||||
&& civInfo.happiness > civInfo.cities.size + 5
|
||||
&& civInfo.getCivUnits().none { it.name == Constants.settler }
|
||||
|
|
|
@ -138,6 +138,11 @@ class CivilizationInfo {
|
|||
fun getCityStateType(): CityStateType = getNation().cityStateType!!
|
||||
fun isMajorCiv() = !isBarbarianCivilization() && !isCityState()
|
||||
|
||||
fun victoryType(): VictoryType {
|
||||
val victoryType = getNation().preferredVictoryType
|
||||
if(gameInfo.gameParameters.victoryTypes.contains(victoryType)) return victoryType
|
||||
else return VictoryType.Neutral
|
||||
}
|
||||
|
||||
fun getStatsForNextTurn():Stats = getStatMapForNextTurn().values.toList().reduce{a,b->a+b}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class PolicyManager {
|
|||
"Liberty Complete" -> {
|
||||
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
|
||||
else {
|
||||
val preferredVictoryType = civInfo.getNation().preferredVictoryType
|
||||
val preferredVictoryType = civInfo.victoryType()
|
||||
val greatPerson = when(preferredVictoryType) {
|
||||
VictoryType.Cultural -> "Great Artist"
|
||||
VictoryType.Scientific -> "Great Scientist"
|
||||
|
|
|
@ -30,11 +30,14 @@ class VictoryManager {
|
|||
|
||||
fun spaceshipPartsRemaining() = requiredSpaceshipParts.values.sum() - currentsSpaceshipParts.values.sum()
|
||||
|
||||
fun hasWonScientificVictory() = spaceshipPartsRemaining()==0
|
||||
fun hasWonScientificVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Scientific)
|
||||
&& spaceshipPartsRemaining()==0
|
||||
|
||||
fun hasWonCulturalVictory() = civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 3
|
||||
fun hasWonCulturalVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Cultural)
|
||||
&& civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 3
|
||||
|
||||
fun hasWonDominationVictory() = civInfo.gameInfo.civilizations.all { it==civInfo || it.isDefeated() || it.isCityState() }
|
||||
fun hasWonDominationVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Domination)
|
||||
&& civInfo.gameInfo.civilizations.all { it==civInfo || it.isDefeated() || it.isCityState() }
|
||||
|
||||
fun hasWonVictoryType(): VictoryType? {
|
||||
if(!civInfo.isMajorCiv()) return null
|
||||
|
|
|
@ -77,15 +77,7 @@ class NewGameScreen: PickerScreen(){
|
|||
addNumberOfHumansAndEnemies(newGameOptionsTable)
|
||||
addDifficultySelectBox(newGameOptionsTable)
|
||||
addVictoryTypeCheckboxes(newGameOptionsTable)
|
||||
|
||||
val noBarbariansCheckbox = CheckBox("No barbarians".tr(),skin)
|
||||
noBarbariansCheckbox.isChecked=newGameParameters.noBarbarians
|
||||
noBarbariansCheckbox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
newGameParameters.noBarbarians = noBarbariansCheckbox.isChecked
|
||||
}
|
||||
})
|
||||
newGameOptionsTable.add(noBarbariansCheckbox).colspan(2).row()
|
||||
addBarbariansCheckbox(newGameOptionsTable)
|
||||
|
||||
|
||||
rightSideButton.enable()
|
||||
|
@ -112,6 +104,17 @@ class NewGameScreen: PickerScreen(){
|
|||
return newGameOptionsTable
|
||||
}
|
||||
|
||||
private fun addBarbariansCheckbox(newGameOptionsTable: Table) {
|
||||
val noBarbariansCheckbox = CheckBox("No barbarians".tr(), skin)
|
||||
noBarbariansCheckbox.isChecked = newGameParameters.noBarbarians
|
||||
noBarbariansCheckbox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
newGameParameters.noBarbarians = noBarbariansCheckbox.isChecked
|
||||
}
|
||||
})
|
||||
newGameOptionsTable.add(noBarbariansCheckbox).colspan(2).row()
|
||||
}
|
||||
|
||||
private fun addMapTypeSizeAndFile(newGameOptionsTable: Table) {
|
||||
newGameOptionsTable.add("{Map type}:".tr())
|
||||
val mapTypes = LinkedHashMap<String, MapType>()
|
||||
|
@ -171,14 +174,14 @@ class NewGameScreen: PickerScreen(){
|
|||
newGameOptionsTable.add("{Number of enemies}:".tr())
|
||||
val enemiesSelectBox = SelectBox<Int>(skin)
|
||||
val enemiesArray = Array<Int>()
|
||||
(0..GameBasics.Nations.filter{ !it.value.isCityState() }.size - 1).forEach { enemiesArray.add(it) }
|
||||
for (enemyNumber in 0 until GameBasics.Nations.filter{ !it.value.isCityState() }.size) {
|
||||
enemiesArray.add(enemyNumber)
|
||||
}
|
||||
enemiesSelectBox.items = enemiesArray
|
||||
enemiesSelectBox.selected = newGameParameters.numberOfEnemies
|
||||
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
|
||||
|
||||
// Todo - re-enable this when city states are fit for players
|
||||
addCityStatesSelectBox(newGameOptionsTable)
|
||||
// newGameParameters.numberOfCityStates = 0
|
||||
|
||||
humanPlayers.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
|
@ -232,31 +235,26 @@ class NewGameScreen: PickerScreen(){
|
|||
|
||||
// Create a checkbox for each VictoryType existing
|
||||
var i=0
|
||||
VictoryType.values().forEach{
|
||||
val victoryCheckbox = CheckBox(it.name.tr(),skin)
|
||||
victoryCheckbox.name=it.name
|
||||
victoryCheckbox.isChecked=newGameParameters.victoryTypes.contains(it)
|
||||
val victoryConditionsTable = Table().apply { defaults().pad(10f) }
|
||||
for (victoryType in VictoryType.values()) {
|
||||
if(victoryType==VictoryType.Neutral) continue
|
||||
val victoryCheckbox = CheckBox(victoryType.name.tr(),skin)
|
||||
victoryCheckbox.name=victoryType.name
|
||||
victoryCheckbox.isChecked=newGameParameters.victoryTypes.contains(victoryType)
|
||||
victoryCheckbox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
// If the checkbox is checked, adds the victoryType else remove it
|
||||
// If the checkbox is checked, adds the victoryTypes else remove it
|
||||
if(victoryCheckbox.isChecked){
|
||||
newGameParameters.victoryTypes.add(it)
|
||||
newGameParameters.victoryTypes.add(victoryType)
|
||||
} else {
|
||||
newGameParameters.victoryTypes.remove(it)
|
||||
newGameParameters.victoryTypes.remove(victoryType)
|
||||
}
|
||||
}
|
||||
})
|
||||
if(++i%2==0) {
|
||||
// New row only each two checkboxes
|
||||
newGameOptionsTable.add(victoryCheckbox)
|
||||
.left() // Left alignment
|
||||
.pad(10f).row()
|
||||
} else {
|
||||
newGameOptionsTable.add(victoryCheckbox)
|
||||
.left() // Left alignment
|
||||
}
|
||||
victoryConditionsTable.add(victoryCheckbox)
|
||||
if(++i%2==0) victoryConditionsTable.row()
|
||||
}
|
||||
|
||||
newGameOptionsTable.add(victoryConditionsTable).colspan(2).row()
|
||||
}
|
||||
|
||||
private fun getMapFileSelectBox(): SelectBox<String> {
|
||||
|
|
|
@ -17,6 +17,11 @@ import com.unciv.ui.utils.toLabel
|
|||
class VictoryScreen : PickerScreen() {
|
||||
|
||||
val playerCivInfo = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||
val victoryTypes = playerCivInfo.gameInfo.gameParameters.victoryTypes
|
||||
val scientificVictoryEnabled = victoryTypes.contains(VictoryType.Scientific)
|
||||
val culturalVictoryEnabled = victoryTypes.contains(VictoryType.Cultural)
|
||||
val dominationVictoryEnabled = victoryTypes.contains(VictoryType.Domination)
|
||||
|
||||
|
||||
val contentsTable = Table()
|
||||
|
||||
|
@ -83,17 +88,17 @@ 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())
|
||||
if(scientificVictoryEnabled) myVictoryStatusTable.add("Science victory".toLabel())
|
||||
if(culturalVictoryEnabled) myVictoryStatusTable.add("Cultural victory".toLabel())
|
||||
if(dominationVictoryEnabled) myVictoryStatusTable.add("Conquest victory".toLabel())
|
||||
myVictoryStatusTable.row()
|
||||
myVictoryStatusTable.add(scienceVictoryColumn())
|
||||
myVictoryStatusTable.add(culturalVictoryColumn())
|
||||
myVictoryStatusTable.add(conquestVictoryColumn())
|
||||
if(scientificVictoryEnabled) myVictoryStatusTable.add(scienceVictoryColumn())
|
||||
if(culturalVictoryEnabled) myVictoryStatusTable.add(culturalVictoryColumn())
|
||||
if(dominationVictoryEnabled) 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())
|
||||
if(scientificVictoryEnabled) myVictoryStatusTable.add("Complete all the spaceship parts\n to win!".toLabel())
|
||||
if(culturalVictoryEnabled) myVictoryStatusTable.add("Complete 4 policy branches\n to win!".toLabel())
|
||||
if(dominationVictoryEnabled) myVictoryStatusTable.add("Destroy all enemies\n to win!".toLabel())
|
||||
|
||||
contentsTable.clear()
|
||||
contentsTable.add(myVictoryStatusTable)
|
||||
|
@ -148,9 +153,9 @@ class VictoryScreen : PickerScreen() {
|
|||
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))
|
||||
if(scientificVictoryEnabled) globalVictoryTable.add(getGlobalScientificVictoryColumn(majorCivs))
|
||||
if(culturalVictoryEnabled) globalVictoryTable.add(getGlobalCulturalVictoryColumn(majorCivs))
|
||||
if(dominationVictoryEnabled) globalVictoryTable.add(getGlobalDominationVictoryColumn(majorCivs))
|
||||
|
||||
contentsTable.clear()
|
||||
contentsTable.add(globalVictoryTable)
|
||||
|
@ -162,15 +167,17 @@ class VictoryScreen : PickerScreen() {
|
|||
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() }) {
|
||||
val civName = if(playerCivInfo.knows(civ) || playerCivInfo==civ) civ.civName.tr() else "???"
|
||||
dominationVictoryColumn.add(TextButton(civName, 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 {
|
||||
private fun getGlobalCulturalVictoryColumn(majorCivs: List<CivilizationInfo>): Table {
|
||||
val policyVictoryColumn = Table().apply { defaults().pad(10f) }
|
||||
policyVictoryColumn.add("Branches completed".toLabel()).row()
|
||||
policyVictoryColumn.addSeparator()
|
||||
|
@ -181,8 +188,10 @@ class VictoryScreen : PickerScreen() {
|
|||
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()
|
||||
for (entry in civsToBranchesCompleted) {
|
||||
val civName = if(playerCivInfo.knows(entry.civ) || playerCivInfo==entry.civ) entry.civ.civName.tr() else "???"
|
||||
policyVictoryColumn.add(TextButton(civName + " - " + entry.branchesCompleted, skin)).row()
|
||||
}
|
||||
return policyVictoryColumn
|
||||
}
|
||||
|
||||
|
@ -198,8 +207,10 @@ class VictoryScreen : PickerScreen() {
|
|||
it.victoryManager.spaceshipPartsRemaining())
|
||||
}
|
||||
|
||||
for (entry in civsToPartsRemaining)
|
||||
scientificVictoryColumn.add(TextButton(entry.civ.civName.tr() + " - " + entry.partsRemaining, skin)).row()
|
||||
for (entry in civsToPartsRemaining) {
|
||||
val civName = if(playerCivInfo.knows(entry.civ) || playerCivInfo==entry.civ) entry.civ.civName.tr() else "???"
|
||||
scientificVictoryColumn.add(TextButton(civName + " - " + entry.partsRemaining, skin)).row()
|
||||
}
|
||||
return scientificVictoryColumn
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ open class CameraStageBaseScreen : Screen {
|
|||
skin.get<TextField.TextFieldStyle>(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
||||
skin.get<CheckBox.CheckBoxStyle>(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
||||
}
|
||||
internal var batch: Batch = SpriteBatch()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue