Search in sources :

Example 1 with RemoveCounterSourceEffect

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

the class GlyphOfDelusionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (source.getTargets().get(1) != null) {
        Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
        if (targetPermanent != null) {
            targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
            SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(), new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));
            GainAbilityTargetEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
            effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
            game.addEffect(effect, source);
            BeginningOfUpkeepTriggeredAbility ability2 = new BeginningOfUpkeepTriggeredAbility(new RemoveCounterSourceEffect(CounterType.GLYPH.createInstance()), TargetController.YOU, false);
            GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(ability2, Duration.Custom);
            effect2.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
            game.addEffect(effect2, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DontUntapInControllersUntapStepSourceEffect(mage.abilities.effects.common.DontUntapInControllersUntapStepSourceEffect) SourceHasCounterCondition(mage.abilities.condition.common.SourceHasCounterCondition) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 2 with RemoveCounterSourceEffect

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

the class GoblinBombEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            game.informPlayers("Goblin Bomb: Won flip. Put a fuse counter on Goblin Bomb.");
            new AddCountersSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
            return true;
        } else {
            game.informPlayers("Goblin Bomb: Lost flip. Remove a fuse counter from Goblin Bomb.");
            new RemoveCounterSourceEffect(CounterType.FUSE.createInstance(1)).apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 3 with RemoveCounterSourceEffect

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

the class DarigaazReincarnatedReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (sourceObject instanceof Card) {
        Card card = (Card) sourceObject;
        new RemoveCounterSourceEffect(CounterType.EGG.createInstance()).apply(game, source);
        if (card.getCounters(game).getCount(CounterType.EGG) == 0) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect) Card(mage.cards.Card)

Example 4 with RemoveCounterSourceEffect

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

the class JinxedChokerCounterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        if (!sourcePermanent.getCounters(game).containsKey(CounterType.CHARGE) || controller.chooseUse(outcome, "Put a charge counter on? (No removes one)", source, game)) {
            return new AddCountersSourceEffect(CounterType.CHARGE.createInstance(), true).apply(game, source);
        } else {
            return new RemoveCounterSourceEffect(CounterType.CHARGE.createInstance()).apply(game, source);
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 5 with RemoveCounterSourceEffect

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

the class ClockworkCondorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent p = game.getPermanent(source.getSourceId());
    if (p != null) {
        AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance()));
        game.addDelayedTriggeredAbility(ability, source);
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Aggregations

RemoveCounterSourceEffect (mage.abilities.effects.common.counter.RemoveCounterSourceEffect)10 Permanent (mage.game.permanent.Permanent)9 Player (mage.players.Player)5 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)4 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)4 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 ConditionalContinuousRuleModifyingEffect (mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect)2 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 Condition (mage.abilities.condition.Condition)1 SourceHasCounterCondition (mage.abilities.condition.common.SourceHasCounterCondition)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 ContinuousRuleModifyingEffect (mage.abilities.effects.ContinuousRuleModifyingEffect)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1