Search in sources :

Example 11 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class WojekSirenBoostEffect 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 12 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class WojekApothecaryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (target != null) {
            ObjectColor color = target.getColor(game);
            for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
                if (permanent.getColor(game).shares(color)) {
                    ContinuousEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, 1);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) PreventDamageToTargetEffect(mage.abilities.effects.common.PreventDamageToTargetEffect)

Example 13 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class HallOfTriumphBoostControlledEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    if (color != null) {
        for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
            if (perm.getColor(game).shares(color)) {
                perm.addPower(1);
                perm.addToughness(1);
            }
        }
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ObjectColor(mage.ObjectColor)

Example 14 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class OpalTitanBecomesCreatureEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    Permanent permanent = affectedObjectList.get(0).getPermanent(game);
    if (permanent != null) {
        switch(layer) {
            case TypeChangingEffects_4:
                permanent.removeAllCardTypes(game);
                permanent.addCardType(game, CardType.CREATURE);
                permanent.removeAllSubTypes(game);
                permanent.addSubType(game, SubType.GIANT);
                break;
            case AbilityAddingRemovingEffects_6:
                if (game.getState().getValue("opalTitanColor" + source.getSourceId()) != null) {
                    for (ObjectColor color : ((ObjectColor) game.getState().getValue("opalTitanColor" + source.getSourceId())).getColors()) {
                        if (!permanent.getAbilities().contains(ProtectionAbility.from(color))) {
                            permanent.addAbility(ProtectionAbility.from(color), source.getSourceId(), game);
                        }
                    }
                }
                break;
            case PTChangingEffects_7:
                if (sublayer == SubLayer.SetPT_7b) {
                    permanent.getPower().setValue(4);
                    permanent.getToughness().setValue(4);
                }
                break;
        }
        return true;
    }
    this.discard();
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor)

Example 15 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class PrismRingTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        Spell spell = game.getStack().getSpell(event.getTargetId());
        ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
        if (spell != null && color != null && spell.getColor(game).shares(color)) {
            return true;
        }
    }
    return false;
}
Also used : ObjectColor(mage.ObjectColor) 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