mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-20 19:56:51 +01:00
Implemented most easy things from comments on moddable victory PR (#6600)
* Implemented most easy things from comments on moddable victory PR Also added religious victory condition * Fixed tests * Fixed compile problems & missing string * Fixed typo
This commit is contained in:
parent
345114ed93
commit
c55b14eaa7
|
|
@ -28,6 +28,7 @@
|
|||
{
|
||||
"name": "Diplomatic",
|
||||
"hiddenInVictoryScreen": false,
|
||||
"victoryScreenHeader": "Build the UN and be voted\nworld leader to win!",
|
||||
"milestones": ["Anyone should build [United Nations]", "Win diplomatic vote"],
|
||||
"victoryString": "You have triumphed over your foes through the art of diplomacy! Your cunning and wisdom have earned you great friends - and divided and sown confusion among your enemies! Forever will you be remembered as the leader who brought peace to this weary world!",
|
||||
"defeatString": "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!"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
{
|
||||
"name": "Diplomatic",
|
||||
"hiddenInVictoryScreen": false,
|
||||
"victoryScreenHeader": "Build the UN and be voted\nworld leader to win!",
|
||||
"milestones": ["Anyone should build [United Nations]", "Win diplomatic vote"],
|
||||
"victoryString": "You have triumphed over your foes through the art of diplomacy! Your cunning and wisdom have earned you great friends - and divided and sown confusion among your enemies! Forever will you be remembered as the leader who brought peace to this weary world!",
|
||||
"defeatString": "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!"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import com.unciv.logic.map.TileInfo
|
|||
import com.unciv.logic.map.TileMap
|
||||
import com.unciv.models.ruleset.Building
|
||||
import com.unciv.models.ruleset.MilestoneType
|
||||
import com.unciv.models.ruleset.ThingToFocus
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.ruleset.Victory.Focus
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
|
|
@ -42,7 +43,7 @@ object Automation {
|
|||
|
||||
rank += stats.production
|
||||
rank += stats.science
|
||||
if (city.tiles.size < 12 || city.civInfo.wantsToFocusOn(ThingToFocus.Culture)) {
|
||||
if (city.tiles.size < 12 || city.civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
|
||||
rank += stats.culture
|
||||
} else rank += stats.culture / 2
|
||||
}
|
||||
|
|
@ -238,7 +239,7 @@ object Automation {
|
|||
}
|
||||
|
||||
fun getReservedSpaceResourceAmount(civInfo: CivilizationInfo): Int {
|
||||
return if (civInfo.wantsToFocusOn(ThingToFocus.Science)) 3 else 2
|
||||
return if (civInfo.wantsToFocusOn(Victory.Focus.Science)) 3 else 2
|
||||
}
|
||||
|
||||
fun threatAssessment(assessor: CivilizationInfo, assessed: CivilizationInfo): ThreatLevel {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.Belief
|
||||
import com.unciv.models.ruleset.BeliefType
|
||||
import com.unciv.models.ruleset.ThingToFocus
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.Stat
|
||||
import kotlin.math.min
|
||||
|
|
@ -134,7 +134,7 @@ object ChooseBeliefsAutomation {
|
|||
score += modifier * when (unique.type) {
|
||||
UniqueType.KillUnitPlunderNearCity ->
|
||||
unique.params[0].toFloat() * 4f *
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Military)) 2f
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Military)) 2f
|
||||
else 1f
|
||||
UniqueType.BuyUnitsForAmountStat, UniqueType.BuyBuildingsForAmountStat ->
|
||||
if (civInfo.religionManager.religion != null
|
||||
|
|
@ -153,7 +153,7 @@ object ChooseBeliefsAutomation {
|
|||
// what happens over there
|
||||
else civInfo.statsForNextTurn[Stat.valueOf(unique.params[1])] * 10f / civInfo.getEra().baseUnitBuyCost
|
||||
UniqueType.BuyUnitsByProductionCost ->
|
||||
15f * if (civInfo.wantsToFocusOn(ThingToFocus.Military)) 2f else 1f
|
||||
15f * if (civInfo.wantsToFocusOn(Victory.Focus.Military)) 2f else 1f
|
||||
UniqueType.StatsWhenSpreading ->
|
||||
unique.params[0].toInt() / 5f
|
||||
UniqueType.StatsWhenAdoptingReligion, UniqueType.StatsWhenAdoptingReligionSpeed ->
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import com.unciv.logic.civilization.PlayerType
|
|||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.models.ruleset.Building
|
||||
import com.unciv.models.ruleset.MilestoneType
|
||||
import com.unciv.models.ruleset.ThingToFocus
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.ruleset.Victory.Focus
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
|
|
@ -132,7 +133,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
val unitsToCitiesRatio = cities.toFloat() / (militaryUnits + 1)
|
||||
// most buildings and civ units contribute the the civ's growth, military units are anti-growth
|
||||
var modifier = sqrt(unitsToCitiesRatio) / 2
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Military)) modifier *= 3
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Military)) modifier *= 3
|
||||
else if (isAtWar) modifier *= unitsToCitiesRatio * 2
|
||||
|
||||
if (Automation.afraidOfBarbarians(civInfo)) modifier = 2f // military units are pro-growth if pressured by barbs
|
||||
|
|
@ -200,7 +201,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
var modifier = 0.5f
|
||||
if (cityInfo.cityStats.currentCityStats.culture == 0f) // It won't grow if we don't help it
|
||||
modifier = 0.8f
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)) modifier = 1.6f
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) modifier = 1.6f
|
||||
addChoice(relativeCostEffectiveness, cultureBuilding.name, modifier)
|
||||
}
|
||||
}
|
||||
|
|
@ -233,17 +234,17 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
}
|
||||
if (wonder.name in buildingsForVictory)
|
||||
return 5f
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)
|
||||
// TODO: Moddability
|
||||
&& wonder.name in listOf("Sistine Chapel", "Eiffel Tower", "Cristo Redentor", "Neuschwanstein", "Sydney Opera House"))
|
||||
return 3f
|
||||
if (wonder.isStatRelated(Stat.Science)) {
|
||||
if (allTechsAreResearched) return .5f
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Science)) return 1.5f
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Science)) return 1.5f
|
||||
else return 1.3f
|
||||
}
|
||||
if (wonder.name == "Manhattan Project") {
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Military)) return 2f
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Military)) return 2f
|
||||
else return 1.3f
|
||||
}
|
||||
if (wonder.isStatRelated(Stat.Happiness)) return 1.2f
|
||||
|
|
@ -269,10 +270,10 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
val unitTrainingBuilding = buildableNotWonders.asSequence()
|
||||
.filter { it.hasUnique(UniqueType.UnitStartingExperience)
|
||||
&& Automation.allowSpendingResource(civInfo, it)}.minByOrNull { it.cost }
|
||||
if (unitTrainingBuilding != null && (!civInfo.wantsToFocusOn(ThingToFocus.Culture) || isAtWar)) {
|
||||
if (unitTrainingBuilding != null && (!civInfo.wantsToFocusOn(Focus.Culture) || isAtWar)) {
|
||||
var modifier = if (cityIsOverAverageProduction) 0.5f else 0.1f // You shouldn't be cranking out units anytime soon
|
||||
if (isAtWar) modifier *= 2
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Military))
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Military))
|
||||
modifier *= 1.3f
|
||||
addChoice(relativeCostEffectiveness, unitTrainingBuilding.name, modifier)
|
||||
}
|
||||
|
|
@ -282,7 +283,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
val defensiveBuilding = buildableNotWonders.asSequence()
|
||||
.filter { it.cityStrength > 0
|
||||
&& Automation.allowSpendingResource(civInfo, it)}.minByOrNull { it.cost }
|
||||
if (defensiveBuilding != null && (isAtWar || !civInfo.wantsToFocusOn(ThingToFocus.Culture))) {
|
||||
if (defensiveBuilding != null && (isAtWar || !civInfo.wantsToFocusOn(Victory.Focus.Culture))) {
|
||||
var modifier = 0.2f
|
||||
if (isAtWar) modifier = 0.5f
|
||||
|
||||
|
|
@ -318,7 +319,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
.minByOrNull { it.cost }
|
||||
if (scienceBuilding != null) {
|
||||
var modifier = 1.1f
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Science))
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Science))
|
||||
modifier *= 1.4f
|
||||
addChoice(relativeCostEffectiveness, scienceBuilding.name, modifier)
|
||||
}
|
||||
|
|
@ -362,7 +363,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
// these 4 if conditions are used to determine if an AI should buy units to spread religion, or spend faith to buy things like new military units or new buildings.
|
||||
// currently this AI can only buy inquisitors and missionaries with faith
|
||||
// this system will have to be reengineered to support buying other stuff with faith
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Military)) return
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Military)) return
|
||||
if (civInfo.religionManager.religion?.name == null) return
|
||||
if (cityInfo.religion.getMajorityReligion()?.name != civInfo.religionManager.religion?.name)
|
||||
return // you don't want to build units of opposing religions.
|
||||
|
|
@ -382,7 +383,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
&& it.canBePurchasedWithStat(cityInfo, Stat.Faith) }
|
||||
|
||||
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)) modifier += 1
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) modifier += 1
|
||||
if (isAtWar) modifier -= 0.5f
|
||||
|
||||
val citiesNotFollowingOurReligion = civInfo.cities.asSequence()
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ object NextTurnAutomation {
|
|||
}
|
||||
}
|
||||
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)) {
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
|
||||
for (cityState in civInfo.getKnownCivs()
|
||||
.filter { it.isCityState() && it.cityStateType == CityStateType.Cultured }) {
|
||||
val diploManager = cityState.getDiplomacyManager(civInfo)
|
||||
|
|
@ -298,20 +298,20 @@ object NextTurnAutomation {
|
|||
if (!cityState.isAlive() || cityState.cities.isEmpty() || civInfo.cities.isEmpty())
|
||||
return value
|
||||
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture) && cityState.canGiveStat(Stat.Culture)) {
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && cityState.canGiveStat(Stat.Culture)) {
|
||||
value += 10
|
||||
}
|
||||
else if (civInfo.wantsToFocusOn(ThingToFocus.Science) && cityState.canGiveStat(Stat.Science)) {
|
||||
else if (civInfo.wantsToFocusOn(Victory.Focus.Science) && cityState.canGiveStat(Stat.Science)) {
|
||||
// In case someone mods this in
|
||||
value += 10
|
||||
}
|
||||
else if (civInfo.wantsToFocusOn(ThingToFocus.Military)) {
|
||||
else if (civInfo.wantsToFocusOn(Victory.Focus.Military)) {
|
||||
// Don't ally close city-states, conquer them instead
|
||||
val distance = getMinDistanceBetweenCities(civInfo, cityState)
|
||||
if (distance < 20)
|
||||
value -= (20 - distance) / 4
|
||||
}
|
||||
else if (civInfo.wantsToFocusOn(ThingToFocus.CityStates)) {
|
||||
else if (civInfo.wantsToFocusOn(Victory.Focus.CityStates)) {
|
||||
value += 5 // Generally be friendly
|
||||
}
|
||||
if (civInfo.gold < 100) {
|
||||
|
|
@ -659,7 +659,7 @@ object NextTurnAutomation {
|
|||
}
|
||||
|
||||
private fun declareWar(civInfo: CivilizationInfo) {
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)) return
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) return
|
||||
if (civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
|
||||
if (civInfo.isAtWar() || civInfo.getHappiness() <= 0) return
|
||||
|
||||
|
|
@ -849,7 +849,7 @@ object 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.wantsToFocusOn(ThingToFocus.Culture) && civInfo.cities.size > 3) return
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && civInfo.cities.size > 3) return
|
||||
if (civInfo.cities.none() || civInfo.getHappiness() <= civInfo.cities.size + 5) return
|
||||
|
||||
val settlerUnits = civInfo.gameInfo.ruleSet.units.values
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class CivilizationInfo {
|
|||
val lastEraResourceUsedForUnit = HashMap<String, Int>()
|
||||
|
||||
@Transient
|
||||
var thingsToFocusOnForVictory = setOf<ThingToFocus>()
|
||||
var thingsToFocusOnForVictory = setOf<Victory.Focus>()
|
||||
|
||||
var playerType = PlayerType.AI
|
||||
|
||||
|
|
@ -348,8 +348,8 @@ class CivilizationInfo {
|
|||
else gameInfo.ruleSet.victories[getPreferredVictoryType()]!!
|
||||
}
|
||||
|
||||
fun wantsToFocusOn(thingToFocusOn: ThingToFocus): Boolean {
|
||||
return thingsToFocusOnForVictory.contains(thingToFocusOn)
|
||||
fun wantsToFocusOn(focus: Victory.Focus): Boolean {
|
||||
return thingsToFocusOnForVictory.contains(focus)
|
||||
}
|
||||
|
||||
@Transient
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ class ReligionManager {
|
|||
fun endTurn(faithFromNewTurn: Int) {
|
||||
storedFaith += faithFromNewTurn
|
||||
}
|
||||
|
||||
fun isMajorityReligionForCiv(religion: Religion): Boolean {
|
||||
return civInfo.cities.count { it.religion.getMajorityReligion() == religion } >= civInfo.cities.count() / 2
|
||||
}
|
||||
|
||||
fun faithForPantheon(additionalCivs: Int = 0) =
|
||||
10 + (civInfo.gameInfo.civilizations.count { it.isMajorCiv() && it.religionManager.religion != null } + additionalCivs) * 5
|
||||
|
|
|
|||
|
|
@ -950,9 +950,6 @@ object RulesetCache : HashMap<String,Ruleset>() {
|
|||
}
|
||||
newRuleset.updateBuildingCosts() // only after we've added all the mods can we calculate the building costs
|
||||
|
||||
println(optionalBaseRuleset)
|
||||
println(newRuleset.victories)
|
||||
|
||||
return newRuleset
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.unciv.models.ruleset
|
|||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.Counter
|
||||
|
|
@ -18,27 +17,30 @@ enum class MilestoneType(val text: String) {
|
|||
DestroyAllPlayers("Destroy all players"),
|
||||
CaptureAllCapitals("Capture all capitals"),
|
||||
CompletePolicyBranches("Complete [amount] Policy branches"),
|
||||
WorldReligion("Become the world religion"),
|
||||
WinDiplomaticVote("Win diplomatic vote"),
|
||||
ScoreAfterTimeOut("Have highest score after max turns"),
|
||||
}
|
||||
|
||||
enum class CompletionStatus {
|
||||
Completed,
|
||||
Partially,
|
||||
Incomplete
|
||||
}
|
||||
|
||||
enum class ThingToFocus {
|
||||
Production,
|
||||
Gold,
|
||||
Science,
|
||||
Culture,
|
||||
Military,
|
||||
CityStates,
|
||||
Score,
|
||||
}
|
||||
|
||||
class Victory : INamed {
|
||||
|
||||
enum class CompletionStatus {
|
||||
Completed,
|
||||
Partially,
|
||||
Incomplete
|
||||
}
|
||||
|
||||
enum class Focus {
|
||||
Production,
|
||||
Gold,
|
||||
Culture,
|
||||
Science,
|
||||
Faith,
|
||||
Military,
|
||||
CityStates,
|
||||
Score,
|
||||
}
|
||||
|
||||
override var name = ""
|
||||
val victoryScreenHeader = "Do things to win!"
|
||||
val hiddenInVictoryScreen = false
|
||||
|
|
@ -59,19 +61,19 @@ class Victory : INamed {
|
|||
val defeatString = "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!"
|
||||
|
||||
fun enablesMaxTurns(): Boolean = milestoneObjects.any { it.type == MilestoneType.ScoreAfterTimeOut }
|
||||
fun getThingsToFocus(civInfo: CivilizationInfo): Set<ThingToFocus> = milestoneObjects
|
||||
fun getThingsToFocus(civInfo: CivilizationInfo): Set<Focus> = milestoneObjects
|
||||
.filter { !it.hasBeenCompletedBy(civInfo) }
|
||||
.map { it.getThingToFocus(civInfo) }
|
||||
.map { it.getFocus(civInfo) }
|
||||
.toSet()
|
||||
}
|
||||
|
||||
class Milestone(val uniqueDescription: String, private val accompaniedVictory: Victory) {
|
||||
class Milestone(val uniqueDescription: String, private val parentVictory: Victory) {
|
||||
|
||||
val type: MilestoneType? = MilestoneType.values().firstOrNull { uniqueDescription.getPlaceholderText() == it.text.getPlaceholderText() }
|
||||
val params by lazy { uniqueDescription.getPlaceholderParameters() }
|
||||
val params = uniqueDescription.getPlaceholderParameters()
|
||||
|
||||
fun getIncompleteSpaceshipParts(civInfo: CivilizationInfo): Counter<String> {
|
||||
val incompleteSpaceshipParts = accompaniedVictory.requiredSpaceshipPartsAsCounter.clone()
|
||||
val incompleteSpaceshipParts = parentVictory.requiredSpaceshipPartsAsCounter.clone()
|
||||
incompleteSpaceshipParts.remove(civInfo.victoryManager.currentsSpaceshipParts)
|
||||
return incompleteSpaceshipParts
|
||||
}
|
||||
|
|
@ -97,6 +99,13 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
civInfo.gameInfo.turns >= civInfo.gameInfo.gameParameters.maxTurns
|
||||
&& civInfo == civInfo.gameInfo.civilizations.maxByOrNull { it.calculateTotalScore() }
|
||||
}
|
||||
MilestoneType.WorldReligion -> {
|
||||
civInfo.gameInfo.isReligionEnabled()
|
||||
&& civInfo.religionManager.religion != null
|
||||
&& civInfo.gameInfo.civilizations.all {
|
||||
it.religionManager.isMajorityReligionForCiv(civInfo.religionManager.religion!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +144,7 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
}
|
||||
MilestoneType.AddedSSPartsInCapital -> {
|
||||
val completeSpaceshipParts = civInfo.victoryManager.currentsSpaceshipParts
|
||||
val incompleteSpaceshipParts = accompaniedVictory.requiredSpaceshipPartsAsCounter.clone()
|
||||
val incompleteSpaceshipParts = parentVictory.requiredSpaceshipPartsAsCounter.clone()
|
||||
val amountToDo = incompleteSpaceshipParts.sumValues()
|
||||
incompleteSpaceshipParts.remove(completeSpaceshipParts)
|
||||
|
||||
|
|
@ -143,15 +152,28 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
|
||||
"{$uniqueDescription} ($amountDone/$amountToDo)"
|
||||
}
|
||||
MilestoneType.WorldReligion -> {
|
||||
val amountToDo = civInfo.gameInfo.civilizations.count { it.isMajorCiv() } - 1 // Don't count yourself
|
||||
val amountDone =
|
||||
when {
|
||||
completed -> amountToDo
|
||||
civInfo.religionManager.religion == null -> 0
|
||||
civInfo.religionManager.religion!!.isPantheon() -> 1
|
||||
else -> civInfo.gameInfo.civilizations.count {
|
||||
it.religionManager.isMajorityReligionForCiv(civInfo.religionManager.religion!!)
|
||||
}
|
||||
}
|
||||
"{$uniqueDescription} ($amountDone/$amountToDo)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getVictoryScreenButtons(completionStatus: CompletionStatus, civInfo: CivilizationInfo): List<TextButton> {
|
||||
fun getVictoryScreenButtons(completionStatus: Victory.CompletionStatus, civInfo: CivilizationInfo): List<TextButton> {
|
||||
val headerButton = getMilestoneButton(
|
||||
getVictoryScreenButtonHeaderText(completionStatus == CompletionStatus.Completed, civInfo),
|
||||
completionStatus == CompletionStatus.Completed
|
||||
getVictoryScreenButtonHeaderText(completionStatus == Victory.CompletionStatus.Completed, civInfo),
|
||||
completionStatus == Victory.CompletionStatus.Completed
|
||||
)
|
||||
if (completionStatus == CompletionStatus.Completed || completionStatus == CompletionStatus.Incomplete) {
|
||||
if (completionStatus == Victory.CompletionStatus.Completed || completionStatus == Victory.CompletionStatus.Incomplete) {
|
||||
// When done or not working on this milestone, only show the header button
|
||||
return listOf(headerButton)
|
||||
}
|
||||
|
|
@ -178,20 +200,16 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
}
|
||||
|
||||
MilestoneType.DestroyAllPlayers -> {
|
||||
for (civ in civInfo.gameInfo.civilizations.filter { it != civInfo && it.isMajorCiv() && !it.isAlive() }) {
|
||||
buttons.add(getMilestoneButton("Destroy [${civ.civName}]", true))
|
||||
}
|
||||
for (civ in civInfo.gameInfo.getAliveMajorCivs().filter { it != civInfo}) {
|
||||
buttons.add(getMilestoneButton("Destroy [${civ.civName}]", false))
|
||||
val majorCivs = civInfo.gameInfo.civilizations.filter { it.isMajorCiv() && it != civInfo }
|
||||
for (civ in majorCivs) {
|
||||
buttons.add(getMilestoneButton("Destroy [${civ.civName}]", !civ.isAlive()))
|
||||
}
|
||||
}
|
||||
|
||||
MilestoneType.CaptureAllCapitals -> {
|
||||
for (city in civInfo.gameInfo.getAliveMajorCivs().mapNotNull {
|
||||
civ -> civ.cities.firstOrNull { it.isOriginalCapital && it.foundingCiv == civ.civName }
|
||||
}
|
||||
) {
|
||||
buttons.add(getMilestoneButton("Capture [${city.name}]", false))
|
||||
val originalCapitals = civInfo.gameInfo.getCities().filter { it.isOriginalCapital }
|
||||
for (city in originalCapitals) {
|
||||
buttons.add(getMilestoneButton("Capture [${city.name}]", city.civInfo == civInfo))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,24 +219,34 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
buttons.add(getMilestoneButton(finisher, civInfo.policies.isAdopted(finisher)))
|
||||
}
|
||||
}
|
||||
MilestoneType.WorldReligion -> {
|
||||
val majorCivs = civInfo.gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||
val civReligion = civInfo.religionManager.religion
|
||||
for (civ in majorCivs) {
|
||||
if (civReligion == null || (civReligion.isPantheon() && civInfo != civ) || !civ.religionManager.isMajorityReligionForCiv(civReligion))
|
||||
buttons.add(getMilestoneButton("Majority religion of [${civ.civName}]", false))
|
||||
else
|
||||
buttons.add(getMilestoneButton("Majority religion of [${civ.civName}]", true))
|
||||
}
|
||||
}
|
||||
}
|
||||
return buttons
|
||||
}
|
||||
|
||||
fun getThingToFocus(civInfo: CivilizationInfo): ThingToFocus {
|
||||
fun getFocus(civInfo: CivilizationInfo): Victory.Focus {
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
return when (type!!) {
|
||||
MilestoneType.BuiltBuilding -> {
|
||||
val building = ruleset.buildings[params[0]]!!
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) ThingToFocus.Science
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) Victory.Focus.Science
|
||||
// if (building.hasUnique(UniqueType.Unbuildable)) Stat.Gold // Temporary, should be replaced with whatever is required to buy
|
||||
ThingToFocus.Production
|
||||
Victory.Focus.Production
|
||||
}
|
||||
MilestoneType.BuildingBuiltGlobally -> {
|
||||
val building = ruleset.buildings[params[0]]!!
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) ThingToFocus.Science
|
||||
// if (building.hasUnique(UniqueType.Unbuildable)) ThingToFocus.Gold
|
||||
ThingToFocus.Production
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) Victory.Focus.Science
|
||||
// if (building.hasUnique(UniqueType.Unbuildable)) Victory.Focus.Gold
|
||||
Victory.Focus.Production
|
||||
}
|
||||
MilestoneType.AddedSSPartsInCapital -> {
|
||||
val constructions =
|
||||
|
|
@ -227,14 +255,15 @@ class Milestone(val uniqueDescription: String, private val accompaniedVictory: V
|
|||
ruleset.buildings[it]!!
|
||||
else ruleset.units[it]!!
|
||||
}
|
||||
if (constructions.any { it.requiredTech != null && !civInfo.tech.isResearched(it.requiredTech!!) } ) ThingToFocus.Science
|
||||
if (constructions.any { it.requiredTech != null && !civInfo.tech.isResearched(it.requiredTech!!) } ) Victory.Focus.Science
|
||||
// if (constructions.any { it.hasUnique(UniqueType.Unbuildable) } ) Stat.Gold
|
||||
ThingToFocus.Production
|
||||
Victory.Focus.Production
|
||||
}
|
||||
MilestoneType.DestroyAllPlayers, MilestoneType.CaptureAllCapitals -> ThingToFocus.Military
|
||||
MilestoneType.CompletePolicyBranches -> ThingToFocus.Culture
|
||||
MilestoneType.WinDiplomaticVote -> ThingToFocus.CityStates
|
||||
MilestoneType.ScoreAfterTimeOut -> ThingToFocus.Score
|
||||
MilestoneType.DestroyAllPlayers, MilestoneType.CaptureAllCapitals -> Victory.Focus.Military
|
||||
MilestoneType.CompletePolicyBranches -> Victory.Focus.Culture
|
||||
MilestoneType.WinDiplomaticVote -> Victory.Focus.CityStates
|
||||
MilestoneType.ScoreAfterTimeOut -> Victory.Focus.Score
|
||||
MilestoneType.WorldReligion -> Victory.Focus.Faith
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import com.unciv.logic.city.CityInfo
|
|||
import com.unciv.logic.civilization.*
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.ThingToFocus
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.ruleset.unique.UniqueType.*
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.translations.fillPlaceholders
|
||||
|
|
@ -144,12 +144,12 @@ object UniqueTriggerActivation {
|
|||
if (greatPeople.isEmpty()) return false
|
||||
var greatPerson = greatPeople.random()
|
||||
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Culture)) {
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture)) {
|
||||
val culturalGP =
|
||||
greatPeople.firstOrNull { it.uniques.contains("Great Person - [Culture]") }
|
||||
if (culturalGP != null) greatPerson = culturalGP
|
||||
}
|
||||
if (civInfo.wantsToFocusOn(ThingToFocus.Science)) {
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Science)) {
|
||||
val scientificGP =
|
||||
greatPeople.firstOrNull { it.uniques.contains("Great Person - [Science]") }
|
||||
if (scientificGP != null) greatPerson = scientificGP
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import com.unciv.Constants
|
|||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.models.metadata.GameSetupInfo
|
||||
import com.unciv.models.ruleset.CompletionStatus
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.newgamescreen.NewGameScreen
|
||||
import com.unciv.ui.pickerscreens.PickerScreen
|
||||
|
|
@ -127,12 +127,12 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||
for (milestone in victoryObject.milestoneObjects) {
|
||||
val completionStatus =
|
||||
when {
|
||||
milestone.hasBeenCompletedBy(playerCivInfo) -> CompletionStatus.Completed
|
||||
milestone.hasBeenCompletedBy(playerCivInfo) -> Victory.CompletionStatus.Completed
|
||||
firstIncomplete -> {
|
||||
firstIncomplete = false
|
||||
CompletionStatus.Partially
|
||||
Victory.CompletionStatus.Partially
|
||||
}
|
||||
else -> CompletionStatus.Incomplete
|
||||
else -> Victory.CompletionStatus.Incomplete
|
||||
}
|
||||
for (button in milestone.getVictoryScreenButtons(completionStatus, playerCivInfo)) {
|
||||
table.add(button).row()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user