Search in sources :

Example 1 with FilterControlledLandPermanent

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

the class DinOfTheFireherdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean applied;
    Token token = new DinOfTheFireherdToken();
    applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
    int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
    int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetOpponent != null) {
        Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
        Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
        effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect2.apply(game, source);
        applied = true;
    }
    return applied;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) Token(mage.game.permanent.token.Token) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Example 2 with FilterControlledLandPermanent

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

the class HazezonTamarEntersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Effect effect = new CreateTokenEffect(new HazezonTamarSandWarriorToken(), new PermanentsOnBattlefieldCount(new FilterControlledLandPermanent()));
        effect.setText("create X 1/1 Sand Warrior creature tokens that are red, green, and white, where X is the number of lands you control at that time");
        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ExileAllEffect(mage.abilities.effects.common.ExileAllEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility) HazezonTamarSandWarriorToken(mage.game.permanent.token.HazezonTamarSandWarriorToken) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Example 3 with FilterControlledLandPermanent

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

the class ScapeshiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int amount = 0;
    TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
    if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
        for (UUID uuid : sacrificeLand.getTargets()) {
            Permanent land = game.getPermanent(uuid);
            if (land != null) {
                land.sacrifice(source, game);
                amount++;
            }
        }
    }
    TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
    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;
    }
    controller.shuffleLibrary(source, game);
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) FilterLandCard(mage.filter.common.FilterLandCard) UUID(java.util.UUID) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 4 with FilterControlledLandPermanent

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

the class CataclysmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Card> chosen = new ArrayList<>();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
        Target target2 = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true);
        Target target3 = new TargetControlledPermanent(1, 1, new FilterControlledEnchantmentPermanent(), true);
        Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
        if (target1.canChoose(source.getSourceId(), player.getId(), game)) {
            while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game)) {
                player.chooseTarget(Outcome.Benefit, target1, source, game);
            }
            Permanent artifact = game.getPermanent(target1.getFirstTarget());
            if (artifact != null) {
                chosen.add(artifact);
            }
            target1.clearChosen();
        }
        if (target2.canChoose(source.getSourceId(), player.getId(), game)) {
            while (player.canRespond() && !target2.isChosen() && target2.canChoose(source.getSourceId(), player.getId(), game)) {
                player.chooseTarget(Outcome.Benefit, target2, source, game);
            }
            Permanent creature = game.getPermanent(target2.getFirstTarget());
            if (creature != null) {
                chosen.add(creature);
            }
            target2.clearChosen();
        }
        if (target3.canChoose(source.getSourceId(), player.getId(), game)) {
            while (player.canRespond() && !target3.isChosen() && target3.canChoose(source.getSourceId(), player.getId(), game)) {
                player.chooseTarget(Outcome.Benefit, target3, source, game);
            }
            Permanent enchantment = game.getPermanent(target3.getFirstTarget());
            if (enchantment != null) {
                chosen.add(enchantment);
            }
            target3.clearChosen();
        }
        if (target4.canChoose(source.getSourceId(), player.getId(), game)) {
            while (player.canRespond() && !target4.isChosen() && target4.canChoose(source.getSourceId(), player.getId(), game)) {
                player.chooseTarget(Outcome.Benefit, target4, source, game);
            }
            Permanent land = game.getPermanent(target4.getFirstTarget());
            if (land != null) {
                chosen.add(land);
            }
            target4.clearChosen();
        }
    }
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
        if (!chosen.contains(permanent)) {
            permanent.sacrifice(source, game);
        }
    }
    return true;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterControlledEnchantmentPermanent(mage.filter.common.FilterControlledEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ArrayList(java.util.ArrayList) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) UUID(java.util.UUID) FilterControlledEnchantmentPermanent(mage.filter.common.FilterControlledEnchantmentPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) Card(mage.cards.Card)

Example 5 with FilterControlledLandPermanent

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

the class SerendibDjinnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
        if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
            controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                permanent.sacrifice(source, game);
                if (permanent.hasSubtype(SubType.ISLAND, game)) {
                    controller.damage(3, source.getSourceId(), source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Aggregations

FilterControlledLandPermanent (mage.filter.common.FilterControlledLandPermanent)19 Player (mage.players.Player)19 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)14 Permanent (mage.game.permanent.Permanent)13 UUID (java.util.UUID)11 Target (mage.target.Target)7 OneShotEffect (mage.abilities.effects.OneShotEffect)4 Cost (mage.abilities.costs.Cost)3 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)3 CardsImpl (mage.cards.CardsImpl)3 TargetPermanent (mage.target.TargetPermanent)3 ArrayList (java.util.ArrayList)2 MageObject (mage.MageObject)2 Ability (mage.abilities.Ability)2 Effect (mage.abilities.effects.Effect)2 Card (mage.cards.Card)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 CardType (mage.constants.CardType)2 Outcome (mage.constants.Outcome)2