mirror of
https://github.com/correl/mage.git
synced 2025-03-17 01:06:26 -09:00
* Fixed a bug when token permanents were put on top or buttom of library (e.g. using activated ability of a copied Timestream Navigator).
This commit is contained in:
parent
e28d5ad8cc
commit
0a28ab2d5a
1 changed files with 10 additions and 6 deletions
|
@ -27,15 +27,15 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import mage.util.ThreadLocalStringBuilder;
|
import mage.util.ThreadLocalStringBuilder;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -105,7 +105,11 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
UUID[] cards = this.toArray(new UUID[this.size()]);
|
UUID[] cards = this.toArray(new UUID[this.size()]);
|
||||||
return game.getCard(cards[RandomUtil.nextInt(cards.length)]);
|
MageObject object = game.getObject(cards[RandomUtil.nextInt(cards.length)]); // neccessary if permanent tokens are in the collection
|
||||||
|
if (object instanceof Card) {
|
||||||
|
return (Card) object;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,7 +155,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
||||||
@Override
|
@Override
|
||||||
public Set<Card> getCards(Game game) {
|
public Set<Card> getCards(Game game) {
|
||||||
Set<Card> cards = new LinkedHashSet<>();
|
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();
|
UUID cardId = it.next();
|
||||||
|
|
||||||
Card card = game.getCard(cardId);
|
Card card = game.getCard(cardId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue