* Move cards from battlefield - fixed that some abilities can duplicates moving cards (#4655); For devs: all cards with CardsImpl and moveCards calls like Winds of Abandon;

This commit is contained in:
Oleg Agafonov 2019-06-07 18:35:30 +04:00
parent fa973d9a90
commit 90a5a55a72

View file

@ -1,15 +1,15 @@
package mage.cards;
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.util.RandomUtil;
import mage.util.ThreadLocalStringBuilder;
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -135,13 +135,15 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
@Override
public Set<Card> getCards(Game game) {
Set<Card> cards = new LinkedHashSet<>();
for (Iterator<UUID> it = this.iterator(); it.hasNext();) { // Changed to iterator because of ConcurrentModificationException
for (Iterator<UUID> it = this.iterator(); it.hasNext(); ) { // Changed to iterator because of ConcurrentModificationException
UUID cardId = it.next();
Card card = game.getCard(cardId);
// cards from battlefield must be as permanent, not card (moveCards uses instanceOf Permanent)
Card card = game.getPermanent(cardId);
if (card == null) {
card = game.getPermanent(cardId); // needed to get TokenCard objects
card = game.getCard(cardId);
}
if (card != null) { // this can happen during the cancelation (player concedes) of a game
cards.add(card);
}