Search in sources :

Example 16 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class InfiniteAuthorityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (aura != null) {
        Permanent enchantedCreature = game.getPermanentOrLKIBattlefield(aura.getAttachedTo());
        if (enchantedCreature != null) {
            Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                if (permanent.destroy(source, game, false)) {
                    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
                    delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(enchantedCreature, game));
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 17 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class ScavengeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getSourceId());
    if (card != null) {
        int count = card.getPower().getValue();
        if (count > 0) {
            Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(count));
            effect.setTargetPointer(getTargetPointer());
            return effect.apply(game, source);
        }
    }
    return false;
}
Also used : AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Card(mage.cards.Card)

Example 18 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class EdgeOfMalacolEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    // Prevent untap event of creatures of target player
    if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
        Plane cPlane = game.getState().getCurrentPlane();
        if (cPlane == null) {
            return false;
        }
        if (!cPlane.getPlaneType().equals(Planes.PLANE_EDGE_OF_MALACOL)) {
            return false;
        }
        Permanent permanent = game.getPermanent(event.getTargetId());
        if (filter.match(permanent, game) && Objects.equals(permanent.getControllerId(), game.getActivePlayerId())) {
            UUID oldController = source.getControllerId();
            source.setControllerId(game.getActivePlayerId());
            Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2));
            effect.setTargetPointer(new FixedTarget(permanent, game));
            effect.apply(game, source);
            source.setControllerId(oldController);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) Plane(mage.game.command.Plane) RollPlanarDieEffect(mage.abilities.effects.common.RollPlanarDieEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) PlanarDieRollCostIncreasingEffect(mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect) Effect(mage.abilities.effects.Effect) UntapAllControllerEffect(mage.abilities.effects.common.UntapAllControllerEffect) UUID(java.util.UUID) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 19 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class MaintenanceDroidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose mode");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        String chosen = choice.getChoice();
        switch(chosen) {
            case "Remove a repair counter":
                new RemoveCounterTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
                break;
            default:
                // "Add another repair counter"
                new AddCountersTargetEffect(CounterType.REPAIR.createInstance()).apply(game, source);
                break;
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) RemoveCounterTargetEffect(mage.abilities.effects.common.counter.RemoveCounterTargetEffect) ChoiceImpl(mage.choices.ChoiceImpl) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 20 with AddCountersTargetEffect

use of mage.abilities.effects.common.counter.AddCountersTargetEffect in project mage by magefree.

the class DreadWightCounterCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent != null) {
        // add paralyzation counter
        Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        // tap permanent
        permanent.tap(source, game);
        // does not untap while paralyzation counter is on it
        ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(Duration.WhileOnBattlefield, permanent.getId());
        effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
        Condition condition = new DreadWightCounterCondition(permanent.getId());
        ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(effect2, condition);
        Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, conditionalEffect);
        ContinuousEffect effect3 = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
        ability.setRuleVisible(true);
        effect3.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect3, source);
        // each gains 4: remove paralyzation counter
        Ability activatedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()), new ManaCostsImpl("{4}"));
        ContinuousEffect effect4 = new GainAbilityTargetEffect(activatedAbility, Duration.WhileOnBattlefield);
        effect4.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect4, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Condition(mage.abilities.condition.Condition) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ConditionalContinuousRuleModifyingEffect(mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect) ContinuousRuleModifyingEffect(mage.abilities.effects.ContinuousRuleModifyingEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect)

Aggregations

AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)36 FixedTarget (mage.target.targetpointer.FixedTarget)27 Permanent (mage.game.permanent.Permanent)24 Effect (mage.abilities.effects.Effect)21 OneShotEffect (mage.abilities.effects.OneShotEffect)18 Player (mage.players.Player)18 Card (mage.cards.Card)7 UUID (java.util.UUID)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)6 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 Target (mage.target.Target)5 TargetPermanent (mage.target.TargetPermanent)5 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)4 Ability (mage.abilities.Ability)3 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)3