Search in sources :

Example 1 with PlayerGainedLifeWatcher

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

the class TivashGloomSummonerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
    if (player == null || watcher == null) {
        return false;
    }
    int lifeGained = watcher.getLifeGained(source.getControllerId());
    Cost cost = new PayLifeCost(lifeGained);
    if (!cost.canPay(source, source, source.getControllerId(), game) || !player.chooseUse(Outcome.PutCreatureInPlay, "Pay " + lifeGained + " life?", source, game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    new DemonFlyingToken(lifeGained).putOntoBattlefield(1, game, source, source.getControllerId());
    return true;
}
Also used : Player(mage.players.Player) PlayerGainedLifeWatcher(mage.watchers.common.PlayerGainedLifeWatcher) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) DemonFlyingToken(mage.game.permanent.token.DemonFlyingToken)

Example 2 with PlayerGainedLifeWatcher

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

the class OathswornVampirePlayEffect method applies.

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
    PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
    if (watcher == null || watcher.getLifeGained(source.getControllerId()) < 1 || !sourceId.equals(source.getSourceId()) || !source.isControlledBy(affectedControllerId)) {
        return false;
    }
    Card card = game.getCard(source.getSourceId());
    return card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD;
}
Also used : PlayerGainedLifeWatcher(mage.watchers.common.PlayerGainedLifeWatcher) Card(mage.cards.Card)

Example 3 with PlayerGainedLifeWatcher

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

the class RegnaTheRedeemerCondition method getInputValue.

@Override
protected int getInputValue(Game game, Ability source) {
    int gainedLife = 0;
    PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class);
    if (watcher != null) {
        for (UUID playerId : game.getPlayerList()) {
            Player player = game.getPlayer(playerId);
            if (player != null && !player.hasOpponent(source.getControllerId(), game)) {
                gainedLife = watcher.getLifeGained(playerId);
                if (gainedLife > 0) {
                    break;
                }
            }
        }
    }
    return gainedLife;
}
Also used : Player(mage.players.Player) PlayerGainedLifeWatcher(mage.watchers.common.PlayerGainedLifeWatcher) UUID(java.util.UUID)

Aggregations

PlayerGainedLifeWatcher (mage.watchers.common.PlayerGainedLifeWatcher)3 Player (mage.players.Player)2 UUID (java.util.UUID)1 Cost (mage.abilities.costs.Cost)1 PayLifeCost (mage.abilities.costs.common.PayLifeCost)1 Card (mage.cards.Card)1 DemonFlyingToken (mage.game.permanent.token.DemonFlyingToken)1