use of mage.abilities.effects.Effect in project mage by magefree.
the class CharmingPrinceEffect 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) {
return false;
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
if (!controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.BATTLEFIELD, true)) {
return false;
}
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
effect.setText("Return it to the battlefield under your control at the beginning of the next end step");
effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class DiffusionSliverTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
return false;
}
Permanent creature = game.getPermanent(event.getTargetId());
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
return false;
}
this.getEffects().clear();
Effect effect = new CounterUnlessPaysEffect(new GenericManaCost(2));
effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
this.addEffect(effect);
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class DinOfTheFireherdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean applied;
Token token = new DinOfTheFireherdToken();
applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect2.apply(game, source);
applied = true;
}
return applied;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class GlimmerpointStagEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int zcc = permanent.getZoneChangeCounter(game);
controller.moveCards(permanent, Zone.EXILED, source, game);
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
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 HauntingWindTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent == null || !permanent.isArtifact(game)) {
return false;
}
StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
if (stackAbility == null) {
return false;
}
String abilityText = stackAbility.getRule(true);
if (abilityText.contains("{T}:") || abilityText.contains("{T},") || abilityText.contains("{T} or")) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
}
return true;
}
if (event.getType() == GameEvent.EventType.TAPPED) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null || !permanent.isArtifact(game)) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
}
return true;
}
return false;
}
Aggregations