mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
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
|
@ -3639,7 +3639,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<? extends Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
return computerPlayer.moveCardsToGraveyardWithInfo(allCards, source, game, fromZone);
|
||||
}
|
||||
|
||||
|
@ -4067,14 +4067,14 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||
Ability source, Game game
|
||||
) {
|
||||
return computerPlayer.moveCards(cards, toZone, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||
Ability source, Game game,
|
||||
boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects
|
||||
) {
|
||||
|
|
|
@ -1161,12 +1161,12 @@ public class PlayerStub implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game) {
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects) {
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1196,7 +1196,7 @@ public class PlayerStub implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<Card> cards, Ability source, Game game, Zone fromZone) {
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<? extends Card> cards, Ability source, Game game, Zone fromZone) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
package mage.cards;
|
||||
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
|
||||
public interface Cards extends Set<UUID>, Serializable {
|
||||
|
||||
|
@ -19,9 +19,9 @@ public interface Cards extends Set<UUID>, Serializable {
|
|||
|
||||
void setOwner(UUID ownerId, Game game);
|
||||
|
||||
void addAll(List<Card> createCards);
|
||||
void addAll(List<? extends Card> createCards);
|
||||
|
||||
void addAll(Set<Card> createCards);
|
||||
void addAll(Set<? extends Card> createCards);
|
||||
|
||||
Set<Card> getCards(Game game);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -807,7 +807,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean moveCards(Card card, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects);
|
||||
|
||||
boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game);
|
||||
boolean moveCards(Set<? extends Card> cards, Zone toZone, Ability source, Game game);
|
||||
|
||||
/**
|
||||
* Universal method to move cards from one zone to another. Do not mix
|
||||
|
@ -826,7 +826,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param appliedEffects
|
||||
* @return
|
||||
*/
|
||||
boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects);
|
||||
boolean moveCards(Set<? extends Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects);
|
||||
|
||||
boolean moveCardsToExile(Card card, Ability source, Game game, boolean withName, UUID exileId, String exileZoneName);
|
||||
|
||||
|
@ -883,7 +883,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param fromZone if null, this info isn't postet
|
||||
* @return Set<Cards> that were successful moved to graveyard
|
||||
*/
|
||||
Set<Card> moveCardsToGraveyardWithInfo(Set<Card> cards, Ability source, Game game, Zone fromZone);
|
||||
Set<Card> moveCardsToGraveyardWithInfo(Set<? extends Card> cards, Ability source, Game game, Zone fromZone);
|
||||
|
||||
/**
|
||||
* Uses card.moveToZone and posts a inform message about moving the card to
|
||||
|
|
|
@ -4097,14 +4097,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||
Ability source, Game game
|
||||
) {
|
||||
return moveCards(cards, toZone, source, game, false, false, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveCards(Set<Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects) {
|
||||
public boolean moveCards(Set<? extends Card> cards, Zone toZone, Ability source, Game game, boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects) {
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -4248,13 +4248,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
public Set<Card> moveCardsToGraveyardWithInfo(Set<? extends Card> allCards, Ability source, Game game, Zone fromZone) {
|
||||
Set<Card> movedCards = new LinkedHashSet<>();
|
||||
while (!allCards.isEmpty()) {
|
||||
// identify cards from one owner
|
||||
Cards cards = new CardsImpl();
|
||||
UUID ownerId = null;
|
||||
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
|
||||
for (Iterator<? extends Card> it = allCards.iterator(); it.hasNext(); ) {
|
||||
Card card = it.next();
|
||||
if (cards.isEmpty()) {
|
||||
ownerId = card.getOwnerId();
|
||||
|
|
Loading…
Reference in a new issue