use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class YannikScavengingSentinelEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (player == null || sourcePermanent == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
return false;
}
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
int power = permanent.getPower().getValue();
new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);
game.addDelayedTriggeredAbility(new OnLeaveReturnExiledToBattlefieldAbility(), source);
if (game.getState().getZone(permanent.getId()) != Zone.BATTLEFIELD) {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, power, false, ""), false, "distribute X +1/+1 counters among any number of target creatures, " + "where X is the exiled creature's power");
ability.addTarget(new TargetCreaturePermanentAmount(power));
game.fireReflexiveTriggeredAbility(ability, source);
}
return true;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class FlamerushRiderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (controller != null && permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true);
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
for (Permanent addedToken : effect.getAddedPermanents()) {
Effect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), false).apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class FlameshadowConjuringEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true);
effect.setTargetPointer(getTargetPointer());
if (effect.apply(game, source)) {
for (Permanent tokenPermanent : effect.getAddedPermanents()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
}
return false;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class GoryosVengeanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
// Haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
// Exile it at end of turn
Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step");
exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.effects.common.ExileTargetEffect in project mage by magefree.
the class InallaArchmageRitualistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent != null) {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true);
effect.setTargetPointer(getTargetPointer());
if (effect.apply(game, source)) {
for (Permanent tokenPermanent : effect.getAddedPermanents()) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
}
return false;
}
Aggregations