Search in sources :

Example 31 with FilterLandPermanent

use of mage.filter.common.FilterLandPermanent in project mage by magefree.

the class DemonicHordesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent demonicHordes = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && demonicHordes != null) {
        StringBuilder sb = new StringBuilder(cost.getText()).append('?');
        if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
            sb.insert(0, "Pay ");
        }
        if (controller.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                return true;
            }
        }
        demonicHordes.tap(source, game);
        Target choiceOpponent = new TargetOpponent();
        choiceOpponent.setNotTarget(true);
        FilterLandPermanent filterLand = new FilterLandPermanent();
        filterLand.add(new ControllerIdPredicate(source.getControllerId()));
        if (controller.choose(Outcome.Neutral, choiceOpponent, source.getSourceId(), game)) {
            Player opponent = game.getPlayer(choiceOpponent.getFirstTarget());
            if (opponent != null) {
                Target chosenLand = new TargetLandPermanent(filterLand);
                chosenLand.setNotTarget(true);
                if (opponent.chooseTarget(Outcome.Sacrifice, chosenLand, source, game)) {
                    Permanent land = game.getPermanent(chosenLand.getFirstTarget());
                    if (land != null) {
                        land.sacrifice(source, game);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetOpponent(mage.target.common.TargetOpponent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetLandPermanent(mage.target.common.TargetLandPermanent)

Example 32 with FilterLandPermanent

use of mage.filter.common.FilterLandPermanent in project mage by magefree.

the class AnathemancerCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    if (sourceAbility.getFirstTarget() == null) {
        return 0;
    }
    FilterLandPermanent filter = new FilterLandPermanent();
    filter.add(Predicates.not(SuperType.BASIC.getPredicate()));
    filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget()));
    return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
Also used : FilterLandPermanent(mage.filter.common.FilterLandPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Aggregations

FilterLandPermanent (mage.filter.common.FilterLandPermanent)32 Player (mage.players.Player)22 Permanent (mage.game.permanent.Permanent)18 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)13 UUID (java.util.UUID)12 TargetLandPermanent (mage.target.common.TargetLandPermanent)10 Target (mage.target.Target)8 FilterPermanent (mage.filter.FilterPermanent)6 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)5 ArrayList (java.util.ArrayList)4 TargetPermanent (mage.target.TargetPermanent)4 TargetPlayer (mage.target.TargetPlayer)4 MageObject (mage.MageObject)3 CardsImpl (mage.cards.CardsImpl)3 FilterControlledLandPermanent (mage.filter.common.FilterControlledLandPermanent)3 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)3 HashSet (java.util.HashSet)2 MageObjectReference (mage.MageObjectReference)2 Mana (mage.Mana)2 Ability (mage.abilities.Ability)2