Search in sources :

Example 6 with FilterLandPermanent

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

the class BoundlessRealmsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    FilterLandPermanent filter = new FilterLandPermanent();
    filter.add(TargetController.YOU.getControllerPredicate());
    int amount = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
    TargetCardInLibrary target = new TargetCardInLibrary(0, amount, StaticFilters.FILTER_CARD_BASIC_LAND);
    if (controller.searchLibrary(target, source, game)) {
        controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
    }
    controller.shuffleLibrary(source, game);
    return true;
}
Also used : Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 7 with FilterLandPermanent

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

the class CyclopeanTombCounterWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game);
    CyclopeanTombCounterWatcher watcher = game.getState().getWatcher(CyclopeanTombCounterWatcher.class);
    if (controller != null && watcher != null) {
        Set<MageObjectReference> landRef = watcher.landMiredByCyclopeanTombInstance(mor, game);
        if (landRef == null || landRef.isEmpty()) {
            // no lands got mire counter from that instance
            return true;
        }
        FilterLandPermanent filter = new FilterLandPermanent("a land with a mire counter added from the Cyclopean Tomb instance (" + landRef.size() + " left)");
        Set<PermanentIdPredicate> idPref = new HashSet<>();
        for (MageObjectReference ref : landRef) {
            Permanent land = ref.getPermanent(game);
            if (land != null) {
                idPref.add(new PermanentIdPredicate(land.getId()));
            }
        }
        filter.add(Predicates.or(idPref));
        TargetLandPermanent target = new TargetLandPermanent(1, 1, filter, true);
        /*Player must choose a land each upkeep. Using the message are above the player hand where frequent interactions
             * take place is the most logical way to prompt for this scenario. A new constructor added to provide a not optional
             * option for any cards like this where the player must choose a target in such the way this card requires.
             */
        if (controller.chooseTarget(Outcome.Neutral, target, source, game)) {
            Permanent chosenLand = game.getPermanent(target.getFirstTarget());
            if (chosenLand != null) {
                Effect effect = new RemoveAllCountersTargetEffect(CounterType.MIRE);
                effect.setTargetPointer(new FixedTarget(chosenLand, game));
                effect.apply(game, source);
                landRef.remove(new MageObjectReference(chosenLand, game));
            }
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) BecomesBasicLandTargetEffect(mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetLandPermanent(mage.target.common.TargetLandPermanent) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) MageObjectReference(mage.MageObjectReference)

Example 8 with FilterLandPermanent

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

the class LandHasFloodCounterCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterLandPermanent filterLand = new FilterLandPermanent();
    filterLand.add(subtype.getPredicate());
    int landCount = game.getBattlefield().getAllActivePermanents(CardType.LAND, game).size();
    return game.getBattlefield().getAllActivePermanents(filterLand, game).size() == landCount;
}
Also used : FilterLandPermanent(mage.filter.common.FilterLandPermanent)

Example 9 with FilterLandPermanent

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

the class TappedLandsCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    if (sourceAbility != null) {
        FilterLandPermanent filter = new FilterLandPermanent("tapped lands on the battlefield");
        filter.add(TappedPredicate.TAPPED);
        return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
    }
    return 0;
}
Also used : FilterLandPermanent(mage.filter.common.FilterLandPermanent)

Example 10 with FilterLandPermanent

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

the class RisingWatersUntapEffect 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)

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