mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Added Scenario victory condition - can now have Scenario deathmatches! (sort of)
This commit is contained in:
@ -194,7 +194,7 @@ object NextTurnAutomation{
|
|||||||
VictoryType.Cultural -> listOf("Piety", "Freedom", "Tradition", "Rationalism", "Commerce")
|
VictoryType.Cultural -> listOf("Piety", "Freedom", "Tradition", "Rationalism", "Commerce")
|
||||||
VictoryType.Scientific -> listOf("Rationalism", "Commerce", "Liberty", "Freedom", "Piety")
|
VictoryType.Scientific -> listOf("Rationalism", "Commerce", "Liberty", "Freedom", "Piety")
|
||||||
VictoryType.Domination -> listOf("Autocracy", "Honor", "Liberty", "Rationalism", "Freedom")
|
VictoryType.Domination -> listOf("Autocracy", "Honor", "Liberty", "Rationalism", "Freedom")
|
||||||
VictoryType.Neutral -> listOf()
|
VictoryType.Neutral, VictoryType.Scenario -> listOf()
|
||||||
}
|
}
|
||||||
val policiesByPreference = adoptablePolicies
|
val policiesByPreference = adoptablePolicies
|
||||||
.groupBy {
|
.groupBy {
|
||||||
|
@ -272,11 +272,15 @@ class CivilizationInfo {
|
|||||||
override fun toString(): String {return civName} // for debug
|
override fun toString(): String {return civName} // for debug
|
||||||
|
|
||||||
/** Returns true if the civ was fully initialized and has no cities remaining */
|
/** Returns true if the civ was fully initialized and has no cities remaining */
|
||||||
fun isDefeated()= cities.isEmpty() // No cities
|
fun isDefeated(): Boolean {
|
||||||
&& exploredTiles.isNotEmpty() // Dirty hack: exploredTiles are empty only before starting units are placed
|
// Dirty hack: exploredTiles are empty only before starting units are placed
|
||||||
&& !isBarbarian() // Barbarians can be never defeated
|
if (isBarbarian() || isSpectator() || exploredTiles.isEmpty()) return false
|
||||||
&& !isSpectator() // can't loose in Spectator mode
|
// Scenarios are 'to the death'... for now
|
||||||
|
if (gameInfo.gameParameters.victoryTypes.contains(VictoryType.Scenario))
|
||||||
|
return cities.isEmpty() && getCivUnits().none()
|
||||||
|
else return cities.isEmpty() // No cities
|
||||||
&& (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler })
|
&& (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler })
|
||||||
|
}
|
||||||
|
|
||||||
fun getEra(): String {
|
fun getEra(): String {
|
||||||
if(tech.researchedTechnologies.isEmpty())
|
if(tech.researchedTechnologies.isEmpty())
|
||||||
|
@ -145,7 +145,7 @@ class PolicyManager {
|
|||||||
val greatPerson = when (preferredVictoryType) {
|
val greatPerson = when (preferredVictoryType) {
|
||||||
VictoryType.Cultural -> "Great Artist"
|
VictoryType.Cultural -> "Great Artist"
|
||||||
VictoryType.Scientific -> "Great Scientist"
|
VictoryType.Scientific -> "Great Scientist"
|
||||||
VictoryType.Domination, VictoryType.Neutral ->
|
else ->
|
||||||
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
|
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
|
||||||
}
|
}
|
||||||
civInfo.addUnit(greatPerson)
|
civInfo.addUnit(greatPerson)
|
||||||
|
@ -30,14 +30,17 @@ class VictoryManager {
|
|||||||
|
|
||||||
fun spaceshipPartsRemaining() = requiredSpaceshipParts.values.sum() - currentsSpaceshipParts.values.sum()
|
fun spaceshipPartsRemaining() = requiredSpaceshipParts.values.sum() - currentsSpaceshipParts.values.sum()
|
||||||
|
|
||||||
fun hasWonScientificVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Scientific)
|
private fun hasVictoryType(victoryType: VictoryType) = civInfo.gameInfo.gameParameters.victoryTypes.contains(victoryType)
|
||||||
&& spaceshipPartsRemaining()==0
|
|
||||||
|
|
||||||
fun hasWonCulturalVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Cultural)
|
fun hasWonScientificVictory() = hasVictoryType(VictoryType.Scientific) && spaceshipPartsRemaining()==0
|
||||||
|
|
||||||
|
fun hasWonCulturalVictory() = hasVictoryType(VictoryType.Cultural)
|
||||||
&& civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 4
|
&& civInfo.policies.adoptedPolicies.count{it.endsWith("Complete")} > 4
|
||||||
|
|
||||||
fun hasWonDominationVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Domination)
|
fun hasWonDominationVictory(): Boolean {
|
||||||
&& civInfo.gameInfo.civilizations.all { it==civInfo || it.isDefeated() || !it.isMajorCiv() }
|
return (hasVictoryType(VictoryType.Domination) || hasVictoryType(VictoryType.Scenario)) &&
|
||||||
|
civInfo.gameInfo.civilizations.all { it == civInfo || it.isDefeated() || !it.isMajorCiv() }
|
||||||
|
}
|
||||||
|
|
||||||
fun hasWonVictoryType(): VictoryType? {
|
fun hasWonVictoryType(): VictoryType? {
|
||||||
if(!civInfo.isMajorCiv()) return null
|
if(!civInfo.isMajorCiv()) return null
|
||||||
|
@ -21,7 +21,7 @@ class GameParameters { // Default values are the default new game
|
|||||||
var oneCityChallenge = false
|
var oneCityChallenge = false
|
||||||
var nuclearWeaponsEnabled = true
|
var nuclearWeaponsEnabled = true
|
||||||
|
|
||||||
var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types
|
var victoryTypes: ArrayList<VictoryType> = arrayListOf(VictoryType.Cultural, VictoryType.Domination, VictoryType.Scientific) // By default, all victory types
|
||||||
var startingEra = Constants.ancientEra
|
var startingEra = Constants.ancientEra
|
||||||
|
|
||||||
var isOnlineMultiplayer = false
|
var isOnlineMultiplayer = false
|
||||||
|
@ -13,7 +13,8 @@ enum class VictoryType{
|
|||||||
Neutral,
|
Neutral,
|
||||||
Cultural,
|
Cultural,
|
||||||
Domination,
|
Domination,
|
||||||
Scientific
|
Scientific,
|
||||||
|
Scenario
|
||||||
}
|
}
|
||||||
|
|
||||||
class Nation : INamed {
|
class Nation : INamed {
|
||||||
|
@ -9,9 +9,10 @@ import com.unciv.models.metadata.GameSpeed
|
|||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.ruleset.VictoryType
|
import com.unciv.models.ruleset.VictoryType
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
|
import com.unciv.ui.mapeditor.GameParametersScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTable:(desiredCiv:String)->Unit)
|
class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPickerTable:(desiredCiv:String)->Unit)
|
||||||
: Table(CameraStageBaseScreen.skin) {
|
: Table(CameraStageBaseScreen.skin) {
|
||||||
var gameParameters = previousScreen.gameSetupInfo.gameParameters
|
var gameParameters = previousScreen.gameSetupInfo.gameParameters
|
||||||
val ruleset = previousScreen.ruleset
|
val ruleset = previousScreen.ruleset
|
||||||
@ -137,6 +138,7 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||||||
val victoryConditionsTable = Table().apply { defaults().pad(5f) }
|
val victoryConditionsTable = Table().apply { defaults().pad(5f) }
|
||||||
for (victoryType in VictoryType.values()) {
|
for (victoryType in VictoryType.values()) {
|
||||||
if (victoryType == VictoryType.Neutral) continue
|
if (victoryType == VictoryType.Neutral) continue
|
||||||
|
if (previousScreen !is GameParametersScreen && victoryType == VictoryType.Scenario) continue // scenario victory is only available for scenarios
|
||||||
val victoryCheckbox = CheckBox(victoryType.name.tr(), CameraStageBaseScreen.skin)
|
val victoryCheckbox = CheckBox(victoryType.name.tr(), CameraStageBaseScreen.skin)
|
||||||
victoryCheckbox.name = victoryType.name
|
victoryCheckbox.name = victoryType.name
|
||||||
victoryCheckbox.isChecked = gameParameters.victoryTypes.contains(victoryType)
|
victoryCheckbox.isChecked = gameParameters.victoryTypes.contains(victoryType)
|
||||||
|
Reference in New Issue
Block a user