Search in sources :

Example 1 with DamagePlayersEffect

use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.

the class RadiantEpicureEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class);
    if (player == null || watcher == null) {
        return false;
    }
    Mana payment = watcher.getLastManaPayment(source.getSourceId());
    if (payment == null) {
        return false;
    }
    int xValue = payment.getDifferentColors();
    new DamagePlayersEffect(xValue, TargetController.OPPONENT).apply(game, source);
    player.gainLife(xValue, game, source);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ManaSpentToCastWatcher(mage.watchers.common.ManaSpentToCastWatcher) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect)

Example 2 with DamagePlayersEffect

use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.

the class CulminationOfStudiesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
    player.moveCards(cards, Zone.EXILED, source, game);
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
    int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game);
    int blueCards = cards.count(filterBlue, game);
    int redCards = cards.count(filterRed, game);
    if (landCards > 0) {
        new TreasureToken().putOntoBattlefield(landCards, game, source, source.getControllerId());
    }
    if (blueCards > 0) {
        player.drawCards(blueCards, source, game);
    }
    if (redCards > 0) {
        new DamagePlayersEffect(redCards, TargetController.OPPONENT).apply(game, source);
    }
    return true;
}
Also used : Player(mage.players.Player) TreasureToken(mage.game.permanent.token.TreasureToken) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 3 with DamagePlayersEffect

use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.

the class ChandraTorchOfDefianceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) {
        Library library = controller.getLibrary();
        Card card = library.getFromTop(game);
        if (card != null) {
            boolean cardWasCast = false;
            controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
            if (!card.getManaCost().isEmpty() || !card.isLand(game)) {
                if (controller.chooseUse(Outcome.Benefit, "Cast " + card.getName() + "? (You still pay the costs)", source, game) && (game.getState().getZone(card.getId()) == Zone.EXILED)) {
                    // card must be in the exile zone
                    // enable the card to be cast from the exile zone
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                    cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, false), game, false, new ApprovingObject(source, game));
                    // reset to null
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                }
            }
            if (!cardWasCast) {
                new DamagePlayersEffect(Outcome.Damage, StaticValue.get(2), TargetController.OPPONENT).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) MageObject(mage.MageObject) Library(mage.players.Library) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect) Card(mage.cards.Card)

Example 4 with DamagePlayersEffect

use of mage.abilities.effects.common.DamagePlayersEffect in project mage by magefree.

the class FieryGambitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        int flipsWon = 0;
        boolean controllerStopped = false;
        while (controller.flipCoin(source, game, true)) {
            ++flipsWon;
            if (!controller.chooseUse(outcome, "You won " + flipsWon + (flipsWon == 1 ? " flip." : " flips.") + " Flip another coin?", source, game)) {
                controllerStopped = true;
                break;
            }
            // AI workaround to stop flips on good result
            if (controller.isComputer() && flipsWon >= 3) {
                controllerStopped = true;
                break;
            }
        }
        if (controllerStopped) {
            Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
            if (creature != null) {
                creature.damage(3, source.getSourceId(), source, game, false, true);
            }
            if (flipsWon > 1) {
                new DamagePlayersEffect(6, TargetController.OPPONENT).apply(game, source);
            }
            if (flipsWon > 2) {
                controller.drawCards(9, source, game);
                new UntapAllLandsControllerEffect().apply(game, source);
            }
        } else {
            game.informPlayers(sourceObject.getIdName() + " had no effect");
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) UntapAllLandsControllerEffect(mage.abilities.effects.common.UntapAllLandsControllerEffect) MageObject(mage.MageObject) DamagePlayersEffect(mage.abilities.effects.common.DamagePlayersEffect)

Aggregations

DamagePlayersEffect (mage.abilities.effects.common.DamagePlayersEffect)4 Player (mage.players.Player)4 MageObject (mage.MageObject)2 ApprovingObject (mage.ApprovingObject)1 Mana (mage.Mana)1 UntapAllLandsControllerEffect (mage.abilities.effects.common.UntapAllLandsControllerEffect)1 Card (mage.cards.Card)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 Permanent (mage.game.permanent.Permanent)1 TreasureToken (mage.game.permanent.token.TreasureToken)1 Library (mage.players.Library)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 ManaSpentToCastWatcher (mage.watchers.common.ManaSpentToCastWatcher)1