Search in sources :

Example 1 with ConditionalContinuousEffect

use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.

the class SowerOfTemptationGainControlEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), new SourceRemainsInZoneCondition(Zone.BATTLEFIELD), "gain control of target creature for as long as {this} remains on the battlefield");
    game.addEffect(effect, source);
    return false;
}
Also used : SourceRemainsInZoneCondition(mage.abilities.condition.common.SourceRemainsInZoneCondition) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 2 with ConditionalContinuousEffect

use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.

the class InfernalDenizenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DynamicValue swamps = new PermanentsOnBattlefieldCount(filter);
        boolean canSac = swamps.calculate(game, source, this) > 1;
        Effect effect = new SacrificeControllerEffect(filter, 2, "Sacrifice two Swamps");
        effect.apply(game, source);
        if (!canSac) {
            if (creature != null) {
                creature.tap(source, game);
            }
            TargetOpponent targetOpp = new TargetOpponent(true);
            if (targetOpp.canChoose(source.getSourceId(), player.getId(), game) && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
                Player opponent = game.getPlayer(targetOpp.getFirstTarget());
                if (opponent != null) {
                    FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature controlled by " + player.getLogName());
                    filter2.add(new ControllerIdPredicate(player.getId()));
                    TargetCreaturePermanent targetCreature = new TargetCreaturePermanent(1, 1, filter2, true);
                    targetCreature.setTargetController(opponent.getId());
                    if (targetCreature.canChoose(source.getSourceId(), id, game) && opponent.chooseUse(Outcome.GainControl, "Gain control of a creature?", source, game) && opponent.chooseTarget(Outcome.GainControl, targetCreature, source, game)) {
                        ConditionalContinuousEffect giveEffect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, true, opponent.getId()), SourceOnBattlefieldCondition.instance, "");
                        giveEffect.setTargetPointer(new FixedTarget(targetCreature.getFirstTarget(), game));
                        game.addEffect(giveEffect, source);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 3 with ConditionalContinuousEffect

use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.

the class HomurasEssence2 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card sourceCard = game.getCard(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    if (sourceCard != null && controller != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
        ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.instance, "");
        game.addEffect(effect, source);
        controller.moveCards(sourceCard, Zone.BATTLEFIELD, source, game);
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
            // not complete correct because it should enter the battlefield flipped
            permanent.flip(game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) CopyTokenEffect(mage.abilities.effects.common.CopyTokenEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) Card(mage.cards.Card)

Example 4 with ConditionalContinuousEffect

use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.

the class FlipSourceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    Player controller = game.getPlayer(source.getControllerId());
    if (permanent != null && controller != null) {
        if (permanent.flip(game)) {
            ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.instance, "");
            game.addEffect(effect, source);
            if (!game.isSimulation()) {
                game.informPlayers(new StringBuilder(controller.getLogName()).append(" flips ").append(permanent.getName()).toString());
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect)

Example 5 with ConditionalContinuousEffect

use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.

the class InfoEffect method addCardHintToPermanentConditional.

/**
 * Add temporary card hint to permanent (visible in rules list)
 * Will be visible on conditional only
 *
 * @param game
 * @param source
 * @param permanent
 * @param cardHint
 * @param duration
 * @param condition
 */
public static void addCardHintToPermanentConditional(Game game, Ability source, Permanent permanent, Hint cardHint, Duration duration, Condition condition) {
    SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("hint"));
    ability.setRuleVisible(false);
    ability.addHint(cardHint);
    GainAbilityTargetEffect gainEffect = new GainAbilityTargetEffect(ability, duration);
    gainEffect.setTargetPointer(new FixedTarget(permanent, game));
    ConditionalContinuousEffect conditionalEffect = new ConditionalContinuousEffect(gainEffect, condition, "test");
    conditionalEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(conditionalEffect, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect)

Aggregations

ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)7 Permanent (mage.game.permanent.Permanent)4 Player (mage.players.Player)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ArrayList (java.util.ArrayList)1 Ability (mage.abilities.Ability)1 Condition (mage.abilities.condition.Condition)1 SourceHasCounterCondition (mage.abilities.condition.common.SourceHasCounterCondition)1 SourceRemainsInZoneCondition (mage.abilities.condition.common.SourceRemainsInZoneCondition)1 SourceTappedCondition (mage.abilities.condition.common.SourceTappedCondition)1 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)1 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CopyTokenEffect (mage.abilities.effects.common.CopyTokenEffect)1 SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)1