use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class NicolBolasGodPharaohPlusTwoEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (opponent == null) {
return false;
}
Library library = opponent.getLibrary();
Card card;
do {
card = library.getFromTop(game);
if (card == null) {
continue;
}
opponent.moveCards(card, Zone.EXILED, source, game);
if (card.isLand(game)) {
continue;
}
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
break;
} while (library.hasCards() && card != null);
return true;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class ExileTopXMayPlayUntilEndOfTurnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
if (cards.isEmpty()) {
return true;
}
controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
// remove cards that could not be moved to exile
cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
if (!cards.isEmpty()) {
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration).setTargetPointer(new FixedTargets(cards, game)), source);
}
return true;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class ApexOfPowerManaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
Set<Card> cards = controller.getLibrary().getTopCards(game, 7);
if (cards.isEmpty()) {
return false;
}
controller.moveCards(cards, Zone.EXILED, source, game);
for (Card card : cards) {
if (card.isLand(game)) {
continue;
}
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class ChandraHeartOfFireUltimateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> exiledCards = new HashSet<>();
// from graveyard
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true).withChooseHint("from graveyard");
if (target.canChoose(source.getSourceId(), controller.getId(), game) && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) {
Set<Card> cards = new CardsImpl(target.getTargets()).getCards(game);
exiledCards.addAll(cards);
}
// from library
target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter).withChooseHint("from library");
if (target.canChoose(source.getSourceId(), controller.getId(), game) && target.choose(Outcome.AIDontUseIt, controller.getId(), source.getSourceId(), game)) {
Set<Card> cards = new CardsImpl(target.getTargets()).getCards(game);
exiledCards.addAll(cards);
}
// exile cards all at once and set the exile name to the source card
controller.moveCardsToExile(exiledCards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
controller.shuffleLibrary(source, game);
exiledCards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
if (!exiledCards.isEmpty()) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTargets(exiledCards, game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class SinsOfThePastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
if (card != null) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.YOU, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
effect = new ExileCardEnteringGraveyardReplacementEffect(card.getId());
game.addEffect(effect, source);
return true;
}
return false;
}
Aggregations