other: reworked target selection (now it use same logic and methods in all places), fixed AI and selection freezes in some use cases (related to #13606, #11285)

This commit is contained in:
Oleg Agafonov 2025-05-07 17:34:36 +04:00
parent 62aa310a4f
commit a53eb66b58
10 changed files with 133 additions and 53 deletions

View file

@ -7,6 +7,7 @@ import mage.constants.Zone;
import mage.filter.Filter;
import mage.game.Game;
import mage.players.Player;
import mage.util.Copyable;
import java.io.Serializable;
import java.util.Collection;
@ -17,14 +18,23 @@ import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
public interface Target extends Serializable {
public interface Target extends Copyable<Target>, Serializable {
/**
* All targets selected by a player
* <p>
* Warning, for "up to" targets it will return true all the time, so make sure your dialog
* use do-while logic and call "choose" one time min or use doneChoosing
*/
boolean isChosen(Game game);
// TODO: combine code or research usages (doneChoosing must be in while cycles, isChosen in other places, see #13606)
boolean doneChoosing(Game game);
void clearChosen();
boolean isChoiceSelected();
boolean isNotTarget();
/**
@ -161,6 +171,7 @@ public interface Target extends Serializable {
UUID getFirstTarget();
@Override
Target copy();
// some targets are chosen from players that are not the controller of the ability (e.g. Pandemonium)