mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-31 15:19:29 +07:00
Added custom victory conditions
This commit is contained in:
@ -4,7 +4,8 @@ import com.unciv.models.Counter
|
||||
import com.unciv.models.ruleset.VictoryType
|
||||
|
||||
class VictoryManager {
|
||||
@Transient lateinit var civInfo: CivilizationInfo
|
||||
@Transient
|
||||
lateinit var civInfo: CivilizationInfo
|
||||
|
||||
var requiredSpaceshipParts = Counter<String>()
|
||||
var currentsSpaceshipParts = Counter<String>()
|
||||
@ -32,10 +33,10 @@ class VictoryManager {
|
||||
|
||||
private fun hasVictoryType(victoryType: VictoryType) = civInfo.gameInfo.gameParameters.victoryTypes.contains(victoryType)
|
||||
|
||||
fun hasWonScientificVictory() = hasVictoryType(VictoryType.Scientific) && spaceshipPartsRemaining()==0
|
||||
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(): Boolean {
|
||||
return (hasVictoryType(VictoryType.Domination) || hasVictoryType(VictoryType.Scenario)) &&
|
||||
@ -43,12 +44,13 @@ class VictoryManager {
|
||||
}
|
||||
|
||||
fun hasWonVictoryType(): VictoryType? {
|
||||
if(!civInfo.isMajorCiv()) return null
|
||||
if(hasWonDominationVictory()) return VictoryType.Domination
|
||||
if(hasWonScientificVictory()) return VictoryType.Scientific
|
||||
if(hasWonCulturalVictory()) return VictoryType.Cultural
|
||||
if (!civInfo.isMajorCiv()) return null
|
||||
if (hasWonDominationVictory()) return VictoryType.Domination
|
||||
if (hasWonScientificVictory()) return VictoryType.Scientific
|
||||
if (hasWonCulturalVictory()) return VictoryType.Cultural
|
||||
if (civInfo.hasUnique("Triggers victory")) return VictoryType.Neutral
|
||||
return null
|
||||
}
|
||||
|
||||
fun hasWon() = hasWonVictoryType()!=null
|
||||
}
|
||||
fun hasWon() = hasWonVictoryType() != null
|
||||
}
|
@ -58,6 +58,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
VictoryType.Cultural -> wonOrLost("You have won a cultural victory!")
|
||||
VictoryType.Domination -> wonOrLost("You have won a domination victory!") // todo change translation
|
||||
VictoryType.Scientific -> wonOrLost("You have won a scientific victory!")
|
||||
VictoryType.Neutral -> wonOrLost("You have won!")
|
||||
}
|
||||
}
|
||||
for (civ in game.gameInfo.civilizations.filter { it.isMajorCiv() && it != playerCivInfo }) {
|
||||
@ -69,6 +70,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
VictoryType.Cultural -> wonOrLost("[$winningCivName] has won a cultural victory!")
|
||||
VictoryType.Domination -> wonOrLost("[$winningCivName] has won a domination victory!")
|
||||
VictoryType.Scientific -> wonOrLost("[$winningCivName] has won a scientific victory!")
|
||||
VictoryType.Neutral -> wonOrLost("[$winningCivName] has won!")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,6 +90,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
"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."
|
||||
"You have won a domination victory!" -> "The world has been convulsed by war. Many great and powerful civilizations have fallen, but you have survived - and emerged victorious! The world will long remember your glorious triumph!"
|
||||
"You have won a scientific victory!" -> "You have achieved victory through mastery of Science! You have conquered the mysteries of nature and led your people on a voyage to a brave new world! Your triumph will be remembered as long as the stars burn in the night sky!"
|
||||
"You have won!" -> "Your civilization stands above all others! The exploits of your people shall be remembered until the end of civilizaton itself!"
|
||||
else -> "You have been defeated. Your civilization has been overwhelmed by its many foes. But your people do not despair, for they know that one day you shall return - and lead them forward to victory!"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user