use of mage.watchers.common.CardsAmountDrawnThisTurnWatcher in project mage by magefree.
the class KeranosGodOfStormsTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getPlayerId().equals(this.getControllerId())) {
return false;
}
if (!game.isActivePlayer(this.getControllerId())) {
return false;
}
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
return false;
}
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = (Permanent) getSourceObject(game);
if (card == null || controller == null || sourcePermanent == null) {
return false;
}
controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
this.getTargets().clear();
this.getEffects().clear();
if (card.isLand(game)) {
this.addEffect(new DrawCardSourceControllerEffect(1));
} else {
this.addEffect(new DamageTargetEffect(3));
this.addTarget(new TargetAnyTarget());
}
return true;
}
use of mage.watchers.common.CardsAmountDrawnThisTurnWatcher in project mage by magefree.
the class NarsetParterOfVeilsEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
Player controller = game.getPlayer(source.getControllerId());
return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId());
}
use of mage.watchers.common.CardsAmountDrawnThisTurnWatcher in project mage by magefree.
the class LeovoldEmissaryOfTrestTriggeredAbility method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
Player controller = game.getPlayer(source.getControllerId());
return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId());
}
use of mage.watchers.common.CardsAmountDrawnThisTurnWatcher in project mage by magefree.
the class GodEternalKefnetDrawCardReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!event.getPlayerId().equals(source.getControllerId())) {
return false;
}
Permanent god = game.getPermanent(source.getSourceId());
Player you = game.getPlayer(source.getControllerId());
if (god == null && you == null) {
return false;
}
Card topCard = you.getLibrary().getFromTop(game);
if (topCard == null) {
return false;
}
// only first draw card
// if card casted on that turn or controlled changed then needs history from watcher
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 0) {
return false;
}
// one time use (if multiple cards drawn)
String mark = getAppliedMark(game, source);
if (game.getState().getValue(mark) != null) {
return false;
}
game.getState().setValue(mark, true);
// ask player to reveal top cards
String mes = topCard.getName() + ", " + (topCard.isInstantOrSorcery(game) ? HintUtils.prepareText("you can copy it and cast {2} less", Color.green) : HintUtils.prepareText("you can't copy it", Color.red));
return you.chooseUse(Outcome.Benefit, "Reveal first drawn card (" + mes + ")?", source, game);
}
Aggregations