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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations