use of mage.abilities.effects.Effect in project mage by magefree.
the class AwakenElementalToken method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID targetId = null;
for (Target target : source.getTargets()) {
targetId = target.getFirstTarget();
}
if (targetId != null) {
FixedTarget fixedTarget = new FixedTarget(targetId, game);
ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.EndOfGame);
continuousEffect.setTargetPointer(fixedTarget);
game.addEffect(continuousEffect, source);
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(3));
effect.setTargetPointer(fixedTarget);
return effect.apply(game, source);
}
return true;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class NullstoneGargoyleTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getSpell(event.getTargetId());
if (spell.isCreature(game)) {
return false;
}
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
if (watcher != null && watcher.getNumberOfNonCreatureSpells() == 1) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class NoosegrafMobEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
permanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
Effect effect = new CreateTokenEffect(new ZombieToken());
return effect.apply(game, source);
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class PsychicPurgeTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (getSourceId().equals(event.getTargetId())) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject != null) {
if (game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId())) {
Effect effect = this.getEffects().get(0);
effect.setTargetPointer(new FixedTarget(stackObject.getControllerId()));
return true;
}
}
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class RescueFromTheUnderworldReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = ability.copy();
delayedAbility.getTargets().addAll(source.getTargets());
for (Effect effect : delayedAbility.getEffects()) {
effect.getTargetPointer().init(game, source);
}
// add the sacrificed creature as target
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
TargetCardInGraveyard target = new TargetCardInGraveyard();
for (Permanent permanent : sacCost.getPermanents()) {
target.add(permanent.getId(), game);
delayedAbility.getTargets().add(target);
}
}
}
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
Aggregations