use of mage.cards.CardsImpl in project mage by magefree.
the class SchemingSymmetryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
source.getTargets().get(0).getTargets().stream().map(playerId -> game.getPlayer(playerId)).filter(player -> player != null).forEach(player -> {
TargetCardInLibrary targetCard = new TargetCardInLibrary();
if (player.searchLibrary(targetCard, source, game)) {
Cards cards = new CardsImpl();
cards.add(targetCard.getFirstTarget());
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(cards, game, source, false);
}
});
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ScapeshiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int amount = 0;
TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
for (UUID uuid : sacrificeLand.getTargets()) {
Permanent land = game.getPermanent(uuid);
if (land != null) {
land.sacrifice(source, game);
amount++;
}
}
}
TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
if (controller.searchLibrary(target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ScalpelexisEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer == null) {
return false;
}
Set<String> cardNames = new HashSet<>();
boolean doubleName;
do {
doubleName = false;
Cards toExile = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 4));
cardNames.clear();
for (Card card : toExile.getCards(game)) {
if (cardNames.contains(card.getName())) {
doubleName = true;
break;
} else {
cardNames.add(card.getName());
}
}
targetPlayer.moveCards(toExile, Zone.EXILED, source, game);
} while (doubleName);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ShrineOfPiercingVisionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (player == null || permanent == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, permanent.getCounters(game).getCount(CounterType.CHARGE)));
if (!cards.isEmpty()) {
player.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
player.moveCards(card, Zone.HAND, source, game);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class SzatsWillEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(game.getOpponents(source.getControllerId()).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).flatMap(Collection::stream).collect(Collectors.toSet()));
player.moveCards(cards, Zone.EXILED, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
int maxPower = cards.getCards(game).stream().filter(Objects::nonNull).filter(card -> card.isCreature(game)).map(MageObject::getPower).mapToInt(MageInt::getValue).max().orElse(0);
if (maxPower > 0) {
new BreedingPitThrullToken().putOntoBattlefield(maxPower, game, source, source.getControllerId());
}
return true;
}
Aggregations