forked from External/mage
Add documentation to Cards and CardsImpl (#9019)
* Added minor documentation and TODO questions * Fixed typo * Address one set of comments * merge fix * remove commented code --------- Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
parent
af2d336045
commit
6b5d4abb69
58 changed files with 124 additions and 112 deletions
|
|
@ -107,7 +107,7 @@ class AlrundGodOfTheCosmosEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Set<Card> twoCardsFromTop = controller.getLibrary().getTopCards(game, 2);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(twoCardsFromTop);
|
||||
cards.addAllCards(twoCardsFromTop);
|
||||
controller.revealCards(source, cards, game);
|
||||
for (Card card : cards.getCards(game)) {
|
||||
if (card.getCardType(game).toString().contains(chosenCardType)) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class AminatousAuguryEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
Cards cardsToCast = new CardsImpl();
|
||||
cardsToCast.addAll(auguryExileZone.getCards(game));
|
||||
cardsToCast.addAllCards(auguryExileZone.getCards(game));
|
||||
|
||||
// put a land card from among them onto the battlefield
|
||||
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_LAND_A);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class AnimistsAwakeningEffect extends OneShotEffect {
|
|||
}
|
||||
Cards cards = new CardsImpl();
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, xValue));
|
||||
cards.addAllCards(controller.getLibrary().getTopCards(game, xValue));
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
Set<Card> toBattlefield = new LinkedHashSet<>();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class BalshanBeguilerEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getTopCards(game, 2));
|
||||
cards.addAllCards(player.getLibrary().getTopCards(game, 2));
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class BalthorTheDefiledEffect extends OneShotEffect {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
cardsToReturn.addAll(player.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
cardsToReturn.addAllCards(player.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
}
|
||||
}
|
||||
controller.moveCards(cardsToReturn.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
|
|
|
|||
|
|
@ -73,9 +73,7 @@ class BoneyardParleyEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (Target target : source.getTargets()) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
cards.add(cardId);
|
||||
}
|
||||
cards.addAll(target.getTargets());
|
||||
}
|
||||
if (!cards.isEmpty() && player.moveCards(cards, Zone.EXILED, source, game)) {
|
||||
TargetOpponent targetOpponent = new TargetOpponent(true);
|
||||
|
|
@ -109,23 +107,9 @@ class BoneyardParleyEffect extends OneShotEffect {
|
|||
pile1Set.addAll(pile1);
|
||||
pile2Set.addAll(pile2);
|
||||
|
||||
// Cards toBattlefield = new CardsImpl();
|
||||
// Cards toGraveyard = new CardsImpl();
|
||||
//
|
||||
// if (pile1Zone == Zone.BATTLEFIELD) {
|
||||
// toBattlefield.addAll(pile1);
|
||||
// toGraveyard.addAll(pile2);
|
||||
// } else {
|
||||
// toBattlefield.addAll(pile2);
|
||||
// toGraveyard.addAll(pile1);
|
||||
// }
|
||||
player.moveCards(pile1Set, pile1Zone, source, game, false, false, false, null);
|
||||
player.moveCards(pile2Set, pile2Zone, source, game, false, false, false, null);
|
||||
|
||||
// StringBuilder sb = new StringBuilder("Pile 1, going to ").append(pile1Zone == Zone.BATTLEFIELD ? "Battlefield" : "Graveyard").append(": ");
|
||||
// game.informPlayers(sb.toString());
|
||||
// sb = new StringBuilder("Pile 2, going to ").append(pile2Zone == Zone.BATTLEFIELD ? "Battlefield" : "Graveyard").append(':');
|
||||
// game.informPlayers(sb.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class BoosterTutorEffect extends OneShotEffect {
|
|||
Set<Card> cardsToLoad = new HashSet<Card>(boosterPack);
|
||||
game.loadCards(cardsToLoad, controller.getId());
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(boosterPack);
|
||||
cards.addAllCards(boosterPack);
|
||||
if (controller.choose(Outcome.Benefit, cards, targetCard, source, game)) {
|
||||
Card card = game.getCard(targetCard.getFirstTarget());
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class BrilliantUltimatumEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
Cards pile2 = new CardsImpl();
|
||||
pile2.addAll(controller.getLibrary().getTopCards(game, 5));
|
||||
pile2.addAllCards(controller.getLibrary().getTopCards(game, 5));
|
||||
controller.moveCardsToExile(pile2.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName());
|
||||
|
||||
TargetOpponent targetOpponent = new TargetOpponent(true);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class CampfireEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl(game.getCommanderCardsFromCommandZone(player, CommanderCardType.ANY));
|
||||
cards.addAll(player.getGraveyard().getCards(filter, game));
|
||||
cards.addAllCards(player.getGraveyard().getCards(filter, game));
|
||||
player.moveCards(cards, Zone.HAND, source, game);
|
||||
player.putCardsOnBottomOfLibrary(player.getGraveyard(), game, source, false);
|
||||
player.shuffleLibrary(source, game);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ClearTheLandEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
Library library = player.getLibrary();
|
||||
Cards cardsToReveal = new CardsImpl();
|
||||
cardsToReveal.addAll(library.getTopCards(game, 5));
|
||||
cardsToReveal.addAllCards(library.getTopCards(game, 5));
|
||||
if (!cardsToReveal.isEmpty()) {
|
||||
player.revealCards(source, "Revealed cards for " + player.getName(), cardsToReveal, game);
|
||||
Cards cardsToPutOnBattlefield = new CardsImpl();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class DubiousChallengeEffect extends OneShotEffect {
|
|||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
Cards topCards = new CardsImpl();
|
||||
topCards.addAll(controller.getLibrary().getTopCards(game, 10));
|
||||
topCards.addAllCards(controller.getLibrary().getTopCards(game, 10));
|
||||
controller.lookAtCards(sourceObject.getIdName(), topCards, game);
|
||||
TargetCard targetCreatures = new TargetCard(0, 2, Zone.LIBRARY, StaticFilters.FILTER_CARD_CREATURE);
|
||||
controller.choose(outcome, topCards, targetCreatures, source, game);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class ElvishSoultillerEffect extends OneShotEffect {
|
|||
Cards cardsToLibrary = new CardsImpl();
|
||||
FilterCreatureCard filter = new FilterCreatureCard();
|
||||
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
|
||||
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
cardsToLibrary.addAllCards(controller.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class FrayingLineEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
Cards cards = new CardsImpl(source.getSourcePermanentIfItStillExists(game));
|
||||
cards.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game));
|
||||
cards.addAllCards(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game));
|
||||
player.moveCards(cards, Zone.EXILED, source, game);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_PERMANENT_CREATURE,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class GlimpseOfTomorrowEffect extends OneShotEffect {
|
|||
toBattlefield.clear();
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
|
||||
toBattlefield.addAll(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
|
||||
toBattlefield.addAllCards(cards.getCards(StaticFilters.FILTER_CARD_PERMANENT, game));
|
||||
toBattlefield.removeIf(uuid -> !game.getCard(uuid).hasSubtype(SubType.AURA, game));
|
||||
player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class GontiLordOfLuxuryEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Cards topCards = new CardsImpl();
|
||||
topCards.addAll(opponent.getLibrary().getTopCards(game, 4));
|
||||
topCards.addAllCards(opponent.getLibrary().getTopCards(game, 4));
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to exile"));
|
||||
controller.choose(outcome, topCards, target, source, game);
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class GrimoireThiefCounterspellEffect extends OneShotEffect {
|
|||
if (exileZones != null && sourceObject != null) {
|
||||
for (ExileZone exileZone : game.getExile().getExileZones()) {
|
||||
if (!exileZone.isEmpty()) {
|
||||
cards.addAll(exileZone.getCards(game));
|
||||
cards.addAllCards(exileZone.getCards(game));
|
||||
}
|
||||
}
|
||||
// set face up first
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class GuidedPassageEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, libSize));
|
||||
cards.addAllCards(controller.getLibrary().getTopCards(game, libSize));
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
|
||||
Player opponent;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class HedronAlignmentEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
Cards cardsToCheck = new CardsImpl();
|
||||
cardsToCheck.addAll(game.getExile().getAllCards(game));
|
||||
cardsToCheck.addAllCards(game.getExile().getAllCards(game));
|
||||
if (cardsToCheck.count(filterCard, controller.getId(), source, game) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class HonorTheFallenEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
cards.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
|
||||
cards.addAllCards(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
|
||||
}
|
||||
controller.moveCards(cards, Zone.EXILED, source, game);
|
||||
int count = cards
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class JalumGrifterEffect extends OneShotEffect {
|
|||
game.informPlayers(controller.getLogName() + " shuffles the face-down pile");
|
||||
TargetCard targetCard = new TargetCard(Zone.HAND, new FilterCard());
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(shellGamePile);
|
||||
cards.addAllCards(shellGamePile);
|
||||
if (opponent.choose(Outcome.Sacrifice, cards, targetCard, source, game)) {
|
||||
Card card = game.getCard(targetCard.getFirstTarget());
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ class ManifoldInsightsEffect extends OneShotEffect {
|
|||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
Cards topLib = new CardsImpl();
|
||||
topLib.addAll(controller.getLibrary().getTopCards(game, 10));
|
||||
topLib.addAllCards(controller.getLibrary().getTopCards(game, 10));
|
||||
controller.revealCards(sourceObject.getIdName(), topLib, game);
|
||||
Cards chosenCards = new CardsImpl();
|
||||
if (game.getOpponents(controller.getId()).size() >= topLib.getCards(StaticFilters.FILTER_CARD_NON_LAND, game).size()) {
|
||||
chosenCards.addAll(topLib.getCards(StaticFilters.FILTER_CARD_NON_LAND, game));
|
||||
chosenCards.addAllCards(topLib.getCards(StaticFilters.FILTER_CARD_NON_LAND, game));
|
||||
topLib.removeAll(chosenCards);
|
||||
} else if (!topLib.getCards(StaticFilters.FILTER_CARD_NON_LAND, game).isEmpty()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class MindblazeEffect extends OneShotEffect {
|
|||
game.informPlayers(sourceObject.getIdName() + " - Chosen number: [" + numberChoice.getChoice() + ']');
|
||||
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getCards(game));
|
||||
cards.addAllCards(player.getLibrary().getCards(game));
|
||||
playerControls.revealCards("Library", cards, game);
|
||||
FilterCard filter = new FilterCard();
|
||||
filter.add(new NamePredicate(cardName));
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class MineMineMineDrawEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
CardsImpl libraryCards = new CardsImpl();
|
||||
libraryCards.addAll(player.getLibrary().getCards(game));
|
||||
libraryCards.addAllCards(player.getLibrary().getCards(game));
|
||||
player.moveCards(libraryCards, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class MitoticManipulationEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
Cards cardsFromTop = new CardsImpl();
|
||||
cardsFromTop.addAll(controller.getLibrary().getTopCards(game, 7));
|
||||
cardsFromTop.addAllCards(controller.getLibrary().getTopCards(game, 7));
|
||||
controller.lookAtCards(sourceObject.getIdName(), cardsFromTop, game);
|
||||
FilterCard filter = new FilterCard("card to put onto the battlefield");
|
||||
List<NamePredicate> namePredicates = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class MnemonicBetrayalExileEffect extends OneShotEffect {
|
|||
.filter(Objects::nonNull)
|
||||
.map(Player::getGraveyard)
|
||||
.map(g -> g.getCards(game))
|
||||
.forEach(cards::addAll);
|
||||
.forEach(cards::addAllCards);
|
||||
controller.moveCardsToExile(
|
||||
cards.getCards(game), source, game, true,
|
||||
source.getSourceId(), CardUtil.getSourceName(game, source)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class MomirVigSimicVisionaryEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, 1));
|
||||
cards.addAllCards(controller.getLibrary().getTopCards(game, 1));
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
|
||||
Set<Card> cardsList = cards.getCards(game);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class MoonlightBargainEffect extends OneShotEffect {
|
|||
if (controller != null && sourceObject != null) {
|
||||
Set<Card> topFive = controller.getLibrary().getTopCards(game, 5);
|
||||
Cards lookAtCards = new CardsImpl();
|
||||
lookAtCards.addAll(topFive);
|
||||
lookAtCards.addAllCards(topFive);
|
||||
controller.lookAtCards(sourceObject.getIdName(), lookAtCards, game);
|
||||
Cards toHand = new CardsImpl();
|
||||
for (Card card : topFive) {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class NecromentiaEffect extends OneShotEffect {
|
|||
|
||||
// cards in Library
|
||||
Cards cardsInLibrary = new CardsImpl();
|
||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
||||
cardsInLibrary.addAllCards(targetPlayer.getLibrary().getCards(game));
|
||||
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
|
||||
if (cardsCount > 0) {
|
||||
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ class OblivionSowerEffect extends OneShotEffect {
|
|||
filter.add(new OwnerIdPredicate(targetPlayer.getId()));
|
||||
filter.add(Predicates.not(FaceDownPredicate.instance));
|
||||
Cards exiledCards = new CardsImpl();
|
||||
exiledCards.addAll(game.getExile().getAllCards(game));
|
||||
exiledCards.addAllCards(game.getExile().getAllCards(game));
|
||||
Cards exiledLands = new CardsImpl();
|
||||
exiledLands.addAll(exiledCards.getCards(filter, controller.getId(), source, game));
|
||||
exiledLands.addAllCards(exiledCards.getCards(filter, controller.getId(), source, game));
|
||||
if (!exiledLands.isEmpty() && controller.chooseUse(outcome, "Put lands into play?", source, game)) {
|
||||
FilterCard filterToPlay = new FilterCard("land"
|
||||
+ (exiledLands.size() > 1 ? "s" : "") + " from exile owned by "
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class OonaQueenOfTheFaeEffect extends OneShotEffect {
|
|||
}
|
||||
int cardsWithColor = 0;
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
|
||||
cardsToExile.addAllCards(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
|
||||
|
||||
for (Card card : cardsToExile.getCards(game)) {
|
||||
if (card != null && card.getColor(game).contains(choice.getColor())) {
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ class PhyrexianPortalEffect extends OneShotEffect {
|
|||
|
||||
game.informPlayers(controller.getLogName() + " chooses to search the " + (choice ? "first" : "second") + " pile");
|
||||
Cards pileToExile = new CardsImpl();
|
||||
pileToExile.addAll(choice ? pile2 : pile1);
|
||||
pileToExile.addAllCards(choice ? pile2 : pile1);
|
||||
controller.moveCardsToExile(pileToExile.getCards(game), source, game, true, null, "");
|
||||
Cards chosenPile = new CardsImpl();
|
||||
chosenPile.addAll(choice ? pile1 : pile2);
|
||||
chosenPile.addAllCards(choice ? pile1 : pile2);
|
||||
|
||||
TargetCard target2 = new TargetCard(Zone.HAND, new FilterCard("card to put into your hand"));
|
||||
if (controller.choose(outcome, chosenPile, target2, source, game)) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class PlanarBirthEffect extends OneShotEffect {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
toBattlefield.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_BASIC_LAND, controller.getId(), source, game));
|
||||
toBattlefield.addAllCards(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_BASIC_LAND, controller.getId(), source, game));
|
||||
}
|
||||
}
|
||||
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class RansackEffect extends OneShotEffect {
|
|||
int number = min(player.getLibrary().size(), 5);
|
||||
Set<Card> cards = player.getLibrary().getTopCards(game, number);
|
||||
Cards cardsRemaining = new CardsImpl();
|
||||
cardsRemaining.addAll(cards);
|
||||
cardsRemaining.addAllCards(cards);
|
||||
TargetCard target = new TargetCard(0, number, Zone.LIBRARY, filter);
|
||||
if (player.choose(Outcome.DrawCard, cardsRemaining, target, source, game)) {
|
||||
Cards pickedCards = new CardsImpl(target.getTargets());
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class SanityGrindingEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Cards revealed = new CardsImpl();
|
||||
revealed.addAll(controller.getLibrary().getTopCards(game, 10));
|
||||
revealed.addAllCards(controller.getLibrary().getTopCards(game, 10));
|
||||
controller.revealCards(sourceObject.getIdName(), revealed, game);
|
||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||
if (targetOpponent != null) {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class SiphonInsightEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Cards topCards = new CardsImpl();
|
||||
topCards.addAll(opponent.getLibrary().getTopCards(game, 2));
|
||||
topCards.addAllCards(opponent.getLibrary().getTopCards(game, 2));
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to exile"));
|
||||
controller.choose(outcome, topCards, target, source, game);
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class SphereOfAnnihilationEffect extends OneShotEffect {
|
|||
int counters = permanent.getCounters(game).getCount(CounterType.VOID);
|
||||
FilterPermanent filter = StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER.copy();
|
||||
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, counters + 1));
|
||||
cards.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game));
|
||||
cards.addAllCards(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game));
|
||||
game.getState()
|
||||
.getPlayersInRange(source.getControllerId(), game)
|
||||
.stream()
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class SwordPointDiplomacyEffect extends OneShotEffect {
|
|||
}
|
||||
int amount = Math.min(controller.getLibrary().size(), 3);
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, amount));
|
||||
cards.addAllCards(controller.getLibrary().getTopCards(game, amount));
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
Set<Card> cardsList = cards.getCards(game);
|
||||
Cards cardsToHand = new CardsImpl();
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class TheStoneBrainEffect extends OneShotEffect {
|
|||
// cards in Library
|
||||
if (numberOfCardsStillToRemove > 0) {
|
||||
Cards cardsInLibrary = new CardsImpl();
|
||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
||||
cardsInLibrary.addAllCards(targetPlayer.getLibrary().getCards(game));
|
||||
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
|
||||
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
|
||||
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, Math.min(cardsCount, numberOfCardsStillToRemove), filter);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class ThiefOfSanityEffect extends OneShotEffect {
|
|||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && damagedPlayer != null && sourceObject != null) {
|
||||
Cards topCards = new CardsImpl();
|
||||
topCards.addAll(damagedPlayer.getLibrary().getTopCards(game, 3));
|
||||
topCards.addAllCards(damagedPlayer.getLibrary().getTopCards(game, 3));
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to exile face down"));
|
||||
if (controller.choose(outcome, topCards, target, source, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class ThoughtDistortionEffect extends OneShotEffect {
|
|||
}
|
||||
player.revealCards(source, player.getHand(), game);
|
||||
Cards cards = new CardsImpl(player.getHand().getCards(filter, game));
|
||||
cards.addAll(player.getGraveyard().getCards(filter, game));
|
||||
cards.addAllCards(player.getGraveyard().getCards(filter, game));
|
||||
return player.moveCards(cards, Zone.EXILED, source, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ class TriumphOfSaintKatherineEffect extends OneShotEffect {
|
|||
if (card.getZoneChangeCounter(game) == source.getSourceObjectZoneChangeCounter()) {
|
||||
cards.add(card);
|
||||
}
|
||||
cards.addAll(player.getLibrary().getTopCards(game, 6));
|
||||
cards.addAllCards(player.getLibrary().getTopCards(game, 6));
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class UnmooredEgoEffect extends OneShotEffect {
|
|||
// cards in Library
|
||||
if (numberOfCardsStillToRemove > 0) {
|
||||
Cards cardsInLibrary = new CardsImpl();
|
||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
||||
cardsInLibrary.addAllCards(targetPlayer.getLibrary().getCards(game));
|
||||
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
|
||||
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
|
||||
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, Math.min(cardsCount, numberOfCardsStillToRemove), filter);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class WarpWorldEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getTopCards(game, permanentsCount.get(player.getId())));
|
||||
cards.addAllCards(player.getLibrary().getTopCards(game, permanentsCount.get(player.getId())));
|
||||
player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ')', cards, game);
|
||||
cardsRevealed.put(player.getId(), cards);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class XenagosExileEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Cards exiledCards = new CardsImpl();
|
||||
exiledCards.addAll(controller.getLibrary().getTopCards(game, 7));
|
||||
exiledCards.addAllCards(controller.getLibrary().getTopCards(game, 7));
|
||||
controller.moveCards(exiledCards, Zone.EXILED, source, game);
|
||||
FilterCard filter = new FilterCard("creature and/or land cards to put onto the battlefield");
|
||||
filter.add(Predicates.or(CardType.CREATURE.getPredicate(),
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class ExileFromGraveCost extends CostImpl {
|
|||
exiledCards.add(card);
|
||||
}
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
cardsToExile.addAll(exiledCards);
|
||||
cardsToExile.addAllCards(exiledCards);
|
||||
controller.moveCardsToExile(
|
||||
cardsToExile.getCards(game), source, game, true,
|
||||
CardUtil.getExileZoneId(game, source),
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class ExileFromHandCost extends CostImpl {
|
|||
this.cards.add(card);
|
||||
}
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
cardsToExile.addAll(cards);
|
||||
cardsToExile.addAllCards(cards);
|
||||
player.moveCards(cardsToExile, Zone.EXILED, ability, game);
|
||||
paid = true;
|
||||
if (setXFromCMC) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class ExileCardsFromTopOfLibraryTargetEffect extends OneShotEffect {
|
|||
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
cards.addAllCards(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
return targetPlayer.moveCards(cards, Zone.EXILED, source, game);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect {
|
|||
}
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
toExile.addAll(player.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
toExile.addAllCards(player.getGraveyard().getCards(filter, source.getControllerId(), source, game));
|
||||
}
|
||||
}
|
||||
controller.moveCards(toExile, Zone.EXILED, source, game);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source);
|
||||
if (player != null && targetPlayer != null && sourceObject != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
cards.addAllCards(targetPlayer.getLibrary().getTopCards(game, amount));
|
||||
player.lookAtCards(sourceObject.getIdName(), cards, game);
|
||||
if (putToGraveyard) {
|
||||
for (Card card : cards.getCards(game)) {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class RevealAndSeparatePilesEffect extends OneShotEffect {
|
|||
|
||||
game.informPlayers("Pile 1, going to " + pile1Zone + ": " + (pile1.isEmpty() ? " (none)" : pile1.stream().map(MageObject::getName).collect(Collectors.joining(", "))));
|
||||
cards.clear();
|
||||
cards.addAll(pile1);
|
||||
cards.addAllCards(pile1);
|
||||
if (pile1Zone == Zone.LIBRARY) {
|
||||
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
|
||||
} else {
|
||||
|
|
@ -137,7 +137,7 @@ public class RevealAndSeparatePilesEffect extends OneShotEffect {
|
|||
|
||||
game.informPlayers("Pile 2, going to " + pile2Zone + ": " + (pile2.isEmpty() ? " (none)" : pile2.stream().map(MageObject::getName).collect(Collectors.joining(", "))));
|
||||
cards.clear();
|
||||
cards.addAll(pile2);
|
||||
cards.addAllCards(pile2);
|
||||
if (pile2Zone == Zone.LIBRARY) {
|
||||
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(controller.getLibrary().getTopCards(game, amountCards.calculate(game, source, this)));
|
||||
cards.addAllCards(controller.getLibrary().getTopCards(game, amountCards.calculate(game, source, this)));
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
|
||||
Set<Card> cardsList = cards.getCards(game);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
|
|
@ -84,7 +83,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
|
|||
|
||||
// cards in Library
|
||||
Cards cardsInLibrary = new CardsImpl();
|
||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
||||
cardsInLibrary.addAllCards(targetPlayer.getLibrary().getCards(game));
|
||||
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
|
||||
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
|
||||
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class RippleEffect extends OneShotEffect {
|
|||
}
|
||||
// reveal top cards from library
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getTopCards(game, rippleNumber));
|
||||
cards.addAllCards(player.getLibrary().getTopCards(game, rippleNumber));
|
||||
player.revealCards(sourceObject.getIdName(), cards, game);
|
||||
|
||||
// determine which card should be rippled
|
||||
|
|
|
|||
|
|
@ -13,17 +13,32 @@ import java.util.UUID;
|
|||
|
||||
public interface Cards extends Set<UUID>, Serializable {
|
||||
|
||||
/**
|
||||
* Add the passed in card to the set if it's not null.
|
||||
*
|
||||
* @param card the card to add
|
||||
*/
|
||||
void add(Card card);
|
||||
|
||||
/**
|
||||
* Get the Card corresponding to the UUID passed IF it is in the set.
|
||||
* Returns null if the card is not in the set
|
||||
*
|
||||
* @param cardId UUID of the card to get
|
||||
* @param game the current game
|
||||
* @return The Card corresponding to the UUID, or null if that UUID is not in the set
|
||||
*/
|
||||
Card get(UUID cardId, Game game);
|
||||
|
||||
/**
|
||||
* Remove a specific card from the set in a safe manner.
|
||||
*
|
||||
* @param card the card to remove from this set
|
||||
* @return boolean indicating if removing the card was done successfully
|
||||
*/
|
||||
boolean remove(Card card);
|
||||
|
||||
void setOwner(UUID ownerId, Game game);
|
||||
|
||||
void addAll(List<? extends Card> createCards);
|
||||
|
||||
void addAll(Set<? extends Card> createCards);
|
||||
void addAllCards(Collection<? extends Card> createCards);
|
||||
|
||||
Set<Card> getCards(Game game);
|
||||
|
||||
|
|
@ -33,6 +48,12 @@ public interface Cards extends Set<UUID>, Serializable {
|
|||
|
||||
String getValue(Game game);
|
||||
|
||||
/**
|
||||
* Get a collection view of the unique non-null cards in this set.
|
||||
*
|
||||
* @param game The current game
|
||||
* @return Collection of unique non-null cards.
|
||||
*/
|
||||
Collection<Card> getUniqueCards(Game game);
|
||||
|
||||
Card getRandom(Game game);
|
||||
|
|
@ -45,7 +66,19 @@ public interface Cards extends Set<UUID>, Serializable {
|
|||
|
||||
Cards copy();
|
||||
|
||||
/**
|
||||
* Remove all cards except those in the provided zone.
|
||||
*
|
||||
* @param zone cards from this zone will be kept.
|
||||
* @param game the ongoing game.
|
||||
*/
|
||||
void retainZone(Zone zone, Game game);
|
||||
|
||||
/**
|
||||
* Remove all cards which are in the provided zone.
|
||||
*
|
||||
* @param zone cards from this zone will be removed.
|
||||
* @param game The ongoing game.
|
||||
*/
|
||||
void removeZone(Zone zone, Game game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
}
|
||||
|
||||
public CardsImpl(List<? extends Card> cards) {
|
||||
this.addAll(cards);
|
||||
this.addAllCards(cards);
|
||||
}
|
||||
|
||||
public CardsImpl(Set<? extends Card> cards) {
|
||||
this.addAll(cards);
|
||||
this.addAllCards(cards);
|
||||
}
|
||||
|
||||
public CardsImpl(Collection<UUID> cardIds) {
|
||||
|
|
@ -79,24 +79,20 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
return this.remove(card.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(UUID ownerId, Game game) {
|
||||
this.ownerId = ownerId;
|
||||
for (UUID card : this) {
|
||||
game.getCard(card).setOwnerId(ownerId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card getRandom(Game game) {
|
||||
if (this.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
MageObject object = game.getObject(RandomUtil.randomFromCollection(this)); // neccessary if permanent tokens are in the collection
|
||||
if (object instanceof Card) {
|
||||
return (Card) object;
|
||||
}
|
||||
return null;
|
||||
|
||||
// neccessary if permanent tokens are in the collection
|
||||
Set<MageObject> cardsForRandomPick = this
|
||||
.stream().map(uuid -> game.getObject(uuid))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(mageObject -> mageObject instanceof Card)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return (Card) RandomUtil.randomFromCollection(cardsForRandomPick);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -134,9 +130,14 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
return cards;
|
||||
}
|
||||
|
||||
// TODO: Why is this used a completely different implementation than the version without the filter?
|
||||
@Override
|
||||
public Set<Card> getCards(FilterCard filter, Game game) {
|
||||
return stream().map(game::getCard).filter(Objects::nonNull).filter(card -> filter.match(card, game)).collect(Collectors.toSet());
|
||||
return stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(card -> filter.match(card, game))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -176,17 +177,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
}
|
||||
|
||||
@Override
|
||||
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<? extends Card> cards) {
|
||||
public void addAllCards(Collection<? extends Card> cards) {
|
||||
if (cards != null) {
|
||||
cards.stream()
|
||||
.filter(Objects::nonNull)
|
||||
|
|
@ -197,13 +188,15 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
|
||||
@Override
|
||||
public Collection<Card> getUniqueCards(Game game) {
|
||||
Map<String, Card> cards = new HashMap<>();
|
||||
Map<String, Card> cards = new HashMap<>(this.size());
|
||||
|
||||
for (UUID cardId : this) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
cards.putIfAbsent(card.getName(), card);
|
||||
}
|
||||
}
|
||||
|
||||
return cards.values();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -477,8 +477,11 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
// if creature is goaded then we start with assumption that it needs to attack any player
|
||||
mustAttack = true;
|
||||
// Filter out the planeswalkers
|
||||
defendersForcedToAttack.addAll(defenders.stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getId).collect(Collectors.toSet()));
|
||||
// defendersForcedToAttack.addAll(defenders);
|
||||
defendersForcedToAttack.addAll(defenders.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::getId)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
if (!mustAttack) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class KayaTheInexorableEmblemEffect extends OneShotEffect {
|
|||
cards.addAll(player.getGraveyard());
|
||||
break;
|
||||
case "Exile":
|
||||
cards.addAll(game.getExile().getCards(filter, game));
|
||||
cards.addAllCards(game.getExile().getCards(filter, game));
|
||||
break;
|
||||
}
|
||||
return CardUtil.castSpellWithAttributesForFree(player, source, game, cards, filter2);
|
||||
|
|
|
|||
|
|
@ -5011,7 +5011,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
game.informPlayers(getLogName() + " scries " + event.getAmount() + CardUtil.getSourceLogName(game, source));
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(getLibrary().getTopCards(game, event.getAmount()));
|
||||
cards.addAllCards(getLibrary().getTopCards(game, event.getAmount()));
|
||||
if (!cards.isEmpty()) {
|
||||
TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY,
|
||||
new FilterCard("card" + (cards.size() == 1 ? "" : "s")
|
||||
|
|
@ -5039,7 +5039,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
game.informPlayers(getLogName() + " surveils " + event.getAmount() + CardUtil.getSourceLogName(game, source));
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(getLibrary().getTopCards(game, event.getAmount()));
|
||||
cards.addAllCards(getLibrary().getTopCards(game, event.getAmount()));
|
||||
if (!cards.isEmpty()) {
|
||||
TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY,
|
||||
new FilterCard("card " + (cards.size() == 1 ? "" : "s")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue