mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Standardized 'spread religion' / 'remove heresy' actions
This commit is contained in:
@ -205,13 +205,12 @@ object UnitActionsFromUniques {
|
|||||||
|
|
||||||
|
|
||||||
fun getImprovementCreationActions(unit: MapUnit, tile: Tile) = sequence {
|
fun getImprovementCreationActions(unit: MapUnit, tile: Tile) = sequence {
|
||||||
val waterImprovementAction = getWaterImprovementAction(unit)
|
val waterImprovementAction = getWaterImprovementAction(unit, tile)
|
||||||
if (waterImprovementAction != null) yield(waterImprovementAction)
|
if (waterImprovementAction != null) yield(waterImprovementAction)
|
||||||
yieldAll(getImprovementConstructionActionsFromGeneralUnique(unit, tile))
|
yieldAll(getImprovementConstructionActionsFromGeneralUnique(unit, tile))
|
||||||
}.asIterable()
|
}.asIterable()
|
||||||
|
|
||||||
fun getWaterImprovementAction(unit: MapUnit): UnitAction? {
|
fun getWaterImprovementAction(unit: MapUnit, tile: Tile): UnitAction? {
|
||||||
val tile = unit.currentTile
|
|
||||||
if (!tile.isWater || !unit.hasUnique(UniqueType.CreateWaterImprovements) || tile.resource == null) return null
|
if (!tile.isWater || !unit.hasUnique(UniqueType.CreateWaterImprovements) || tile.resource == null) return null
|
||||||
|
|
||||||
val improvementName = tile.tileResource.getImprovingImprovement(tile, unit.civ) ?: return null
|
val improvementName = tile.tileResource.getImprovingImprovement(tile, unit.civ) ?: return null
|
||||||
@ -372,7 +371,7 @@ object UnitActionsFromUniques {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return listOf(UnitAction(UnitActionType.ConstructImprovement,
|
return listOf(UnitAction(UnitActionType.ConstructImprovement,
|
||||||
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
isCurrentAction = tile.hasImprovementInProgress(),
|
||||||
action = {
|
action = {
|
||||||
GUI.pushScreen(ImprovementPickerScreen(tile, unit) {
|
GUI.pushScreen(ImprovementPickerScreen(tile, unit) {
|
||||||
if (GUI.getSettings().autoUnitCycle)
|
if (GUI.getSettings().autoUnitCycle)
|
||||||
|
@ -87,7 +87,7 @@ object UnitActionsReligion {
|
|||||||
|
|
||||||
fun addSpreadReligionActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
fun addSpreadReligionActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
||||||
if (!unit.civ.religionManager.maySpreadReligionAtAll(unit)) return listOf()
|
if (!unit.civ.religionManager.maySpreadReligionAtAll(unit)) return listOf()
|
||||||
val city = unit.currentTile.getCity() ?: return listOf()
|
val city = tile.getCity() ?: return listOf()
|
||||||
|
|
||||||
val newStyleUnique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.CanSpreadReligion).firstOrNull()
|
val newStyleUnique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.CanSpreadReligion).firstOrNull()
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ object UnitActionsReligion {
|
|||||||
val religion = unit.civ.gameInfo.religions[unit.religion] ?: return listOf()
|
val religion = unit.civ.gameInfo.religions[unit.religion] ?: return listOf()
|
||||||
if (religion.isPantheon()) return listOf()
|
if (religion.isPantheon()) return listOf()
|
||||||
|
|
||||||
val city = unit.currentTile.getCity() ?: return listOf()
|
val city = tile.getCity() ?: return listOf()
|
||||||
if (city.civ != unit.civ) return listOf()
|
if (city.civ != unit.civ) return listOf()
|
||||||
// Only allow the action if the city actually has any foreign religion
|
// Only allow the action if the city actually has any foreign religion
|
||||||
// This will almost be always due to pressure from cities close-by
|
// This will almost be always due to pressure from cities close-by
|
||||||
|
Reference in New Issue
Block a user