Search in sources :

Example 1 with AddCountersSourceEffect

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

the class DelayingShieldUpkeepEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    new AddCountersSourceEffect(CounterType.DELAY.createInstance(damageEvent.getAmount()), true).apply(game, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) DamageEvent(mage.game.events.DamageEvent)

Example 2 with AddCountersSourceEffect

use of mage.abilities.effects.common.counter.AddCountersSourceEffect 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 AddCountersSourceEffect

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

the class RescuerSphinxEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (!player.chooseUse(outcome, "Return a nonland permanent you control to your hand?", source, game)) {
        return false;
    }
    Target target = new TargetPermanent(0, 1, filter, true);
    if (!player.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null || !player.moveCards(permanent, Zone.HAND, source, game)) {
        return false;
    }
    return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent)

Example 4 with AddCountersSourceEffect

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

the class BingoCount method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        if (spell.getManaValue() > 9) {
            return true;
        }
        MageObject mageObject = game.getObject(source.getSourceId());
        if (mageObject != null) {
            // Map<number, amount of counters>
            Map<Integer, Integer> chipCounters = new HashMap<>();
            if (game.getState().getValue(mageObject.getId() + "_chip") != null) {
                chipCounters.putAll((Map<Integer, Integer>) game.getState().getValue(mageObject.getId() + "_chip"));
            }
            chipCounters.putIfAbsent(spell.getManaValue(), 0);
            chipCounters.put(spell.getManaValue(), chipCounters.get(spell.getManaValue()) + 1);
            game.getState().setValue(mageObject.getId() + "_chip", chipCounters);
            if (mageObject instanceof Permanent) {
                StringBuilder sb = new StringBuilder();
                int i = 0;
                for (Map.Entry<Integer, Integer> entry : chipCounters.entrySet()) {
                    i++;
                    sb.append(entry.getKey());
                    if (i < chipCounters.size()) {
                        sb.append(", ");
                    }
                }
                ((Permanent) mageObject).addInfo("chip counters", CardUtil.addToolTipMarkTags("Chip counters at: " + sb), game);
                new AddCountersSourceEffect(CounterType.CHIP.createInstance()).apply(game, source);
            }
            return true;
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Permanent(mage.game.permanent.Permanent) HashMap(java.util.HashMap) MageObject(mage.MageObject) HashMap(java.util.HashMap) Map(java.util.Map) Spell(mage.game.stack.Spell) FilterSpell(mage.filter.FilterSpell)

Example 5 with AddCountersSourceEffect

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

the class ForceBubbleStateTriggeredAbility method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    new AddCountersSourceEffect(CounterType.DEPLETION.createInstance(damageEvent.getAmount()), true).apply(game, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) DamageEvent(mage.game.events.DamageEvent)

Aggregations

AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)40 Player (mage.players.Player)21 Permanent (mage.game.permanent.Permanent)20 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)5 Cost (mage.abilities.costs.Cost)5 UUID (java.util.UUID)4 RemoveCounterSourceEffect (mage.abilities.effects.common.counter.RemoveCounterSourceEffect)4 Card (mage.cards.Card)4 ZoneChangeGroupEvent (mage.game.events.ZoneChangeGroupEvent)4 Target (mage.target.Target)4 TargetPermanent (mage.target.TargetPermanent)3 MageInt (mage.MageInt)2 Ability (mage.abilities.Ability)2 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)2 ManaCosts (mage.abilities.costs.mana.ManaCosts)2 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2 FlyingAbility (mage.abilities.keyword.FlyingAbility)2 CardImpl (mage.cards.CardImpl)2