Transported units gifting fix (#9865)

* Gifting units containing transported units now gifts the transported units as well.

* Change transported units so that they can't be gifted.
This commit is contained in:
Oskar Niesen 2023-08-03 03:38:25 -05:00 committed by GitHub
parent 0fe584700b
commit 15bfaa24a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -559,10 +559,9 @@ class MapUnit : IsPartOfGameInfoSerialization {
fun gift(recipient: Civilization) {
civ.units.removeUnit(this)
civ.cache.updateViewableTiles()
// all transported units should be destroyed as well
// all transported units should be gift as well
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
.toList() // because we're changing the list
.forEach { unit -> unit.destroy() }
.forEach { unit -> unit.gift(recipient) }
assignOwner(recipient)
recipient.cache.updateViewableTiles()
}

View File

@ -634,6 +634,9 @@ object UnitActions {
// If gifting to major civ they need to be friendly
else if (!tile.isFriendlyTerritory(unit.civ)) return null
// Transported units can't be gifted
if (unit.isTransported) return null
if (unit.currentMovement <= 0)
return UnitAction(UnitActionType.GiftUnit, action = null)