Search in sources :

Example 46 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class LeaveNoTraceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
    if (target != null) {
        ObjectColor color = target.getColor(game);
        target.destroy(source, game, false);
        for (Permanent p : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
            if (p.getColor(game).shares(color)) {
                p.destroy(source, game, false);
            }
        }
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetEnchantmentPermanent(mage.target.common.TargetEnchantmentPermanent) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor)

Example 47 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class PsychicAllergyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
        filter.add(TokenPredicate.FALSE);
        int damage = game.getBattlefield().countAll(filter, player.getId(), game);
        player.damage(damage, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ObjectColor(mage.ObjectColor)

Example 48 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class ThoughtPrisonDamageEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Spell spell = (Spell) game.getObject(event.getTargetId());
    Permanent sourcePermanent = game.getPermanent(this.getSourceId());
    if (spell instanceof Spell) {
        if (sourcePermanent == null) {
            sourcePermanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
        }
        if (sourcePermanent != null && sourcePermanent.getImprinted() != null && !sourcePermanent.getImprinted().isEmpty()) {
            Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0));
            if (imprintedCard != null && game.getState().getZone(imprintedCard.getId()) == Zone.EXILED) {
                // Check if spell's color matches the imprinted card
                ObjectColor spellColor = spell.getColor(game);
                ObjectColor imprintedColor = imprintedCard.getColor(game);
                boolean matches = false;
                if (spellColor.shares(imprintedColor)) {
                    matches = true;
                }
                // Check if spell's CMC matches the imprinted card
                int cmc = spell.getManaValue();
                int imprintedCmc = imprintedCard.getManaValue();
                if (cmc == imprintedCmc) {
                    matches = true;
                }
                if (matches) {
                    for (Effect effect : this.getEffects()) {
                        effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
                    }
                    return matches;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) Spell(mage.game.stack.Spell) FilterSpell(mage.filter.FilterSpell) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 49 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class VolrathsLaboratoryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
    Token token = new VolrathsLaboratoryToken(color, subType);
    return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
Also used : SubType(mage.constants.SubType) ObjectColor(mage.ObjectColor) VolrathsLaboratoryToken(mage.game.permanent.token.VolrathsLaboratoryToken) Token(mage.game.permanent.token.Token) VolrathsLaboratoryToken(mage.game.permanent.token.VolrathsLaboratoryToken)

Example 50 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class ZombieBoaTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (player.choose(outcome, choice, game)) {
        ObjectColor color = choice.getColor();
        game.informPlayers(player.getLogName() + " chooses " + color);
        game.addDelayedTriggeredAbility(new ZombieBoaTriggeredAbility(color), source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ObjectColor(mage.ObjectColor) ChoiceColor(mage.choices.ChoiceColor)

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