Search in sources :

Example 11 with FilterLandPermanent

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

the class VisionCharmEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceLandType();
        if (!controller.choose(outcome, choice, game)) {
            discard();
            return;
        }
        targetLandType = choice.getChoice();
        choice = new ChoiceBasicLandType();
        if (!controller.choose(outcome, choice, game)) {
            discard();
            return;
        }
        targetBasicLandType = SubType.byDescription(choice.getChoice());
        if (targetLandType == null || targetBasicLandType == null) {
            this.discard();
            return;
        }
    } else {
        this.discard();
        return;
    }
    FilterPermanent filter = new FilterLandPermanent();
    filter.add(SubType.byDescription(targetLandType).getPredicate());
    if (this.affectedObjectsSet) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
            affectedObjectList.add(new MageObjectReference(permanent, game));
        }
    }
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceLandType(mage.choices.ChoiceLandType) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) ChoiceBasicLandType(mage.choices.ChoiceBasicLandType) MageObjectReference(mage.MageObjectReference)

Example 12 with FilterLandPermanent

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

the class SimpleGameTest method testSimple.

@Test
public void testSimple() {
    addCard(Zone.BATTLEFIELD, playerA, "Forest");
    addCard(Zone.BATTLEFIELD, playerB, "Forest");
    addCard(Zone.BATTLEFIELD, playerC, "Forest");
    addCard(Zone.BATTLEFIELD, playerD, "Forest");
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertLife(playerA, 20);
    assertLife(playerB, 20);
    assertLife(playerC, 20);
    assertLife(playerD, 20);
    FilterPermanent filterPermanent = new FilterLandPermanent();
    filterPermanent.add(SubType.FOREST.getPredicate());
    List<Permanent> forestCards = currentGame.getBattlefield().getAllActivePermanents(filterPermanent, currentGame);
    Assert.assertEquals(4, forestCards.size());
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) Test(org.junit.Test)

Example 13 with FilterLandPermanent

use of mage.filter.common.FilterLandPermanent 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 14 with FilterLandPermanent

use of mage.filter.common.FilterLandPermanent 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 15 with FilterLandPermanent

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

the class ManaSkimmerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent source = game.getPermanent(event.getSourceId());
    if (source != null && source.getId().equals(this.getSourceId())) {
        FilterLandPermanent filter = new FilterLandPermanent("land that player controls");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        filter.setMessage("land controlled by " + game.getPlayer(event.getTargetId()).getLogName());
        this.getTargets().clear();
        this.addTarget(new TargetPermanent(filter));
        return true;
    }
    return false;
}
Also used : FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

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