Search in sources :

Example 6 with ConditionalContinuousEffect

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

the class PreacherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && sourcePermanent != null && targetPermanent != null) {
        SourceTappedCondition sourceTappedCondition = SourceTappedCondition.TAPPED;
        ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), sourceTappedCondition, "Gain control of target creature of an opponent's choice that they control for as long as {this} remains tapped");
        effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponentsChoicePermanent(mage.target.common.TargetOpponentsChoicePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SourceTappedCondition(mage.abilities.condition.common.SourceTappedCondition) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 7 with ConditionalContinuousEffect

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

the class LevelerCardBuilder method build.

/**
 * Main method constructing ability.
 *
 * @return
 */
public List<Ability> build() {
    List<Ability> constructed = new ArrayList<>();
    Condition condition = new SourceHasCounterCondition(CounterType.LEVEL, level1, level2);
    for (Ability ability : abilities) {
        ContinuousEffect effect = new GainAbilitySourceEffect(ability);
        ConditionalContinuousEffect abEffect = new ConditionalContinuousEffect(effect, condition, "");
        Ability staticAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, abEffect);
        staticAbility.setRuleVisible(false);
        constructed.add(staticAbility);
    }
    ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
    ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule);
    constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect));
    return constructed;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) SourceHasCounterCondition(mage.abilities.condition.common.SourceHasCounterCondition) Condition(mage.abilities.condition.Condition) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ArrayList(java.util.ArrayList) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SourceHasCounterCondition(mage.abilities.condition.common.SourceHasCounterCondition) 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