mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Converted create/enhance religion actions to new format
This commit is contained in:
parent
c48584868d
commit
75a4f06d03
@ -51,7 +51,7 @@ object CivilianUnitAutomation {
|
||||
|
||||
if (unit.hasUnique(UniqueType.MayEnhanceReligion)
|
||||
&& unit.civ.religionManager.religionState < ReligionState.EnhancedReligion
|
||||
&& unit.civ.religionManager.mayEnhanceReligionAtAll(unit)
|
||||
&& unit.civ.religionManager.mayEnhanceReligionAtAll()
|
||||
)
|
||||
return ReligiousUnitAutomation.enhanceReligion(unit)
|
||||
|
||||
@ -170,5 +170,5 @@ object CivilianUnitAutomation {
|
||||
?: return // can't move anywhere!
|
||||
unit.movement.moveToTile(tileFurthestFromEnemy)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.map.mapunit.MapUnit
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.Counter
|
||||
import com.unciv.models.Religion
|
||||
import com.unciv.models.ruleset.Belief
|
||||
@ -271,16 +272,16 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
return true
|
||||
}
|
||||
|
||||
fun mayFoundReligionNow(prophet: MapUnit): Boolean {
|
||||
fun mayFoundReligionHere(tile: Tile): Boolean {
|
||||
if (!mayFoundReligionAtAll()) return false
|
||||
if (!prophet.getTile().isCityCenter()) return false
|
||||
if (prophet.getTile().getCity()!!.isHolyCity()) return false
|
||||
if (!tile.isCityCenter()) return false
|
||||
if (tile.getCity()!!.isHolyCity()) return false
|
||||
// No double holy cities. Not sure if these were allowed in the base game
|
||||
return true
|
||||
}
|
||||
|
||||
fun foundReligion(prophet: MapUnit) {
|
||||
if (!mayFoundReligionNow(prophet)) return // How did you do this?
|
||||
if (!mayFoundReligionHere(prophet.getTile())) return // How did you do this?
|
||||
if (religionState == ReligionState.None) shouldChoosePantheonBelief = true
|
||||
religionState = ReligionState.FoundingReligion
|
||||
civInfo.religionManager.foundingCityId = prophet.getTile().getCity()!!.id
|
||||
@ -289,7 +290,7 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionAtAll(prophet: MapUnit): Boolean {
|
||||
fun mayEnhanceReligionAtAll(): Boolean {
|
||||
if (!civInfo.gameInfo.isReligionEnabled()) return false
|
||||
if (religion == null) return false // First found a pantheon
|
||||
if (religionState != ReligionState.Religion) return false // First found an actual religion
|
||||
@ -304,14 +305,14 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
return true
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionNow(prophet: MapUnit): Boolean {
|
||||
if (!mayEnhanceReligionAtAll(prophet)) return false
|
||||
if (!prophet.getTile().isCityCenter()) return false
|
||||
fun mayEnhanceReligionHere(tile: Tile): Boolean {
|
||||
if (!mayEnhanceReligionAtAll()) return false
|
||||
if (!tile.isCityCenter()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
fun useProphetForEnhancingReligion(prophet: MapUnit) {
|
||||
if (!mayEnhanceReligionNow(prophet)) return // How did you do this?
|
||||
if (!mayEnhanceReligionHere(prophet.getTile())) return // How did you do this?
|
||||
religionState = ReligionState.EnhancingReligion
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnhancingReligion))
|
||||
|
@ -43,7 +43,9 @@ object UnitActions {
|
||||
UnitActionType.HurryResearch to UnitActionsGreatPerson::getHurryResearchActions,
|
||||
UnitActionType.HurryWonder to UnitActionsGreatPerson::getHurryWonderActions,
|
||||
UnitActionType.HurryBuilding to UnitActionsGreatPerson::getHurryBuildingActions,
|
||||
UnitActionType.ConductTradeMission to UnitActionsGreatPerson::getConductTradeMissionActions
|
||||
UnitActionType.ConductTradeMission to UnitActionsGreatPerson::getConductTradeMissionActions,
|
||||
UnitActionType.FoundReligion to UnitActionsReligion::getFoundReligionActions,
|
||||
UnitActionType.EnhanceReligion to UnitActionsReligion::getEnhanceReligionActions
|
||||
)
|
||||
|
||||
private fun getNormalActions(unit: MapUnit): List<UnitAction> {
|
||||
@ -54,8 +56,6 @@ object UnitActions {
|
||||
actionList.addAll(getActionsFunction(unit, tile))
|
||||
|
||||
// Determined by unit uniques
|
||||
UnitActionsReligion.addFoundReligionAction(unit, actionList)
|
||||
UnitActionsReligion.addEnhanceReligionAction(unit, actionList)
|
||||
UnitActionsFromUniques.addCreateWaterImprovements(unit, actionList)
|
||||
actionList += UnitActionsFromUniques.getImprovementConstructionActions(unit, tile)
|
||||
UnitActionsReligion.addSpreadReligionActions(unit, actionList)
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.screens.worldscreen.unit.actions
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.civilization.NotificationCategory
|
||||
import com.unciv.logic.map.mapunit.MapUnit
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.UnitAction
|
||||
import com.unciv.models.UnitActionType
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
@ -13,17 +14,17 @@ import com.unciv.ui.components.extensions.toPercent
|
||||
object UnitActionsReligion {
|
||||
|
||||
|
||||
internal fun addFoundReligionAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
if (!unit.civ.religionManager.mayFoundReligionAtAll()) return
|
||||
internal fun getFoundReligionActions(unit: MapUnit, tile:Tile): List<UnitAction> {
|
||||
if (!unit.civ.religionManager.mayFoundReligionAtAll()) return listOf()
|
||||
|
||||
val unique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.MayFoundReligion)
|
||||
.firstOrNull() ?: return
|
||||
.firstOrNull() ?: return listOf()
|
||||
|
||||
val hasActionModifiers = unique.conditionals.any { it.type?.targetTypes?.contains(
|
||||
UniqueTarget.UnitActionModifier
|
||||
) == true }
|
||||
|
||||
actionList += UnitAction(
|
||||
return listOf(UnitAction(
|
||||
UnitActionType.FoundReligion,
|
||||
|
||||
if (hasActionModifiers) UnitActionModifiers.actionTextWithSideEffects(
|
||||
@ -37,22 +38,22 @@ object UnitActionsReligion {
|
||||
|
||||
if (hasActionModifiers) UnitActionModifiers.activateSideEffects(unit, unique)
|
||||
else unit.consume()
|
||||
}.takeIf { unit.civ.religionManager.mayFoundReligionNow(unit) }
|
||||
)
|
||||
}.takeIf { unit.civ.religionManager.mayFoundReligionHere(tile) }
|
||||
))
|
||||
}
|
||||
|
||||
internal fun addEnhanceReligionAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
if (!unit.civ.religionManager.mayEnhanceReligionAtAll(unit)) return
|
||||
internal fun getEnhanceReligionActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
||||
if (!unit.civ.religionManager.mayEnhanceReligionAtAll()) return listOf()
|
||||
|
||||
val unique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.MayEnhanceReligion)
|
||||
.firstOrNull() ?: return
|
||||
.firstOrNull() ?: return listOf()
|
||||
|
||||
val hasActionModifiers = unique.conditionals.any { it.type?.targetTypes?.contains(
|
||||
UniqueTarget.UnitActionModifier
|
||||
) == true }
|
||||
|
||||
val baseTitle = "Enhance [${unit.civ.religionManager.religion!!.getReligionDisplayName()}]"
|
||||
actionList += UnitAction(
|
||||
return listOf(UnitAction(
|
||||
UnitActionType.EnhanceReligion,
|
||||
title = if (hasActionModifiers) UnitActionModifiers.actionTextWithSideEffects(
|
||||
baseTitle,
|
||||
@ -64,8 +65,8 @@ object UnitActionsReligion {
|
||||
unit.civ.religionManager.useProphetForEnhancingReligion(unit)
|
||||
if (hasActionModifiers) UnitActionModifiers.activateSideEffects(unit, unique)
|
||||
else unit.consume()
|
||||
}.takeIf { unit.civ.religionManager.mayEnhanceReligionNow(unit) }
|
||||
)
|
||||
}.takeIf { unit.civ.religionManager.mayEnhanceReligionHere(tile) }
|
||||
))
|
||||
}
|
||||
|
||||
private fun useActionWithLimitedUses(unit: MapUnit, action: String) {
|
||||
|
Loading…
Reference in New Issue
Block a user