Search in sources :

Example 1 with FilterObject

use of mage.filter.FilterObject in project mage by magefree.

the class PrismaticCircleEffect method init.

@Override
public void init(Ability source, Game game) {
    FilterObject filter = targetSource.getFilter();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
    super.init(source, game);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor)

Example 2 with FilterObject

use of mage.filter.FilterObject in project mage by magefree.

the class StoryCircleEffect method init.

@Override
public void init(Ability source, Game game) {
    FilterObject filter = targetSource.getFilter();
    filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
    super.init(source, game);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor)

Example 3 with FilterObject

use of mage.filter.FilterObject in project mage by magefree.

the class ProtectionChosenColorTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (permanent != null) {
        ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
        if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
            chosenColor = color;
            FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
            protectionFilter.add(new ColorPredicate(chosenColor));
            protectionAbility = new ProtectionAbility(protectionFilter);
        }
        if (protectionAbility != null) {
            permanent.addAbility(protectionAbility, source.getSourceId(), game);
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 4 with FilterObject

use of mage.filter.FilterObject in project mage by magefree.

the class ProtectionChosenColorSourceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
        ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
        if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
            chosenColor = color;
            FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
            protectionFilter.add(new ColorPredicate(chosenColor));
            protectionAbility = new ProtectionAbility(protectionFilter);
        }
        if (protectionAbility != null) {
            permanent.addAbility(protectionAbility, source.getSourceId(), game);
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 5 with FilterObject

use of mage.filter.FilterObject in project mage by magefree.

the class ProtectionChosenColorAttachedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent attachement = game.getPermanent(source.getSourceId());
    if (attachement != null && attachement.getAttachedTo() != null) {
        ObjectColor color = (ObjectColor) game.getState().getValue(attachement.getId() + "_color");
        if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
            chosenColor = color;
            FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
            protectionFilter.add(new ColorPredicate(chosenColor));
            protectionAbility = new ProtectionAbility(protectionFilter);
            if (notRemoveItself) {
                protectionAbility.setAuraIdNotToBeRemoved(source.getSourceId());
            }
            if (notRemoveControlled) {
                protectionAbility.setDoesntRemoveControlled(true);
                protectionAbility.setRemoveEquipment(false);
                protectionAbility.setRemovesAuras(false);
            }
        }
        if (protectionAbility != null) {
            Permanent attachedTo = game.getPermanent(attachement.getAttachedTo());
            if (attachedTo != null) {
                attachedTo.addAbility(protectionAbility, source.getSourceId(), game);
            }
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Permanent(mage.game.permanent.Permanent) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Aggregations

FilterObject (mage.filter.FilterObject)8 ObjectColor (mage.ObjectColor)7 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)6 Permanent (mage.game.permanent.Permanent)5 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)4 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 MageObjectReference (mage.MageObjectReference)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)1 Card (mage.cards.Card)1 Filter (mage.filter.Filter)1 Predicate (mage.filter.predicate.Predicate)1 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)1 SharesColorPredicate (mage.filter.predicate.mageobject.SharesColorPredicate)1 ExileZone (mage.game.ExileZone)1 Player (mage.players.Player)1 TargetSource (mage.target.TargetSource)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1