Search in sources :

Example 26 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class CardUtil method moveCardWithCounter.

/**
 * Move card or permanent to dest zone and add counter to it
 *
 * @param game
 * @param source
 * @param controller
 * @param card       can be card or permanent
 * @param toZone
 * @param counter
 */
public static boolean moveCardWithCounter(Game game, Ability source, Player controller, Card card, Zone toZone, Counter counter) {
    if (toZone == Zone.BATTLEFIELD) {
        throw new IllegalArgumentException("Wrong code usage - method doesn't support moving to battlefield zone");
    }
    // move to zone
    if (!controller.moveCards(card, toZone, source, game)) {
        return false;
    }
    // add counter
    // after move it's a new object (not a permanent), so must work with main card
    Effect effect = new AddCountersTargetEffect(counter);
    effect.setTargetPointer(new FixedTarget(card.getMainCard(), game));
    effect.apply(game, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Effect(mage.abilities.effects.Effect) CanPlayCardControllerEffect(mage.abilities.effects.common.asthought.CanPlayCardControllerEffect) YouMaySpendManaAsAnyColorToCastTargetEffect(mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 27 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class FinalityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Target target = new TargetControlledCreaturePermanent(0, 1);
    target.setNotTarget(true);
    if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
        Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    game.addEffect(new BoostAllEffect(-4, -4, Duration.EndOfTurn), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) Effect(mage.abilities.effects.Effect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 28 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class FormlessNurturingEffect 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) {
            new ManifestEffect(1).apply(game, source);
            Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
            effect.setTargetPointer(new FixedTarget(card.getId()));
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ManifestEffect(mage.abilities.effects.keyword.ManifestEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ManifestEffect(mage.abilities.effects.keyword.ManifestEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Card(mage.cards.Card)

Example 29 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class GiantOysterLeaveUntapDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent oyster = game.getPermanent(source.getSourceId());
        Permanent tappedCreature = game.getPermanent(source.getFirstTarget());
        if (oyster != null && tappedCreature != null) {
            Effect addCountersEffect = new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
            addCountersEffect.setTargetPointer(getTargetPointer().getFixedTarget(game, source));
            DelayedTriggeredAbility drawStepAbility = new AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(addCountersEffect, Duration.Custom, false);
            drawStepAbility.setControllerId(source.getControllerId());
            UUID drawStepAbilityUUID = game.addDelayedTriggeredAbility(drawStepAbility, source);
            DelayedTriggeredAbility leaveUntapDelayedTriggeredAbility = new GiantOysterLeaveUntapDelayedTriggeredAbility(drawStepAbilityUUID);
            leaveUntapDelayedTriggeredAbility.getEffects().get(0).setTargetPointer(new FixedTarget(tappedCreature, game));
            game.addDelayedTriggeredAbility(leaveUntapDelayedTriggeredAbility, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) RemoveDelayedTriggeredAbilityEffect(mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DontUntapAsLongAsSourceTappedEffect(mage.abilities.effects.common.DontUntapAsLongAsSourceTappedEffect) AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextDrawStepDelayedTriggeredAbility) UUID(java.util.UUID) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 30 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class NecropolisRegentTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedPlayerEvent) event).isCombatDamage()) {
        Permanent creature = game.getPermanent(event.getSourceId());
        if (creature != null && creature.isControlledBy(controllerId)) {
            this.getEffects().clear();
            Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(event.getAmount()));
            effect.setTargetPointer(new FixedTarget(creature.getId(), game));
            this.addEffect(effect);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Aggregations

AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)36 FixedTarget (mage.target.targetpointer.FixedTarget)27 Permanent (mage.game.permanent.Permanent)24 Effect (mage.abilities.effects.Effect)21 OneShotEffect (mage.abilities.effects.OneShotEffect)18 Player (mage.players.Player)18 Card (mage.cards.Card)7 UUID (java.util.UUID)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 Target (mage.target.Target)5 TargetPermanent (mage.target.TargetPermanent)5 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)4 Ability (mage.abilities.Ability)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)3