Search in sources :

Example 61 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 targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null) {
        Player player = game.getPlayer(targetCreature.getControllerId());
        if (player != null) {
            ChoiceColor colorChoice = new ChoiceColor();
            if (player.choose(Outcome.Neutral, colorChoice, game)) {
                game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
                game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor());
                ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color");
                if (protectColor != null) {
                    ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
                    effect.setTargetPointer(new FixedTarget(targetCreature, 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) ChoiceColor(mage.choices.ChoiceColor)

Example 62 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class RallyTheRighteousBoostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (target != null) {
        ObjectColor color = target.getColor(game);
        target.untap(game);
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
            if (permanent.getColor(game).shares(color) && !permanent.getId().equals(target.getId())) {
                permanent.untap(game);
            }
        }
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor)

Example 63 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class WardSliverGainAbilityControlledEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (protectionFilter == null) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
            ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
            if (color != null) {
                protectionFilter = new FilterPermanent(color.getDescription());
                protectionFilter.add(new ColorPredicate(color));
            }
        }
    }
    if (protectionFilter != null) {
        for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ALL_SLIVERS, game)) {
            perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ObjectColor(mage.ObjectColor) ProtectionAbility(mage.abilities.keyword.ProtectionAbility)

Example 64 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class WashOutEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> cardsToReturn = new LinkedHashSet<>();
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
        ObjectColor color = choice.getColor();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(color));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            cardsToReturn.add((Card) permanent);
        }
        return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ChoiceColor(mage.choices.ChoiceColor) Card(mage.cards.Card)

Example 65 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class VerifyCardDataTest method checkColors.

private void checkColors(Card card, MtgJsonCard ref) {
    if (skipListHaveName(SKIP_LIST_COLOR, card.getExpansionSetCode(), card.getName())) {
        return;
    }
    Set<String> expected = new HashSet<>();
    if (ref.colors != null) {
        expected.addAll(ref.colors);
    }
    if (card.isFlipCard()) {
        expected.addAll(ref.colorIdentity);
    }
    ObjectColor color = card.getColor(null);
    if (expected.size() != color.getColorCount() || (color.isBlack() && !expected.contains("B")) || (color.isBlue() && !expected.contains("U")) || (color.isGreen() && !expected.contains("G")) || (color.isRed() && !expected.contains("R")) || (color.isWhite() && !expected.contains("W"))) {
        fail(card, "colors", color + " != " + expected);
    }
}
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