Search in sources :

Example 1 with SourceHasCounterCondition

use of mage.abilities.condition.common.SourceHasCounterCondition in project mage by magefree.

the class GlyphOfDelusionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (source.getTargets().get(1) != null) {
        Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
        if (targetPermanent != null) {
            targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
            SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(), new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));
            GainAbilityTargetEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
            effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
            game.addEffect(effect, source);
            BeginningOfUpkeepTriggeredAbility ability2 = new BeginningOfUpkeepTriggeredAbility(new RemoveCounterSourceEffect(CounterType.GLYPH.createInstance()), TargetController.YOU, false);
            GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(ability2, Duration.Custom);
            effect2.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
            game.addEffect(effect2, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DontUntapInControllersUntapStepSourceEffect(mage.abilities.effects.common.DontUntapInControllersUntapStepSourceEffect) SourceHasCounterCondition(mage.abilities.condition.common.SourceHasCounterCondition) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Example 2 with SourceHasCounterCondition

use of mage.abilities.condition.common.SourceHasCounterCondition 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

SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 SourceHasCounterCondition (mage.abilities.condition.common.SourceHasCounterCondition)2 ArrayList (java.util.ArrayList)1 Ability (mage.abilities.Ability)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 Condition (mage.abilities.condition.Condition)1 ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)1 ConditionalContinuousRuleModifyingEffect (mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 DontUntapInControllersUntapStepSourceEffect (mage.abilities.effects.common.DontUntapInControllersUntapStepSourceEffect)1 GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)1 RemoveCounterSourceEffect (mage.abilities.effects.common.counter.RemoveCounterSourceEffect)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 TargetPermanent (mage.target.TargetPermanent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1