Search in sources :

Example 1 with PermanentsOnBattlefieldCount

use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.

the class ElvishBranchbenderToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
    // fix
    ContinuousEffect effect = new BecomesCreatureTargetEffect(new ElvishBranchbenderToken(xValue), false, false, Duration.EndOfTurn);
    effect.setTargetPointer(targetPointer);
    game.addEffect(effect, source);
    return false;
}
Also used : BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 2 with PermanentsOnBattlefieldCount

use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.

the class HarvestSeasonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int tappedCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
        if (tappedCreatures > 0) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, tappedCreatures, 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;
    }
    return false;
}
Also used : Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 3 with PermanentsOnBattlefieldCount

use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount 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 4 with PermanentsOnBattlefieldCount

use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.

the class PeerPressureEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (controller != null && controller.choose(Outcome.GainControl, choice, game)) {
        String chosenType = choice.getChoice();
        game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
        UUID playerWithMost = null;
        int maxControlled = 0;
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            FilterPermanent filter = new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType);
            filter.add(new ControllerIdPredicate(playerId));
            int controlled = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
            if (controlled > maxControlled) {
                maxControlled = controlled;
                playerWithMost = playerId;
            } else if (controlled == maxControlled) {
                // Do nothing in case of tie
                playerWithMost = null;
            }
        }
        if (playerWithMost != null && playerWithMost.equals(controller.getId())) {
            for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType), controller.getId(), source.getSourceId(), game)) {
                ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame);
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 5 with PermanentsOnBattlefieldCount

use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.

the class LuminescentRainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) {
        FilterControlledPermanent filter = new FilterControlledPermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Aggregations

PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)22 Player (mage.players.Player)18 Permanent (mage.game.permanent.Permanent)6 Choice (mage.choices.Choice)5 ChoiceCreatureType (mage.choices.ChoiceCreatureType)5 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 Card (mage.cards.Card)4 FilterPermanent (mage.filter.FilterPermanent)4 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)4 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)4 UUID (java.util.UUID)3 CardsImpl (mage.cards.CardsImpl)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Cost (mage.abilities.costs.Cost)2 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)2 Effect (mage.abilities.effects.Effect)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 BecomesCreatureTargetEffect (mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect)2