Search in sources :

Example 21 with FilterControlledCreaturePermanent

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

the class SamiteElderEffect method apply.

public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target != null) {
        for (ObjectColor color : target.getColor(game).getColors()) {
            FilterCard filter = new FilterCard(color.getDescription());
            filter.add(new ColorPredicate(color));
            game.addEffect(new GainAbilityControlledEffect(new ProtectionAbility(filter), Duration.EndOfTurn, new FilterControlledCreaturePermanent()), source);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent)

Example 22 with FilterControlledCreaturePermanent

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

the class XenagosExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
        if (x == 0) {
            return false;
        }
        Mana mana = new Mana();
        int redCount = player.getAmount(0, x, "How much <b>RED</b> mana add to pool? (available: " + x + ", another mana goes to <b>GREEN</b>)?", game);
        int greenCount = Math.max(0, x - redCount);
        mana.setRed(redCount);
        mana.setGreen(greenCount);
        if (mana.count() > 0) {
            player.getManaPool().addMana(mana, game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) CreaturesYouControlHint(mage.abilities.hint.common.CreaturesYouControlHint)

Example 23 with FilterControlledCreaturePermanent

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

the class ConvokeEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && game.getBattlefield().containsControlled(filterUntapped, source, game, 1)) {
        if (source.getAbilityType() == AbilityType.SPELL) {
            SpecialAction specialAction = new ConvokeSpecialAction(unpaid, this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            // create filter for possible creatures to tap
            FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
            filter.add(TappedPredicate.UNTAPPED);
            if (unpaid.getMana().getGeneric() == 0) {
                List<ColorPredicate> colorPredicates = new ArrayList<>();
                if (unpaid.getMana().getBlack() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
                }
                if (unpaid.getMana().getBlue() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
                }
                if (unpaid.getMana().getRed() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.RED));
                }
                if (unpaid.getMana().getGreen() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
                }
                if (unpaid.getMana().getWhite() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
                }
                filter.add(Predicates.or(colorPredicates));
            }
            Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
            target.setTargetName("tap creature card as convoke's pay");
            specialAction.addTarget(target);
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ArrayList(java.util.ArrayList) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 24 with FilterControlledCreaturePermanent

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

the class LightningRunnerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        new GetEnergyCountersControllerEffect(2).apply(game, source);
        if (controller.getCounters().getCount(CounterType.ENERGY) > 7) {
            Cost cost = new PayEnergyCost(8);
            if (controller.chooseUse(outcome, "Pay {E}{E}{E}{E}{E}{E}{E}{E} to use this? ", "Untap all creatures you control and after this phase, there is an additional combat phase.", "Yes", "No", source, game) && cost.pay(source, game, source, source.getControllerId(), true)) {
                new UntapAllControllerEffect(new FilterControlledCreaturePermanent()).apply(game, source);
                new AdditionalCombatPhaseEffect().apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) GetEnergyCountersControllerEffect(mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect) AdditionalCombatPhaseEffect(mage.abilities.effects.common.AdditionalCombatPhaseEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) Cost(mage.abilities.costs.Cost) PayEnergyCost(mage.abilities.costs.common.PayEnergyCost) UntapAllControllerEffect(mage.abilities.effects.common.UntapAllControllerEffect)

Example 25 with FilterControlledCreaturePermanent

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

the class MoggToadyCantBlockEffect method canAttack.

@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
    if (defenderId == null) {
        return true;
    }
    UUID defendingPlayerId;
    Player defender = game.getPlayer(defenderId);
    if (defender == null) {
        Permanent permanent = game.getPermanent(defenderId);
        if (permanent != null) {
            defendingPlayerId = permanent.getControllerId();
        } else {
            return false;
        }
    } else {
        defendingPlayerId = defenderId;
    }
    if (defendingPlayerId != null) {
        return game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), source.getControllerId(), game) > game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), defendingPlayerId, game);
    } else {
        return true;
    }
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) UUID(java.util.UUID)

Aggregations

FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)75 Permanent (mage.game.permanent.Permanent)62 Player (mage.players.Player)60 UUID (java.util.UUID)29 Target (mage.target.Target)27 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)21 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)16 ArrayList (java.util.ArrayList)13 Card (mage.cards.Card)11 TargetPermanent (mage.target.TargetPermanent)11 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)10 FixedTarget (mage.target.targetpointer.FixedTarget)9 MageObject (mage.MageObject)7 OneShotEffect (mage.abilities.effects.OneShotEffect)7 Effect (mage.abilities.effects.Effect)6 Ability (mage.abilities.Ability)5 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)5 FilterPermanent (mage.filter.FilterPermanent)5 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)5 Spell (mage.game.stack.Spell)5