Search in sources :

Example 36 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class CagedSunEffect 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) {
            for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
                if (perm.getColor(game).contains(color)) {
                    perm.addPower(1);
                    perm.addToughness(1);
                }
            }
        }
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ObjectColor(mage.ObjectColor)

Example 37 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class DiamondMareTriggeredAbility 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)

Example 38 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class SealOfTheGuildpactCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    MageObject sourceObject = game.getObject(abilityToModify.getSourceId());
    if (sourceObject != null) {
        ObjectColor color1 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color1");
        ObjectColor color2 = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color2");
        int amount = 0;
        if (color1 != null && sourceObject.getColor(game).contains(color1)) {
            amount++;
        }
        if (color2 != null && sourceObject.getColor(game).contains(color2)) {
            amount++;
        }
        if (amount > 0) {
            SpellAbility spellAbility = (SpellAbility) abilityToModify;
            CardUtil.adjustCost(spellAbility, amount);
        }
        return true;
    }
    return false;
}
Also used : MageObject(mage.MageObject) ObjectColor(mage.ObjectColor) SpellAbility(mage.abilities.SpellAbility)

Example 39 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class SphinxsTutelageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (targetPlayer != null) {
        int possibleIterations = targetPlayer.getLibrary().size() / 2;
        int iteration = 0;
        boolean colorShared;
        do {
            iteration++;
            if (iteration > possibleIterations + 20) {
                // 801.16. If the game somehow enters a "loop" of mandatory actions, repeating a sequence of events
                // with no way to stop, the game is a draw for each player who controls an object that's involved in
                // that loop, as well as for each player within the range of influence of any of those players. They
                // leave the game. All remaining players continue to play the game.
                game.setDraw(source.getControllerId());
                return true;
            }
            colorShared = false;
            List<Card> cards = targetPlayer.millCards(2, source, game).getCards(game).stream().filter(card -> !card.isLand(game)).collect(Collectors.toList());
            if (cards.size() < 2) {
                break;
            }
            for (int i = 0; i < cards.size(); i++) {
                if (colorShared) {
                    break;
                }
                ObjectColor color1 = cards.get(i).getColor(game);
                if (color1.isColorless()) {
                    continue;
                }
                for (int j = 0; j < cards.size(); j++) {
                    if (i >= j) {
                        continue;
                    }
                    ObjectColor color2 = cards.get(j).getColor(game);
                    if (color1.shares(color2)) {
                        colorShared = true;
                        break;
                    }
                }
            }
        } while (colorShared);
        return true;
    }
    return false;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetOpponent(mage.target.common.TargetOpponent) Zone(mage.constants.Zone) DrawDiscardControllerEffect(mage.abilities.effects.common.DrawDiscardControllerEffect) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) List(java.util.List) DrawCardControllerTriggeredAbility(mage.abilities.common.DrawCardControllerTriggeredAbility) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) ObjectColor(mage.ObjectColor) Card(mage.cards.Card) Ability(mage.abilities.Ability) Player(mage.players.Player) ObjectColor(mage.ObjectColor) Card(mage.cards.Card)

Example 40 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class CardInfo method getColor.

public ObjectColor getColor() {
    ObjectColor color = new ObjectColor();
    color.setBlack(black);
    color.setBlue(blue);
    color.setGreen(green);
    color.setRed(red);
    color.setWhite(white);
    return color;
}
Also used : ObjectColor(mage.ObjectColor)

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