use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class SpelljackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID targetId = targetPointer.getFirst(game, source);
StackObject stackObject = game.getStack().getStackObject(targetId);
if (stackObject != null && game.getStack().counter(targetId, source, game, Zone.EXILED, false, ZoneDetail.NONE)) {
Card card = ((Spell) stackObject).getCard();
if (card != null) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.Custom, true);
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class RobberOfTheRichEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (controller == null || damagedPlayer == null) {
return false;
}
Card card = damagedPlayer.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
// move card to exile
controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
// don't worry about land
if (card.getSpellAbility() != null) {
// the exiled card is independent and requires a new ability in case the Robber leaves the battlefield
// the exiled card can be cast throughout the entire game as long as the controller attacked with a rogue that turn
Ability copiedAbility = source.copy();
copiedAbility.newId();
copiedAbility.setSourceId(card.getId());
copiedAbility.setControllerId(source.getControllerId());
PlayFromNotOwnHandZoneTargetEffect playFromExile = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfGame);
YouMaySpendManaAsAnyColorToCastTargetEffect spendAnyMana = new YouMaySpendManaAsAnyColorToCastTargetEffect(Duration.EndOfGame);
ConditionalAsThoughEffect castOnlyIfARogueAttackedThisTurn = new ConditionalAsThoughEffect(playFromExile, new RogueAttackedThisTurnCondition(copiedAbility));
playFromExile.setTargetPointer(new FixedTarget(card, game));
spendAnyMana.setTargetPointer(new FixedTarget(card, game));
castOnlyIfARogueAttackedThisTurn.setTargetPointer(new FixedTarget(card, game));
game.addEffect(castOnlyIfARogueAttackedThisTurn, copiedAbility);
game.addEffect(spendAnyMana, copiedAbility);
return true;
}
return false;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class ExpressiveIterationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
if (cards.size() < 1) {
return false;
}
TargetCard target = new TargetCardInLibrary(cards.size() == 3 ? 1 : 0, 1, StaticFilters.FILTER_CARD);
target.withChooseHint("To put into your hand");
player.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
if (cards.isEmpty()) {
return true;
}
target = new TargetCardInLibrary(cards.size() == 2 ? 1 : 0, 1, StaticFilters.FILTER_CARD);
target.withChooseHint("To put on the bottom of your library");
player.choose(outcome, cards, target, game);
card = game.getCard(target.getFirstTarget());
if (card != null) {
player.putCardsOnBottomOfLibrary(card, game, source, false);
cards.remove(card);
}
if (cards.isEmpty()) {
return true;
}
target = new TargetCardInLibrary();
target.withChooseHint("To exile (you may play it this turn)");
player.choose(outcome, cards, target, game);
card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
player.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn).setTargetPointer(new FixedTarget(card, game)), source);
return true;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class MissionBriefingReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.surveil(2, source, game);
Target target = new TargetCardInYourGraveyard(new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard"));
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return true;
}
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect();
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
effect = new MissionBriefingReplacementEffect(card.getId());
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.
the class CodieVociferousCodexEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = (Spell) getValue("spellCast");
if (controller == null || spell == null) {
return false;
}
Cards toExile = new CardsImpl();
Card toCast = null;
for (Card card : controller.getLibrary().getCards(game)) {
toExile.add(card);
if (card.isInstantOrSorcery(game) && card.getManaValue() < spell.getManaValue()) {
toCast = card;
break;
}
}
if (toCast == null) {
controller.moveCards(toExile, Zone.EXILED, source, game);
controller.putCardsOnBottomOfLibrary(toExile, game, source, false);
return true;
}
controller.moveCards(toCast, Zone.EXILED, source, game);
PlayFromNotOwnHandZoneTargetEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(toCast.getId(), game));
game.addEffect(effect, source);
toExile.remove(toCast);
controller.putCardsOnBottomOfLibrary(toExile, game, source, false);
return true;
}
Aggregations