Added Scenario victory condition - can now have Scenario deathmatches! (sort of)
This commit is contained in:
parent
fd211b1fa3
commit
0c4947a03e
9 changed files with 31 additions and 21 deletions
|
@ -31,10 +31,10 @@ object GameStarter {
|
|||
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
|
||||
addCivilizations(gameSetupInfo.gameParameters, gameInfo, ruleset) // this is before gameInfo.setTransients, so gameInfo doesn't yet have the gameBasics
|
||||
|
||||
for(tile in gameInfo.tileMap.values)
|
||||
for(unit in tile.getUnits())
|
||||
if(gameInfo.civilizations.none { it.civName== unit.owner}){
|
||||
unit.currentTile=tile
|
||||
for (tile in gameInfo.tileMap.values)
|
||||
for (unit in tile.getUnits())
|
||||
if (gameInfo.civilizations.none { it.civName == unit.owner }) {
|
||||
unit.currentTile = tile
|
||||
unit.setTransients(ruleset)
|
||||
unit.removeFromTile()
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ object NextTurnAutomation{
|
|||
VictoryType.Cultural -> listOf("Piety", "Freedom", "Tradition", "Rationalism", "Commerce")
|
||||
VictoryType.Scientific -> listOf("Rationalism", "Commerce", "Liberty", "Freedom", "Piety")
|
||||
VictoryType.Domination -> listOf("Autocracy", "Honor", "Liberty", "Rationalism", "Freedom")
|
||||
VictoryType.Neutral -> listOf()
|
||||
VictoryType.Neutral, VictoryType.Scenario -> listOf()
|
||||
}
|
||||
val policiesByPreference = adoptablePolicies
|
||||
.groupBy {
|
||||
|
|
|
@ -317,7 +317,7 @@ object Battle {
|
|||
capturedUnit.assignOwner(attacker.getCivInfo())
|
||||
}
|
||||
|
||||
destroyIfDefeated(defenderCiv,attacker.getCivInfo())
|
||||
destroyIfDefeated(defenderCiv, attacker.getCivInfo())
|
||||
capturedUnit.updateVisibleTiles()
|
||||
}
|
||||
|
||||
|
|
|
@ -272,11 +272,15 @@ class CivilizationInfo {
|
|||
override fun toString(): String {return civName} // for debug
|
||||
|
||||
/** Returns true if the civ was fully initialized and has no cities remaining */
|
||||
fun isDefeated()= cities.isEmpty() // No cities
|
||||
&& exploredTiles.isNotEmpty() // Dirty hack: exploredTiles are empty only before starting units are placed
|
||||
&& !isBarbarian() // Barbarians can be never defeated
|
||||
&& !isSpectator() // can't loose in Spectator mode
|
||||
&& (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler })
|
||||
fun isDefeated(): Boolean {
|
||||
// Dirty hack: exploredTiles are empty only before starting units are placed
|
||||
if (isBarbarian() || isSpectator() || exploredTiles.isEmpty()) return false
|
||||
// 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 })
|
||||
}
|
||||
|
||||
fun getEra(): String {
|
||||
if(tech.researchedTechnologies.isEmpty())
|
||||
|
|
|
@ -145,7 +145,7 @@ class PolicyManager {
|
|||
val greatPerson = when (preferredVictoryType) {
|
||||
VictoryType.Cultural -> "Great Artist"
|
||||
VictoryType.Scientific -> "Great Scientist"
|
||||
VictoryType.Domination, VictoryType.Neutral ->
|
||||
else ->
|
||||
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
|
||||
}
|
||||
civInfo.addUnit(greatPerson)
|
||||
|
|
|
@ -30,14 +30,17 @@ class VictoryManager {
|
|||
|
||||
fun spaceshipPartsRemaining() = requiredSpaceshipParts.values.sum() - currentsSpaceshipParts.values.sum()
|
||||
|
||||
fun hasWonScientificVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Scientific)
|
||||
&& spaceshipPartsRemaining()==0
|
||||
private fun hasVictoryType(victoryType: VictoryType) = civInfo.gameInfo.gameParameters.victoryTypes.contains(victoryType)
|
||||
|
||||
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
|
||||
|
||||
fun hasWonDominationVictory() = civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Domination)
|
||||
&& civInfo.gameInfo.civilizations.all { it==civInfo || it.isDefeated() || !it.isMajorCiv() }
|
||||
fun hasWonDominationVictory(): Boolean {
|
||||
return (hasVictoryType(VictoryType.Domination) || hasVictoryType(VictoryType.Scenario)) &&
|
||||
civInfo.gameInfo.civilizations.all { it == civInfo || it.isDefeated() || !it.isMajorCiv() }
|
||||
}
|
||||
|
||||
fun hasWonVictoryType(): VictoryType? {
|
||||
if(!civInfo.isMajorCiv()) return null
|
||||
|
|
|
@ -21,7 +21,7 @@ class GameParameters { // Default values are the default new game
|
|||
var oneCityChallenge = false
|
||||
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 isOnlineMultiplayer = false
|
||||
|
|
|
@ -9,11 +9,12 @@ import com.unciv.models.translations.Translations
|
|||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
enum class VictoryType{
|
||||
enum class VictoryType {
|
||||
Neutral,
|
||||
Cultural,
|
||||
Domination,
|
||||
Scientific
|
||||
Scientific,
|
||||
Scenario
|
||||
}
|
||||
|
||||
class Nation : INamed {
|
||||
|
|
|
@ -9,9 +9,10 @@ import com.unciv.models.metadata.GameSpeed
|
|||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.ruleset.VictoryType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.mapeditor.GameParametersScreen
|
||||
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) {
|
||||
var gameParameters = previousScreen.gameSetupInfo.gameParameters
|
||||
val ruleset = previousScreen.ruleset
|
||||
|
@ -137,6 +138,7 @@ class GameOptionsTable(previousScreen: IPreviousScreen, val updatePlayerPickerTa
|
|||
val victoryConditionsTable = Table().apply { defaults().pad(5f) }
|
||||
for (victoryType in VictoryType.values()) {
|
||||
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)
|
||||
victoryCheckbox.name = victoryType.name
|
||||
victoryCheckbox.isChecked = gameParameters.victoryTypes.contains(victoryType)
|
||||
|
|
Loading…
Reference in a new issue