Skip to content

Commit

Permalink
* Fixed a bug when token permanents were put on top or buttom of libr…
Browse files Browse the repository at this point in the history
…ary (e.g. using activated ability of a copied Timestream Navigator).
  • Loading branch information
LevelX2 committed Feb 6, 2018
1 parent e28d5ad commit 0a28ab2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Mage/src/main/java/mage/cards/CardsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,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
*/
Expand Down Expand Up @@ -105,7 +105,11 @@ public Card getRandom(Game game) {
return null;
}
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
Expand Down Expand Up @@ -151,7 +155,7 @@ public Set<Card> getCards(FilterCard filter, Game game) {
@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);
Expand Down

0 comments on commit 0a28ab2

Please sign in to comment.