mirror of
https://github.com/correl/mage.git
synced 2025-04-01 19:07:57 -09:00
* Eerie Ultimatum - Fixed target handling. Duplicate names could be selected. Deselection was not possible.
This commit is contained in:
parent
29184316f2
commit
77a44733c2
2 changed files with 26 additions and 14 deletions
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human
Mage.Sets/src/mage/cards/e
|
@ -9,9 +9,9 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
|
@ -43,7 +43,6 @@ import mage.game.GameImpl;
|
|||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.events.DeclareAttackerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
@ -93,8 +92,8 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
protected boolean holdingPriority;
|
||||
|
||||
protected Queue<PlayerResponse> actionQueue = new LinkedList<>();
|
||||
protected Queue<PlayerResponse> actionQueueSaved = new LinkedList<>();
|
||||
protected ConcurrentLinkedQueue<PlayerResponse> actionQueue = new ConcurrentLinkedQueue<>();
|
||||
protected ConcurrentLinkedQueue<PlayerResponse> actionQueueSaved = new ConcurrentLinkedQueue<>();
|
||||
protected int actionIterations = 0;
|
||||
protected boolean recordingMacro = false;
|
||||
protected boolean macroTriggeredSelectionFlag;
|
||||
|
@ -159,7 +158,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
protected boolean pullResponseFromQueue(Game game) {
|
||||
if (actionQueue.isEmpty() && actionIterations > 0 && !actionQueueSaved.isEmpty()) {
|
||||
actionQueue = new LinkedList<>(actionQueueSaved);
|
||||
actionQueue = new ConcurrentLinkedQueue<>(actionQueueSaved);
|
||||
actionIterations--;
|
||||
// logger.info("MACRO iteration: " + actionIterations);
|
||||
}
|
||||
|
@ -685,11 +684,11 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
waitForResponse(game);
|
||||
|
||||
if (response.getUUID() != null) {
|
||||
if (target.canTarget(abilityControllerId, response.getUUID(), null, cards, game)) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
if (response.getUUID() != null) {
|
||||
if (target.getTargets().contains(response.getUUID())) { // if already included remove it with
|
||||
target.remove(response.getUUID());
|
||||
} else {
|
||||
if (target.canTarget(abilityControllerId, response.getUUID(), null, cards, game)) {
|
||||
target.add(response.getUUID(), game);
|
||||
if (target.doneChosing()) {
|
||||
return true;
|
||||
|
|
|
@ -76,11 +76,8 @@ class EerieUltimatumEffect extends OneShotEffect {
|
|||
|
||||
class EerieUltimatumTarget extends TargetCardInYourGraveyard {
|
||||
|
||||
private static final FilterCard filter
|
||||
= new FilterPermanentCard("permanent cards with different names");
|
||||
|
||||
EerieUltimatumTarget() {
|
||||
super(0, Integer.MAX_VALUE, filter, true);
|
||||
super(0, Integer.MAX_VALUE, new FilterPermanentCard("permanent cards with different names"), true);
|
||||
}
|
||||
|
||||
private EerieUltimatumTarget(final EerieUltimatumTarget target) {
|
||||
|
@ -92,6 +89,22 @@ class EerieUltimatumTarget extends TargetCardInYourGraveyard {
|
|||
return new EerieUltimatumTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability ability, Game game) {
|
||||
if (super.canTarget(playerId, id, ability, game)) {
|
||||
Set<String> names = this.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.map(MageObject::getName)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
Card card = game.getCard(id);
|
||||
return card != null && !names.contains(card.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
||||
|
|
Loading…
Add table
Reference in a new issue