Search in sources :

Example 6 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class InvokePrejudiceEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
        Spell spell = (Spell) game.getObject(event.getTargetId());
        if (spell != null && spell.isCreature(game)) {
            boolean creatureSharesAColor = false;
            ObjectColor spellColor = spell.getColor(game);
            for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterControlledCreaturePermanent(), getControllerId(), game)) {
                if (spellColor.shares(permanent.getColor(game))) {
                    creatureSharesAColor = true;
                    break;
                }
            }
            if (!creatureSharesAColor) {
                for (Effect effect : getEffects()) {
                    effect.setTargetPointer(new FixedTarget(event.getTargetId()));
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ObjectColor(mage.ObjectColor) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Effect(mage.abilities.effects.Effect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) Spell(mage.game.stack.Spell)

Example 7 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class IonaShieldOfEmeriaReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
        ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
        // spell is not on the stack yet, so we have to check the card
        Card card = game.getCard(event.getSourceId());
        if (chosenColor != null && card != null && card.getColor(game).contains(chosenColor)) {
            return true;
        }
    }
    return false;
}
Also used : ObjectColor(mage.ObjectColor) Card(mage.cards.Card)

Example 8 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class JihadOpponentCondition method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID chosenOpponent = (UUID) game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) == 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 9 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class JihadOpponentCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID chosenOpponent = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
    filter.add(TokenPredicate.FALSE);
    return game.getBattlefield().countAll(filter, chosenOpponent, game) > 0;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID)

Example 10 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class ParadisePlumeSpellCastTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
    if (color != null) {
        FilterSpell filter = new FilterSpell();
        filter.add(new ColorPredicate(color));
        Spell spell = game.getStack().getSpell(event.getTargetId());
        return (spell != null && filter.match(spell, getSourceId(), getControllerId(), game));
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterSpell(mage.filter.FilterSpell) ObjectColor(mage.ObjectColor) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Aggregations

ObjectColor (mage.ObjectColor)82 Permanent (mage.game.permanent.Permanent)50 Player (mage.players.Player)27 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)19 UUID (java.util.UUID)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)14 Card (mage.cards.Card)13 FilterPermanent (mage.filter.FilterPermanent)13 Spell (mage.game.stack.Spell)12 Ability (mage.abilities.Ability)10 FixedTarget (mage.target.targetpointer.FixedTarget)10 ChoiceColor (mage.choices.ChoiceColor)9 Mana (mage.Mana)8 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)8 ArrayList (java.util.ArrayList)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)7 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)7 FilterCard (mage.filter.FilterCard)7 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)6 MageObject (mage.MageObject)5