Search in sources :

Example 66 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class HallOfGemstoneEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ObjectColor colorChosen = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    if (colorChosen == null) {
        return false;
    }
    ManaEvent manaEvent = (ManaEvent) event;
    Mana mana = manaEvent.getMana();
    // 8/23/2016 	Colorless mana added to a player's mana pool isn't affected.
    int genericAmount = mana.getGeneric();
    int colorlessAmount = mana.getColorless();
    int coloredAmount = mana.countColored();
    switch(colorChosen.getOneColoredManaSymbol()) {
        case W:
            mana.setToMana(Mana.WhiteMana(coloredAmount));
            break;
        case U:
            mana.setToMana(Mana.BlueMana(coloredAmount));
            break;
        case B:
            mana.setToMana(Mana.BlackMana(coloredAmount));
            break;
        case R:
            mana.setToMana(Mana.RedMana(coloredAmount));
            break;
        case G:
            mana.setToMana(Mana.GreenMana(coloredAmount));
            break;
    }
    mana.setGeneric(genericAmount);
    mana.setColorless(colorlessAmount);
    return false;
}
Also used : Mana(mage.Mana) ObjectColor(mage.ObjectColor) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 67 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class IlluminatedFolioTarget method possibleTargets.

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
    Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
    if (this.getTargets().size() == 1) {
        Card card = game.getCard(this.getTargets().get(0));
        possibleTargets.removeIf(uuid -> !game.getCard(uuid).getColor(game).shares(card.getColor(game)));
        return possibleTargets;
    }
    if (possibleTargets.size() < 2) {
        possibleTargets.clear();
        return possibleTargets;
    }
    Set<Card> allTargets = possibleTargets.stream().map(game::getCard).collect(Collectors.toSet());
    possibleTargets.clear();
    for (ObjectColor color : ObjectColor.getAllColors()) {
        Set<Card> inColor = allTargets.stream().filter(card -> card.getColor(game).shares(color)).collect(Collectors.toSet());
        if (inColor.size() > 1) {
            inColor.stream().map(MageItem::getId).forEach(possibleTargets::add);
        }
        if (possibleTargets.size() == allTargets.size()) {
            break;
        }
    }
    return possibleTargets;
}
Also used : FilterCard(mage.filter.FilterCard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetCardInHand(mage.target.common.TargetCardInHand) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) Cards(mage.cards.Cards) Set(java.util.Set) Predicates(mage.filter.predicate.Predicates) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) MageItem(mage.MageItem) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) List(java.util.List) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) CardImpl(mage.cards.CardImpl) RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) CardType(mage.constants.CardType) ColorlessPredicate(mage.filter.predicate.mageobject.ColorlessPredicate) ObjectColor(mage.ObjectColor) Card(mage.cards.Card) Ability(mage.abilities.Ability) ObjectColor(mage.ObjectColor) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 68 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class IonaShieldOfEmeriaReplacementEffect method getInfoMessage.

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
    ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
    MageObject mageObject = game.getObject(source.getSourceId());
    if (mageObject != null && chosenColor != null) {
        return "You can't cast " + chosenColor.toString() + " spells (" + mageObject.getIdName() + ").";
    }
    return null;
}
Also used : ObjectColor(mage.ObjectColor) MageObject(mage.MageObject)

Example 69 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class KatildaDawnhartPrimeManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game != null) {
        Player controller = game.getPlayer(source.getControllerId());
        Permanent permanent = source.getSourcePermanentIfItStillExists(game);
        if (controller != null && permanent != null) {
            Choice choice = new ChoiceImpl();
            choice.setMessage("Pick a mana color");
            ObjectColor color = permanent.getColor(game);
            if (color.isWhite()) {
                choice.getChoices().add("White");
            }
            if (color.isBlue()) {
                choice.getChoices().add("Blue");
            }
            if (color.isBlack()) {
                choice.getChoices().add("Black");
            }
            if (color.isRed()) {
                choice.getChoices().add("Red");
            }
            if (color.isGreen()) {
                choice.getChoices().add("Green");
            }
            if (!choice.getChoices().isEmpty()) {
                if (choice.getChoices().size() == 1) {
                    choice.setChoice(choice.getChoices().iterator().next());
                } else {
                    controller.choose(outcome, choice, game);
                }
                if (choice.getChoice() != null) {
                    switch(choice.getChoice()) {
                        case "White":
                            mana.setWhite(1);
                            break;
                        case "Blue":
                            mana.setBlue(1);
                            break;
                        case "Black":
                            mana.setBlack(1);
                            break;
                        case "Red":
                            mana.setRed(1);
                            break;
                        case "Green":
                            mana.setGreen(1);
                            break;
                    }
                }
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ChoiceImpl(mage.choices.ChoiceImpl)

Example 70 with ObjectColor

use of mage.ObjectColor in project mage by magefree.

the class MournersShieldEffect method init.

@Override
public void init(Ability source, Game game) {
    ObjectColor colorsAmongImprinted = new ObjectColor();
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
    if (sourceObject == null || sourceObject.getImprinted() == null) {
        noneExiled = true;
        return;
    }
    for (UUID imprinted : sourceObject.getImprinted()) {
        if (imprinted != null && exileZone.contains(imprinted)) {
            Card card = game.getCard(imprinted);
            if (card != null) {
                colorsAmongImprinted = colorsAmongImprinted.union(card.getColor(game));
            }
        }
    }
    FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card");
    filterObject.add(new SharesColorPredicate(colorsAmongImprinted));
    this.target = new TargetSource(filterObject);
    this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
    if (target.getFirstTarget() != null) {
        mageObjectReference = new MageObjectReference(target.getFirstTarget(), game);
    } else {
        mageObjectReference = null;
    }
}
Also used : TargetSource(mage.target.TargetSource) Permanent(mage.game.permanent.Permanent) SharesColorPredicate(mage.filter.predicate.mageobject.SharesColorPredicate) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

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