Search in sources :

Example 16 with FilterNonlandPermanent

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

the class BloodletterEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Map<Character, Integer> initialCount = new HashMap<>();
    for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), getControllerId(), getSourceId(), game)) {
        Character initial = permanent.getName().charAt(0);
        initialCount.putIfAbsent(initial, 0);
        initialCount.put(initial, initialCount.get(initial) + 1);
    }
    for (Map.Entry<Character, Integer> entry : initialCount.entrySet()) {
        if (entry.getValue() >= 3) {
            return true;
        }
    }
    return false;
}
Also used : FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) Permanent(mage.game.permanent.Permanent) HashMap(java.util.HashMap) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with FilterNonlandPermanent

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

the class HasLowestCMCAmongstNonlandPermanentsPredicate method apply.

@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
    FilterPermanent filter = new FilterNonlandPermanent();
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, input.getObject().getManaValue()));
    return !game.getBattlefield().contains(filter, input.getSourceId(), input.getPlayerId(), game, 1);
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent)

Aggregations

FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)17 Permanent (mage.game.permanent.Permanent)13 FilterPermanent (mage.filter.FilterPermanent)11 Player (mage.players.Player)11 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)8 TargetPermanent (mage.target.TargetPermanent)7 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)5 UUID (java.util.UUID)3 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)3 Target (mage.target.Target)3 HashMap (java.util.HashMap)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)2 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)2 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)2 PlayerList (mage.players.PlayerList)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1