mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +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
|
@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);
|
return computerPlayer.moveCardsToGraveyardWithInfo(allCards, source, game, fromZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4067,14 +4067,14 @@ public class TestPlayer implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||||
Ability source, Game game
|
Ability source, Game game
|
||||||
) {
|
) {
|
||||||
return computerPlayer.moveCards(cards, toZone, source, game);
|
return computerPlayer.moveCards(cards, toZone, source, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||||
Ability source, Game game,
|
Ability source, Game game,
|
||||||
boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects
|
boolean tapped, boolean faceDown, boolean byOwner, List<UUID> appliedEffects
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1161,12 +1161,12 @@ public class PlayerStub implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,7 +1196,7 @@ public class PlayerStub implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.game.Game;
|
|
||||||
|
|
||||||
public interface Cards extends Set<UUID>, Serializable {
|
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 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);
|
Set<Card> getCards(Game game);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
|
import mage.MageItem;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -28,10 +29,12 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardsImpl(Set<Card> cards) {
|
public CardsImpl(List<? extends Card> cards) {
|
||||||
for (Card card : cards) {
|
this.addAll(cards);
|
||||||
this.add(card.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CardsImpl(Set<? extends Card> cards) {
|
||||||
|
this.addAll(cards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardsImpl(Collection<UUID> cardIds) {
|
public CardsImpl(Collection<UUID> cardIds) {
|
||||||
|
@ -172,16 +175,22 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAll(List<Card> cards) {
|
public void addAll(List<? extends Card> cards) {
|
||||||
for (Card card : cards) {
|
if (cards != null) {
|
||||||
add(card.getId());
|
cards.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(MageItem::getId)
|
||||||
|
.forEach(this::add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAll(Set<Card> cards) {
|
public void addAll(Set<? extends Card> cards) {
|
||||||
for (Card card : cards) {
|
if (cards != null) {
|
||||||
add(card.getId());
|
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(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
|
* 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
|
* @param appliedEffects
|
||||||
* @return
|
* @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);
|
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
|
* @param fromZone if null, this info isn't postet
|
||||||
* @return Set<Cards> that were successful moved to graveyard
|
* @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
|
* 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
|
@Override
|
||||||
public boolean moveCards(Set<Card> cards, Zone toZone,
|
public boolean moveCards(Set<? extends Card> cards, Zone toZone,
|
||||||
Ability source, Game game
|
Ability source, Game game
|
||||||
) {
|
) {
|
||||||
return moveCards(cards, toZone, source, game, false, false, false, null);
|
return moveCards(cards, toZone, source, game, false, false, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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()) {
|
if (cards.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4248,13 +4248,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<>();
|
Set<Card> movedCards = new LinkedHashSet<>();
|
||||||
while (!allCards.isEmpty()) {
|
while (!allCards.isEmpty()) {
|
||||||
// identify cards from one owner
|
// identify cards from one owner
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
UUID ownerId = null;
|
UUID ownerId = null;
|
||||||
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
|
for (Iterator<? extends Card> it = allCards.iterator(); it.hasNext(); ) {
|
||||||
Card card = it.next();
|
Card card = it.next();
|
||||||
if (cards.isEmpty()) {
|
if (cards.isEmpty()) {
|
||||||
ownerId = card.getOwnerId();
|
ownerId = card.getOwnerId();
|
||||||
|
|
Loading…
Reference in a new issue