use of mage.abilities.effects.Effect in project mage by magefree.
the class BerserkDelayedDestroyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// create delayed triggered ability
Effect effect = new BerserkDelayedDestroyEffect();
effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source), game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class BroodOfCockroachesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
game.addDelayedTriggeredAbility(delayedLifeLost, source);
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return {this} to your hand.");
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class DermoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent thisCreature = game.getPermanent(source.getId());
FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
filter.add(new AbilityPredicate(MorphAbility.class));
Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
if (effect.apply(game, source)) {
if (thisCreature != null) {
effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class ExplosionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX();
Effect effect = new DamageTargetEffect(StaticValue.get(xValue), true, "", true);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (player != null) {
player.drawCards(xValue, source, game);
}
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class GalepowderMageEffect 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) {
if (getTargetPointer().getFirst(game, source) != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
UUID exileId = UUID.randomUUID();
if (controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
}
return true;
}
return false;
}
Aggregations