use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DiluvianPrimordialReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Target target : source.getTargets()) {
if (target instanceof TargetCardInOpponentsGraveyard) {
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Cast " + targetCard.getLogName() + '?', source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(targetCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), null);
if (cardWasCast) {
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId())));
game.addEffect(effect, source);
}
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class DireFleetDaredevilReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
if (targetCard != null) {
if (controller.moveCards(targetCard, Zone.EXILED, source, game)) {
targetCard = game.getCard(targetCard.getId());
if (targetCard != null) {
// you may play and spend any mana
CardUtil.makeCardPlayable(game, source, targetCard, Duration.EndOfTurn, true);
// exile from graveyard
ContinuousEffect effect = new DireFleetDaredevilReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard, game));
game.addEffect(effect, source);
return true;
}
}
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class ElkinLairPutIntoGraveyardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (player != null && sourcePermanent != null) {
Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]);
if (cards.length > 0) {
Card card = cards[RandomUtil.nextInt(cards.length)];
if (card != null) {
String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
player.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
if (game.getState().getZone(card.getId()) == Zone.EXILED) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
game.addDelayedTriggeredAbility(delayed, source);
return true;
}
}
}
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class ElkinBottleCastFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
ContinuousEffect effect = new ElkinBottleCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.ContinuousEffect in project mage by magefree.
the class EmberwildeDjinnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
if (cost.pay(source, game, source, player.getId(), false)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
game.addEffect(effect, source);
player.resetStoredBookmark(game);
}
}
return true;
}
Aggregations