Search in sources :

Example 1 with DrawDiscardControllerEffect

use of mage.abilities.effects.common.DrawDiscardControllerEffect in project mage by magefree.

the class HordewingSkaabTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        if (!damagedEvent.isCombatDamage()) {
            continue;
        }
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.ZOMBIE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DrawDiscardControllerEffect(opponents.size(), opponents.size()));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DrawDiscardControllerEffect(mage.abilities.effects.common.DrawDiscardControllerEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 2 with DrawDiscardControllerEffect

use of mage.abilities.effects.common.DrawDiscardControllerEffect in project mage by magefree.

the class MirrodinBesiegedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    new DrawDiscardControllerEffect(1, 1).apply(game, source);
    Player player = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (player == null || opponent == null) {
        return false;
    }
    if (player.getGraveyard().getCards(StaticFilters.FILTER_CARD_ARTIFACT, source.getSourceId(), source.getControllerId(), game).size() >= 15) {
        opponent.lost(game);
    }
    return true;
}
Also used : Player(mage.players.Player) DrawDiscardControllerEffect(mage.abilities.effects.common.DrawDiscardControllerEffect)

Aggregations

DrawDiscardControllerEffect (mage.abilities.effects.common.DrawDiscardControllerEffect)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 DamagedEvent (mage.game.events.DamagedEvent)1 DamagedPlayerBatchEvent (mage.game.events.DamagedPlayerBatchEvent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1