mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -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
|
// Unit actions should look like: "Can {action description}, to allow them to be combined with modifiers
|
||||||
|
|
||||||
FoundCity("Founds a new city", UniqueTarget.Unit),
|
FoundCity("Founds a new city", UniqueTarget.Unit),
|
||||||
|
|
||||||
ConstructImprovementInstantly("Can instantly construct a [improvementName] improvement", 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>"))
|
@Deprecated("as of 4.5.2", ReplaceWith("Can instantly construct a [improvementName] improvement <by consuming this unit>"))
|
||||||
ConstructImprovementConsumingUnit("Can construct [improvementName]", UniqueTarget.Unit),
|
ConstructImprovementConsumingUnit("Can construct [improvementName]", UniqueTarget.Unit),
|
||||||
|
@ -176,14 +176,15 @@ object UnitActions {
|
|||||||
* (no movement left, too close to another city).
|
* (no movement left, too close to another city).
|
||||||
*/
|
*/
|
||||||
fun getFoundCityAction(unit: MapUnit, tile: Tile): UnitAction? {
|
fun getFoundCityAction(unit: MapUnit, tile: Tile): UnitAction? {
|
||||||
if (!unit.hasUnique(UniqueType.FoundCity)
|
val unique = unit.getMatchingUniques(UniqueType.FoundCity).firstOrNull()
|
||||||
|| tile.isWater || tile.isImpassible()) return null
|
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
|
// 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.civ.isOneCityChallenger() && unit.civ.hasEverOwnedOriginalCapital == true) return null
|
||||||
|
|
||||||
if (unit.currentMovement <= 0 || !tile.canBeSettled())
|
if (unit.currentMovement <= 0 || !tile.canBeSettled())
|
||||||
return UnitAction(UnitActionType.FoundCity, action = null)
|
return UnitAction(UnitActionType.FoundCity, action = null)
|
||||||
|
|
||||||
|
val hasActionModifiers = unique.conditionals.any { it.type?.targetTypes?.contains(UniqueTarget.UnitActionModifier) == true }
|
||||||
val foundAction = {
|
val foundAction = {
|
||||||
if (unit.civ.playerType != PlayerType.AI)
|
if (unit.civ.playerType != PlayerType.AI)
|
||||||
UncivGame.Current.settings.addCompletedTutorialTask("Found city")
|
UncivGame.Current.settings.addCompletedTutorialTask("Found city")
|
||||||
@ -191,8 +192,9 @@ object UnitActions {
|
|||||||
if (tile.ruleset.tileImprovements.containsKey("City center"))
|
if (tile.ruleset.tileImprovements.containsKey("City center"))
|
||||||
tile.changeImprovement("City center")
|
tile.changeImprovement("City center")
|
||||||
tile.removeRoad()
|
tile.removeRoad()
|
||||||
unit.destroy()
|
|
||||||
GUI.setUpdateWorldOnNextRender()
|
if (hasActionModifiers) activateSideEffects(unit, unique)
|
||||||
|
else unit.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.civ.playerType == PlayerType.AI)
|
if (unit.civ.playerType == PlayerType.AI)
|
||||||
@ -684,7 +686,9 @@ object UnitActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getMovementPointsToUse(actionUnique: Unique): Int {
|
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
|
if (movementCost != null) return movementCost
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user