Search in sources :

Example 11 with PermanentsOnBattlefieldCount

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

the class RoarOfTheCrowdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
        if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
            return false;
        }
        FilterControlledPermanent filter = new FilterControlledPermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        return new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)).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) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 12 with PermanentsOnBattlefieldCount

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

the class SkyshroudWarBeastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        MageObject target = game.getObject(source.getSourceId());
        if (target != null) {
            UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
            FilterLandPermanent filter = FilterLandPermanent.nonbasicLand();
            filter.add(new ControllerIdPredicate(playerId));
            int number = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
            target.getPower().setValue(number);
            target.getToughness().setValue(number);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) MageObject(mage.MageObject) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) UUID(java.util.UUID)

Example 13 with PermanentsOnBattlefieldCount

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

the class CheeseStandsAloneContinuousEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.getHand().isEmpty()) {
            int numberPerms = new PermanentsOnBattlefieldCount(new FilterControlledPermanent()).calculate(game, source, this);
            if (numberPerms == 1) {
                if (game.getBattlefield().containsControlled(filter, source, game, 1)) {
                    if (!wonAlready) {
                        wonAlready = true;
                        controller.won(game);
                    }
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 14 with PermanentsOnBattlefieldCount

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

the class TezzeretAgentOfBolasEffect2 method apply.

@Override
public boolean apply(Game game, Ability source) {
    int count = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT).calculate(game, source, this) * 2;
    if (count > 0) {
        Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        if (targetPlayer != null) {
            targetPlayer.loseLife(count, game, source, false);
        }
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            controller.gainLife(count, game, source);
        }
    }
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)

Example 15 with PermanentsOnBattlefieldCount

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

the class WinnowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target != null) {
        FilterPermanent filter = new FilterPermanent();
        filter.add(new NamePredicate(target.getName()));
        if (new PermanentsOnBattlefieldCount(filter).calculate(game, source, this) > 1) {
            super.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)

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