Unciv/android/Images
Arthur van der Staaij a7afc0718c
Unit swapping (#4049)
* Added an icon for unit swapping

* Implemented unit swapping

In the original Civ V, unit swapping is a supported mechanic.
If you try to move a unit to a tile with another of your units, and both
units have enough movement points left to reach the other's tile, they
will swap places. They will consume only the movement points needed to
reach the other's tile in this way.

This change implements unit swapping for Unciv.

To prevent all kinds of problems from arising with automatic unit
movement, unit swapping can only be done explicitly. This also means
that it can only be done if the unit-swap movement is possible in a
single turn. It is however not limited to adjacent units.

Because Unciv supports mobile devices, there is in general no separation
between a unit-selection click and a movement click. Clicking on another
unit while a unit is selected simply selects that other unit. Because we
do not want to make it more difficult to select other units in this way,
unit swapping is implemented as a separate "movement mode": to toggle
this mode on or off, the new unit action "Swap units" must be used.
Newly selected units still always start in the normal movement mode.

In the unit-swap movement mode, the possible swap tiles are highlighted
instead of the possible movement and attack tiles. Clicking on a
highlighted tile will display a swap button, similar to the movement
button, or instantly perform the swap if single-click-movement is
enabled. This new behavior overrides the selection of the unit on the
target tile: if the user wants to select the unit instead, they have to
exit the unit-swapping mode first.

The swapping code is robust, it can even handle swaps that involve a
paradrop!

An option to always swap-move when an eligible tile is clicked instead
of requiring the unit-swapping mode, similar to the existing
single-click-movement option, could perhaps be added in later.

* Added some comments to existing movement functions

* Fixed a silly mistake

Fixed a silly mistake which caused the unit-swapping eligibility
detection to sometimes remove units from the world.

* Removed some unneeded code

* Fixed movement buttons not showing with world wrap

Fixed a bug where the "move here" and "swap with" buttons would only
show on the leftmost copy of the world when world wrap was enabled.

* Made the swap action only display if usable

Made the unit swapping button only display if there is at least one
possible swap movement.
2021-06-06 22:56:25 +03:00
..
EmojiIcons Added construction production info to city screen 2021-04-29 14:02:27 +03:00
ImprovementIcons Tileset for new layering is now in base game 2021-04-01 23:19:07 +03:00
NationIcons Aztecs and some other things (#3033) 2020-08-30 21:02:59 +03:00
OtherIcons Unit swapping (#4049) 2021-06-06 22:56:25 +03:00
PolicyIcons Resolved #1422 - resources are now spread over different terrains as much as possible 2019-12-08 21:19:45 +02:00
ResourceIcons Changed "Gold" resource to be called "Gold Ore" to not conflict with the yield type for translations - #2458 2021-02-23 20:05:00 +02:00
StatIcons Added Faith icon and display for games with Religion 2021-04-01 20:44:27 +03:00
TechIcons Added national wonders, fixed some minor issues (#3163) 2020-09-21 21:44:52 +03:00
TileSets Resolves #3926 - Wheat+Farm gets location-appropriate farm 2021-06-03 21:50:30 +03:00
UnitPromotionIcons Added the amphibious promotion and the marine unit (#3987) 2021-05-29 23:42:04 +03:00