Search in sources :

Example 1 with AmountOfDamageAPlayerReceivedThisTurnWatcher

use of mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher in project mage by magefree.

the class NotoriousThrongEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class);
    if (controller != null && watcher != null) {
        int numTokens = 0;
        for (UUID opponentId : game.getOpponents(controller.getId())) {
            numTokens += watcher.getAmountOfDamageReceivedThisTurn(opponentId);
        }
        if (numTokens > 0) {
            new CreateTokenEffect(new FaerieRogueToken(), numTokens).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) AmountOfDamageAPlayerReceivedThisTurnWatcher(mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher) FaerieRogueToken(mage.game.permanent.token.FaerieRogueToken) UUID(java.util.UUID) ProwlCostWasPaidHint(mage.abilities.hint.common.ProwlCostWasPaidHint)

Example 2 with AmountOfDamageAPlayerReceivedThisTurnWatcher

use of mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher in project mage by magefree.

the class KnollspineDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller != null) {
        new DiscardHandControllerEffect().apply(game, source);
        if (targetOpponent != null) {
            AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class);
            if (watcher != null) {
                int drawAmount = watcher.getAmountOfDamageReceivedThisTurn(targetOpponent.getId());
                controller.drawCards(drawAmount, source, game);
                return true;
            }
        }
        game.informPlayers(controller.getLogName() + " drew no cards");
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) AmountOfDamageAPlayerReceivedThisTurnWatcher(mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher) DiscardHandControllerEffect(mage.abilities.effects.common.discard.DiscardHandControllerEffect)

Aggregations

Player (mage.players.Player)2 AmountOfDamageAPlayerReceivedThisTurnWatcher (mage.watchers.common.AmountOfDamageAPlayerReceivedThisTurnWatcher)2 UUID (java.util.UUID)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 DiscardHandControllerEffect (mage.abilities.effects.common.discard.DiscardHandControllerEffect)1 ProwlCostWasPaidHint (mage.abilities.hint.common.ProwlCostWasPaidHint)1 FaerieRogueToken (mage.game.permanent.token.FaerieRogueToken)1