Search in sources :

Example 1 with BecomesColorTargetEffect

use of mage.abilities.effects.common.continuous.BecomesColorTargetEffect in project mage by magefree.

the class ChangeColorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    Permanent chosen = game.getPermanent(targetPointer.getFirst(game, source));
    if (player != null && permanent != null) {
        ContinuousEffect effect = new BecomesColorTargetEffect(null, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(chosen.getId(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesColorTargetEffect(mage.abilities.effects.common.continuous.BecomesColorTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 2 with BecomesColorTargetEffect

use of mage.abilities.effects.common.continuous.BecomesColorTargetEffect in project mage by magefree.

the class ChainerDementiaMasterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID cardId = this.getTargetPointer().getFirst(game, source);
        new ReturnFromGraveyardToBattlefieldTargetEffect().apply(game, source);
        Permanent permanent = game.getPermanent(cardId);
        if (permanent != null) {
            ContinuousEffectImpl effect = new BecomesColorTargetEffect(ObjectColor.BLACK, Duration.WhileOnBattlefield);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
            effect = new BecomesCreatureTypeTargetEffect(Duration.WhileOnBattlefield, SubType.NIGHTMARE, false);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesColorTargetEffect(mage.abilities.effects.common.continuous.BecomesColorTargetEffect) Player(mage.players.Player) BecomesCreatureTypeTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) UUID(java.util.UUID)

Example 3 with BecomesColorTargetEffect

use of mage.abilities.effects.common.continuous.BecomesColorTargetEffect in project mage by magefree.

the class BecomesColorOrColorsEnchantedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (enchantment == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
    StringBuilder sb = new StringBuilder();
    if (controller == null || permanent == null) {
        return false;
    }
    for (int i = 0; i < 5; i++) {
        if (i > 0) {
            if (!controller.chooseUse(Outcome.Neutral, "Choose another color?", source, game)) {
                break;
            }
        }
        ChoiceColor choiceColor = new ChoiceColor();
        if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
            return false;
        }
        if (!game.isSimulation()) {
            game.informPlayers(permanent.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
        }
        if (choiceColor.getColor().isBlack()) {
            sb.append('B');
        } else if (choiceColor.getColor().isBlue()) {
            sb.append('U');
        } else if (choiceColor.getColor().isRed()) {
            sb.append('R');
        } else if (choiceColor.getColor().isGreen()) {
            sb.append('G');
        } else if (choiceColor.getColor().isWhite()) {
            sb.append('W');
        }
    }
    String colors = new String(sb);
    ObjectColor chosenColors = new ObjectColor(colors);
    ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, Duration.Custom);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesColorTargetEffect(mage.abilities.effects.common.continuous.BecomesColorTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Aggregations

BecomesColorTargetEffect (mage.abilities.effects.common.continuous.BecomesColorTargetEffect)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 TargetPermanent (mage.target.TargetPermanent)2 UUID (java.util.UUID)1 ObjectColor (mage.ObjectColor)1 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)1 ReturnFromGraveyardToBattlefieldTargetEffect (mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect)1 BecomesCreatureTypeTargetEffect (mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect)1 ChoiceColor (mage.choices.ChoiceColor)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1