forked from External/mage
updated some methods to support collections of card subclasses
This commit is contained in:
parent
c552234e9c
commit
3b5147f6ee
6 changed files with 37 additions and 28 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
|
|
@ -28,10 +29,12 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
}
|
||||
}
|
||||
|
||||
public CardsImpl(Set<Card> cards) {
|
||||
for (Card card : cards) {
|
||||
this.add(card.getId());
|
||||
}
|
||||
public CardsImpl(List<? extends Card> cards) {
|
||||
this.addAll(cards);
|
||||
}
|
||||
|
||||
public CardsImpl(Set<? extends Card> cards) {
|
||||
this.addAll(cards);
|
||||
}
|
||||
|
||||
public CardsImpl(Collection<UUID> cardIds) {
|
||||
|
|
@ -172,16 +175,22 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addAll(List<Card> cards) {
|
||||
for (Card card : cards) {
|
||||
add(card.getId());
|
||||
public void addAll(List<? extends Card> cards) {
|
||||
if (cards != null) {
|
||||
cards.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(MageItem::getId)
|
||||
.forEach(this::add);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAll(Set<Card> cards) {
|
||||
for (Card card : cards) {
|
||||
add(card.getId());
|
||||
public void addAll(Set<? extends Card> cards) {
|
||||
if (cards != null) {
|
||||
cards.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(MageItem::getId)
|
||||
.forEach(this::add);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue