mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
Resolved #10676 - Citezenship policy grants worker even without having cities
This commit is contained in:
@ -57,9 +57,7 @@ object UniqueTriggerActivation {
|
|||||||
when (unique.type) {
|
when (unique.type) {
|
||||||
UniqueType.OneTimeFreeUnit -> {
|
UniqueType.OneTimeFreeUnit -> {
|
||||||
val unitName = unique.params[0]
|
val unitName = unique.params[0]
|
||||||
val baseUnit = ruleSet.units[unitName]
|
val baseUnit = ruleSet.units[unitName] ?: return false
|
||||||
if ((chosenCity == null && tile == null) || baseUnit == null)
|
|
||||||
return false
|
|
||||||
val unit = civInfo.getEquivalentUnit(baseUnit)
|
val unit = civInfo.getEquivalentUnit(baseUnit)
|
||||||
if (unit.isCityFounder() && civInfo.isOneCityChallenger())
|
if (unit.isCityFounder() && civInfo.isOneCityChallenger())
|
||||||
return false
|
return false
|
||||||
@ -69,10 +67,15 @@ object UniqueTriggerActivation {
|
|||||||
if (limit != null && limit <= civInfo.units.getCivUnits().count { it.name == unitName })
|
if (limit != null && limit <= civInfo.units.getCivUnits().count { it.name == unitName })
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val placedUnit = if (city != null || tile == null)
|
// 4 situations: If city ->
|
||||||
civInfo.units.addUnit(unitName, chosenCity) ?: return false
|
val placedUnit = when {
|
||||||
else civInfo.units.placeUnitNearTile(tile.position, unitName) ?: return false
|
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.getCivUnits().any() ->
|
||||||
|
civInfo.units.placeUnitNearTile(civInfo.units.getCivUnits().first().currentTile.position, unitName) ?: return false
|
||||||
|
else -> return false
|
||||||
|
}
|
||||||
val notificationText = getNotificationText(notification, triggerNotificationText,
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
"Gained [1] [$unitName] unit(s)")
|
"Gained [1] [$unitName] unit(s)")
|
||||||
?: return true
|
?: return true
|
||||||
|
Reference in New Issue
Block a user