use of mage.cards.CardsImpl in project mage by magefree.
the class MundaAmbushLeaderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards allCards = new CardsImpl();
allCards.addAll(controller.getLibrary().getTopCards(game, 4));
controller.lookAtCards(sourceObject.getIdName(), allCards, game);
if (!allCards.isEmpty()) {
Cards cardsToReveal = new CardsImpl();
TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
controller.chooseTarget(outcome, allCards, target, source, game);
cardsToReveal.addAll(target.getTargets());
if (!cardsToReveal.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game, true);
allCards.removeAll(cardsToReveal);
}
controller.putCardsOnTopOfLibrary(cardsToReveal, game, source, true);
}
if (!allCards.isEmpty()) {
controller.putCardsOnBottomOfLibrary(allCards, game, source, true);
}
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class NyleaKeenEyedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
player.revealCards(source, new CardsImpl(card), game);
if (card.isCreature(game)) {
return player.moveCards(card, Zone.HAND, source, game);
}
if (!player.chooseUse(Outcome.Detriment, "Put " + card.getName() + " into your graveyard?", source, game)) {
return true;
}
return player.moveCards(card, Zone.GRAVEYARD, source, game);
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ParadoxicalOutcomeNumber method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(source.getTargets().get(0).getTargets());
game.getState().setValue(CardUtil.getCardZoneString("ParadoxicalOutcomeEffect", source.getSourceId(), game), cards.size());
controller.moveCards(new CardsImpl(source.getTargets().get(0).getTargets()), Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ParoxysmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(source.getSourceId());
if (aura != null) {
Permanent creatureAttachedTo = game.getPermanent(aura.getAttachedTo());
if (creatureAttachedTo != null) {
Player controllerOfCreature = game.getPlayer(creatureAttachedTo.getControllerId());
if (controllerOfCreature != null) {
Card revealCardFromTop = controllerOfCreature.getLibrary().getFromTop(game);
if (revealCardFromTop != null) {
Cards cards = new CardsImpl(revealCardFromTop);
controllerOfCreature.revealCards(source, cards, game);
if (revealCardFromTop.isLand(game)) {
creatureAttachedTo.destroy(source, game, false);
} else {
ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId(), game));
game.addEffect(effect, source);
}
return true;
}
}
}
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class PatronOfTheMoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped"));
controller.chooseTarget(outcome, controller.getHand(), target, source, game);
return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return false;
}
Aggregations