Search in sources :

Example 1 with ChoiceColorOrArtifact

use of mage.choices.ChoiceColorOrArtifact in project mage by magefree.

the class JeweledSpiritEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
    if (controller != null && controller.choose(outcome, choice, game)) {
        FilterCard protectionFilter = new FilterCard();
        if (choice.isArtifactSelected()) {
            protectionFilter.add(CardType.ARTIFACT.getPredicate());
        } else {
            protectionFilter.add(new ColorPredicate(choice.getColor()));
        }
        protectionFilter.setMessage(choice.getChoice());
        ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
        ContinuousEffect effect = new GainAbilitySourceEffect(protectionAbility, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ChoiceColorOrArtifact(mage.choices.ChoiceColorOrArtifact) Player(mage.players.Player) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 2 with ChoiceColorOrArtifact

use of mage.choices.ChoiceColorOrArtifact in project mage by magefree.

the class ApostlesBlessingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
        if (controller.choose(outcome, choice, game)) {
            FilterCard protectionFilter = new FilterCard();
            if (choice.isArtifactSelected()) {
                protectionFilter.add(CardType.ARTIFACT.getPredicate());
            } else {
                protectionFilter.add(new ColorPredicate(choice.getColor()));
            }
            protectionFilter.setMessage(choice.getChoice());
            ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
            ContinuousEffect effect = new GainAbilityTargetEffect(protectionAbility, Duration.EndOfTurn);
            effect.setTargetPointer(getTargetPointer());
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) ChoiceColorOrArtifact(mage.choices.ChoiceColorOrArtifact) Player(mage.players.Player) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)2 ChoiceColorOrArtifact (mage.choices.ChoiceColorOrArtifact)2 FilterCard (mage.filter.FilterCard)2 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)2 Player (mage.players.Player)2 GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1