mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +07:00
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:
parent
0fe584700b
commit
15bfaa24a5
@ -559,10 +559,9 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
fun gift(recipient: Civilization) {
|
fun gift(recipient: Civilization) {
|
||||||
civ.units.removeUnit(this)
|
civ.units.removeUnit(this)
|
||||||
civ.cache.updateViewableTiles()
|
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) }
|
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
||||||
.toList() // because we're changing the list
|
.forEach { unit -> unit.gift(recipient) }
|
||||||
.forEach { unit -> unit.destroy() }
|
|
||||||
assignOwner(recipient)
|
assignOwner(recipient)
|
||||||
recipient.cache.updateViewableTiles()
|
recipient.cache.updateViewableTiles()
|
||||||
}
|
}
|
||||||
|
@ -634,6 +634,9 @@ object UnitActions {
|
|||||||
// If gifting to major civ they need to be friendly
|
// If gifting to major civ they need to be friendly
|
||||||
else if (!tile.isFriendlyTerritory(unit.civ)) return null
|
else if (!tile.isFriendlyTerritory(unit.civ)) return null
|
||||||
|
|
||||||
|
// Transported units can't be gifted
|
||||||
|
if (unit.isTransported) return null
|
||||||
|
|
||||||
if (unit.currentMovement <= 0)
|
if (unit.currentMovement <= 0)
|
||||||
return UnitAction(UnitActionType.GiftUnit, action = null)
|
return UnitAction(UnitActionType.GiftUnit, action = null)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user