Search in sources :

Example 1 with PlayerLostLifeWatcher

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

the class WarlockClassEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    if (watcher == null) {
        return false;
    }
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        int lifeLost = watcher.getLifeLost(playerId);
        if (lifeLost > 0) {
            opponent.loseLife(lifeLost, game, source, false);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher) UUID(java.util.UUID) MorbidHint(mage.abilities.hint.common.MorbidHint)

Example 2 with PlayerLostLifeWatcher

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

the class LolthSpiderQueenEmblemEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    return player != null && watcher != null && player.loseLife(Math.max(8 - watcher.getLifeLost(player.getId()), 0), game, source, false) > 0;
}
Also used : Player(mage.players.Player) PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher)

Example 3 with PlayerLostLifeWatcher

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

the class OpponentLostLifeCondition method getInputValue.

@Override
protected int getInputValue(Game game, Ability source) {
    int maxLostLive = 0;
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    if (watcher != null) {
        for (UUID opponentId : game.getOpponents(source.getControllerId())) {
            int lostLive = watcher.getLifeLost(opponentId);
            if (lostLive > maxLostLive) {
                maxLostLive = lostLive;
            }
        }
    }
    return maxLostLive;
}
Also used : PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher) UUID(java.util.UUID)

Example 4 with PlayerLostLifeWatcher

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

the class FlorianVoldarenScionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    if (controller != null && watcher != null) {
        int lifeLost = watcher.getAllOppLifeLost(controller.getId(), game);
        if (lifeLost > 0) {
            Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, lifeLost));
            int numCards = cards.size();
            if (numCards > 0) {
                controller.lookAtCards(source, null, cards, game);
                Card selectedCard;
                if (numCards == 1) {
                    selectedCard = game.getCard(cards.iterator().next());
                } else {
                    TargetCard target = new TargetCard(Zone.LIBRARY, StaticFilters.FILTER_CARD);
                    controller.chooseTarget(outcome, cards, target, source, game);
                    selectedCard = game.getCard(target.getFirstTarget());
                }
                if (selectedCard != null) {
                    cards.remove(selectedCard);
                    PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, selectedCard, TargetController.YOU, Duration.EndOfTurn, false, false, false);
                }
                if (!cards.isEmpty()) {
                    controller.putCardsOnBottomOfLibrary(cards, game, source, false);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard)

Example 5 with PlayerLostLifeWatcher

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

the class TheaterOfHorrorsCastEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    Card theCard = game.getCard(objectId);
    if (theCard == null) {
        return false;
    }
    // for split cards and mdfc
    objectId = theCard.getMainCard().getId();
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    if (watcher != null && game.isActivePlayer(source.getControllerId()) && watcher.getAllOppLifeLost(source.getControllerId(), game) > 0 && affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
        ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
        return zone != null && zone.contains(objectId);
    }
    return false;
}
Also used : PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher) ExileZone(mage.game.ExileZone) Card(mage.cards.Card)

Aggregations

PlayerLostLifeWatcher (mage.watchers.common.PlayerLostLifeWatcher)7 Player (mage.players.Player)5 UUID (java.util.UUID)4 MorbidHint (mage.abilities.hint.common.MorbidHint)1 Card (mage.cards.Card)1 ExileZone (mage.game.ExileZone)1 TargetCard (mage.target.TargetCard)1