Search in sources :

Example 1 with RemoveAllCountersSourceCost

use of mage.abilities.costs.common.RemoveAllCountersSourceCost in project mage by magefree.

the class SageOfHoursEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        int countersRemoved = 0;
        for (Cost cost : source.getCosts()) {
            if (cost instanceof RemoveAllCountersSourceCost) {
                countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters();
            }
        }
        int turns = countersRemoved / 5;
        for (int i = 0; i < turns; i++) {
            game.getState().getTurnMods().add(new TurnMod(player.getId(), false));
        }
        game.informPlayers("Removed " + countersRemoved + " +1/+1 counters: " + player.getLogName() + " takes " + CardUtil.numberToText(turns, "an") + (turns > 1 ? " extra turns " : " extra turn ") + "after this one");
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) TurnMod(mage.game.turn.TurnMod) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) Cost(mage.abilities.costs.Cost)

Example 2 with RemoveAllCountersSourceCost

use of mage.abilities.costs.common.RemoveAllCountersSourceCost in project mage by magefree.

the class TortureChamberEffect2 method apply.

@Override
public boolean apply(Game game, Ability source) {
    int countersRemoved = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof RemoveAllCountersSourceCost) {
            countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters();
        }
    }
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        permanent.damage(countersRemoved, source.getSourceId(), source, game, false, true);
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost)

Example 3 with RemoveAllCountersSourceCost

use of mage.abilities.costs.common.RemoveAllCountersSourceCost in project mage by magefree.

the class EssenceBottleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int countersRemoved = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof RemoveAllCountersSourceCost) {
            countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters();
        }
    }
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        player.gainLife(countersRemoved * 2, game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost)

Example 4 with RemoveAllCountersSourceCost

use of mage.abilities.costs.common.RemoveAllCountersSourceCost in project mage by magefree.

the class JarOfEyeballsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int countersRemoved = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof RemoveAllCountersSourceCost) {
            countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters();
        }
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, countersRemoved));
    controller.lookAtCards(source, null, cards, game);
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
    if (controller.choose(Outcome.DrawCard, cards, target, game)) {
        Cards targetCards = new CardsImpl(target.getTargets());
        controller.moveCards(targetCards, Zone.HAND, source, game);
        cards.removeAll(targetCards);
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) TargetCard(mage.target.TargetCard) RemoveAllCountersSourceCost(mage.abilities.costs.common.RemoveAllCountersSourceCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

Cost (mage.abilities.costs.Cost)4 RemoveAllCountersSourceCost (mage.abilities.costs.common.RemoveAllCountersSourceCost)4 TapSourceCost (mage.abilities.costs.common.TapSourceCost)3 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)3 Player (mage.players.Player)3 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 FilterCard (mage.filter.FilterCard)1 Permanent (mage.game.permanent.Permanent)1 TurnMod (mage.game.turn.TurnMod)1 TargetCard (mage.target.TargetCard)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1