mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00: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;
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -105,7 +105,11 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
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
|
||||
|
@ -151,7 +155,7 @@ 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);
|
||||
|
|
Loading…
Reference in a new issue