Search in sources :

Example 6 with TargetLandPermanent

use of mage.target.common.TargetLandPermanent in project mage by magefree.

the class DeusOfCalamityTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.getSourceId()) && event.getAmount() > 5 && game.getOpponents(this.getControllerId()).contains(event.getTargetId())) {
        FilterLandPermanent filter = new FilterLandPermanent("land of the damaged player");
        filter.add(new ControllerIdPredicate(event.getTargetId()));
        Target target = new TargetLandPermanent(filter);
        this.getTargets().clear();
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) FilterLandPermanent(mage.filter.common.FilterLandPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetLandPermanent(mage.target.common.TargetLandPermanent)

Example 7 with TargetLandPermanent

use of mage.target.common.TargetLandPermanent in project mage by magefree.

the class HokoriDustDrinkerUntapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    FilterLandPermanent filter = new FilterLandPermanent("land you control");
    filter.add(new ControllerIdPredicate(game.getActivePlayerId()));
    Target target = new TargetLandPermanent(filter);
    if (player != null && player.chooseTarget(Outcome.Untap, target, source, game)) {
        for (UUID landId : target.getTargets()) {
            Permanent land = game.getPermanent(landId);
            if (land != null) {
                land.untap(game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetLandPermanent(mage.target.common.TargetLandPermanent) UUID(java.util.UUID)

Example 8 with TargetLandPermanent

use of mage.target.common.TargetLandPermanent in project mage by magefree.

the class UntapLandsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int tappedLands;
        if (upTo) {
            tappedLands = game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game).size();
        } else {
            tappedLands = game.getBattlefield().getAllActivePermanents(filter, game).size();
        }
        TargetLandPermanent target = new TargetLandPermanent(upTo ? 0 : Math.min(tappedLands, amount), amount, filter, true);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            // UI Shortcut: Check if any lands are already tapped.  If there are equal/fewer than amount, give the option to add those in to be untapped now.
            if (tappedLands <= amount && upTo) {
                if (controller.chooseUse(outcome, "Include your tapped lands to untap?", source, game)) {
                    for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
                        target.addTarget(land.getId(), source, game);
                    }
                }
            }
            if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) {
                for (UUID targetId : target.getTargets()) {
                    Permanent p = game.getPermanent(targetId);
                    if (p != null) {
                        p.untap(game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) UUID(java.util.UUID)

Example 9 with TargetLandPermanent

use of mage.target.common.TargetLandPermanent in project mage by magefree.

the class KeldonFirebombersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> landsToSacrifice = new ArrayList<>();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size() - 3;
            if (amount > 0) {
                FilterLandPermanent playerFilter = filter.copy();
                playerFilter.add(new ControllerIdPredicate(playerId));
                Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
                player.choose(outcome.Sacrifice, target, source.getSourceId(), game);
                for (UUID landId : target.getTargets()) {
                    Permanent land = game.getPermanent(landId);
                    if (land != null) {
                        landsToSacrifice.add(land);
                    }
                }
            }
        }
    }
    for (Permanent land : landsToSacrifice) {
        land.sacrifice(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ArrayList(java.util.ArrayList) TargetLandPermanent(mage.target.common.TargetLandPermanent) UUID(java.util.UUID)

Example 10 with TargetLandPermanent

use of mage.target.common.TargetLandPermanent in project mage by magefree.

the class ThoughtsOfRuinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = controller.getHand().size();
        if (amount > 0) {
            List<Permanent> permanentsToSacrifice = new ArrayList<>();
            // select all lands to sacrifice
            for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    int lands = game.getState().getBattlefield().countAll(filter, playerId, game);
                    if (amount >= lands) {
                        permanentsToSacrifice.addAll(game.getState().getBattlefield().getAllActivePermanents(filter, playerId, game));
                    } else {
                        FilterLandPermanent playerFilter = filter.copy();
                        playerFilter.add(new ControllerIdPredicate(playerId));
                        Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
                        player.choose(outcome, target, source.getSourceId(), game);
                        for (UUID landId : target.getTargets()) {
                            Permanent permanent = game.getPermanent(landId);
                            if (permanent != null) {
                                permanentsToSacrifice.add(permanent);
                            }
                        }
                    }
                }
            }
            // sacrifice all lands
            for (Permanent permanent : permanentsToSacrifice) {
                permanent.sacrifice(source, game);
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ArrayList(java.util.ArrayList) TargetLandPermanent(mage.target.common.TargetLandPermanent) UUID(java.util.UUID)

Aggregations

TargetLandPermanent (mage.target.common.TargetLandPermanent)15 Player (mage.players.Player)13 Permanent (mage.game.permanent.Permanent)12 FilterLandPermanent (mage.filter.common.FilterLandPermanent)11 Target (mage.target.Target)10 UUID (java.util.UUID)9 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)6 OneShotEffect (mage.abilities.effects.OneShotEffect)3 Card (mage.cards.Card)3 TargetPermanent (mage.target.TargetPermanent)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Ability (mage.abilities.Ability)2 Effect (mage.abilities.effects.Effect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 MageObjectReference (mage.MageObjectReference)1 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 PermanentsOnTheBattlefieldCondition (mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition)1