Search in sources :

Example 16 with ObjectColor

use of mage.ObjectColor 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 17 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class PrismaticWardPreventDamageEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (!super.applies(event, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
    if (color == null) {
        return false;
    }
    MageObject sourceObject = game.getObject(event.getSourceId());
    if (sourceObject == null || !sourceObject.getColor(game).shares(color)) {
        return false;
    }
    Permanent attachment = game.getPermanent(source.getSourceId());
    if (attachment != null && attachment.getAttachedTo() != null && event.getTargetId().equals(attachment.getAttachedTo())) {
        return true;
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ObjectColor(mage.ObjectColor) MageObject(mage.MageObject)

Example 18 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class RallyTheRighteousBoostEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (target != null) {
        affectedObjectList.add(new MageObjectReference(target, game));
        ObjectColor color = target.getColor(game);
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
            if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
                affectedObjectList.add(new MageObjectReference(permanent, game));
            }
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) MageObjectReference(mage.MageObjectReference)

Example 19 with ObjectColor

use of mage.ObjectColor 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 20 with ObjectColor

use of mage.ObjectColor 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)

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