mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 12:48:56 +07:00
Fix not getting unique unit from tile based free unit trigger (For real this time) (#10746)
This commit is contained in:
@ -64,20 +64,20 @@ object UniqueTriggerActivation {
|
||||
|
||||
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||
.map { it.params[0].toInt() }.minOrNull()
|
||||
if (limit != null && limit <= civInfo.units.getCivUnits().count { it.name == unitName })
|
||||
if (limit != null && limit <= civInfo.units.getCivUnits().count { it.name == unit.name })
|
||||
return false
|
||||
|
||||
// 4 situations: If city ->
|
||||
val placedUnit = when {
|
||||
city != null || (tile == null && civInfo.cities.isNotEmpty()) ->
|
||||
civInfo.units.addUnit(unitName, chosenCity) ?: return false
|
||||
tile != null -> civInfo.units.placeUnitNearTile(tile.position, unitName) ?: return false
|
||||
civInfo.units.addUnit(unit, chosenCity) ?: return false
|
||||
tile != null -> civInfo.units.placeUnitNearTile(tile.position, unit) ?: return false
|
||||
civInfo.units.getCivUnits().any() ->
|
||||
civInfo.units.placeUnitNearTile(civInfo.units.getCivUnits().first().currentTile.position, unitName) ?: return false
|
||||
civInfo.units.placeUnitNearTile(civInfo.units.getCivUnits().first().currentTile.position, unit) ?: return false
|
||||
else -> return false
|
||||
}
|
||||
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||
"Gained [1] [$unitName] unit(s)")
|
||||
"Gained [1] [${unit.name}] unit(s)")
|
||||
?: return true
|
||||
|
||||
civInfo.addNotification(
|
||||
@ -99,7 +99,7 @@ object UniqueTriggerActivation {
|
||||
|
||||
val limit = unit.getMatchingUniques(UniqueType.MaxNumberBuildable)
|
||||
.map { it.params[0].toInt() }.minOrNull()
|
||||
val unitCount = civInfo.units.getCivUnits().count { it.name == unitName }
|
||||
val unitCount = civInfo.units.getCivUnits().count { it.name == unit.name }
|
||||
val amountFromTriggerable = unique.params[0].toInt()
|
||||
val actualAmount = when {
|
||||
limit == null -> amountFromTriggerable
|
||||
@ -111,22 +111,22 @@ object UniqueTriggerActivation {
|
||||
|
||||
val tilesUnitsWerePlacedOn: MutableList<Vector2> = mutableListOf()
|
||||
repeat(actualAmount) {
|
||||
val placedUnit = if (city != null || tile == null) civInfo.units.addUnit(unitName, chosenCity)
|
||||
else civInfo.units.placeUnitNearTile(tile.position, unitName)
|
||||
val placedUnit = if (city != null || tile == null) civInfo.units.addUnit(unit, chosenCity)
|
||||
else civInfo.units.placeUnitNearTile(tile.position, unit)
|
||||
if (placedUnit != null)
|
||||
tilesUnitsWerePlacedOn.add(placedUnit.getTile().position)
|
||||
}
|
||||
if (tilesUnitsWerePlacedOn.isEmpty()) return true
|
||||
|
||||
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||
"Gained [${tilesUnitsWerePlacedOn.size}] [$unitName] unit(s)")
|
||||
"Gained [${tilesUnitsWerePlacedOn.size}] [${unit.name}] unit(s)")
|
||||
?: return true
|
||||
|
||||
civInfo.addNotification(
|
||||
notificationText,
|
||||
MapUnitAction(tilesUnitsWerePlacedOn),
|
||||
NotificationCategory.Units,
|
||||
civInfo.getEquivalentUnit(unit).name
|
||||
unit.name
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user