mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 02:42:16 -04:00
'founds a new city' now accepts action modifiers
This commit is contained in:
parent
06fa2c2378
commit
64925adc7e
@ -350,6 +350,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// Unit actions should look like: "Can {action description}, to allow them to be combined with modifiers
|
||||
|
||||
FoundCity("Founds a new city", UniqueTarget.Unit),
|
||||
|
||||
ConstructImprovementInstantly("Can instantly construct a [improvementName] improvement", UniqueTarget.Unit),
|
||||
@Deprecated("as of 4.5.2", ReplaceWith("Can instantly construct a [improvementName] improvement <by consuming this unit>"))
|
||||
ConstructImprovementConsumingUnit("Can construct [improvementName]", UniqueTarget.Unit),
|
||||
|
@ -176,14 +176,15 @@ object UnitActions {
|
||||
* (no movement left, too close to another city).
|
||||
*/
|
||||
fun getFoundCityAction(unit: MapUnit, tile: Tile): UnitAction? {
|
||||
if (!unit.hasUnique(UniqueType.FoundCity)
|
||||
|| tile.isWater || tile.isImpassible()) return null
|
||||
val unique = unit.getMatchingUniques(UniqueType.FoundCity).firstOrNull()
|
||||
if (unique == null || tile.isWater || tile.isImpassible()) return null
|
||||
// Spain should still be able to build Conquistadors in a one city challenge - but can't settle them
|
||||
if (unit.civ.isOneCityChallenger() && unit.civ.hasEverOwnedOriginalCapital == true) return null
|
||||
|
||||
if (unit.currentMovement <= 0 || !tile.canBeSettled())
|
||||
return UnitAction(UnitActionType.FoundCity, action = null)
|
||||
|
||||
val hasActionModifiers = unique.conditionals.any { it.type?.targetTypes?.contains(UniqueTarget.UnitActionModifier) == true }
|
||||
val foundAction = {
|
||||
if (unit.civ.playerType != PlayerType.AI)
|
||||
UncivGame.Current.settings.addCompletedTutorialTask("Found city")
|
||||
@ -191,8 +192,9 @@ object UnitActions {
|
||||
if (tile.ruleset.tileImprovements.containsKey("City center"))
|
||||
tile.changeImprovement("City center")
|
||||
tile.removeRoad()
|
||||
unit.destroy()
|
||||
GUI.setUpdateWorldOnNextRender()
|
||||
|
||||
if (hasActionModifiers) activateSideEffects(unit, unique)
|
||||
else unit.destroy()
|
||||
}
|
||||
|
||||
if (unit.civ.playerType == PlayerType.AI)
|
||||
@ -684,7 +686,9 @@ object UnitActions {
|
||||
}
|
||||
|
||||
fun getMovementPointsToUse(actionUnique: Unique): Int {
|
||||
val movementCost = actionUnique.conditionals.filter { it.type == UniqueType.UnitActionMovementCost }.minOfOrNull { it.params[0].toInt() }
|
||||
val movementCost = actionUnique.conditionals
|
||||
.filter { it.type == UniqueType.UnitActionMovementCost }
|
||||
.minOfOrNull { it.params[0].toInt() }
|
||||
if (movementCost != null) return movementCost
|
||||
return 1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user