Search in sources :

Example 6 with SetPowerToughnessTargetEffect

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

the class EldraziMimicEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (permanent != null) {
            ContinuousEffect effect = new SetPowerToughnessTargetEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect)

Example 7 with SetPowerToughnessTargetEffect

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

the class RiseAndShineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(RiseAndShine.filter, source.getControllerId(), source.getSourceId(), game);
    if (permanents.isEmpty()) {
        return false;
    }
    game.addEffect(new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE).setTargetPointer(new FixedTargets(permanents, game)), source);
    game.addEffect(new SetPowerToughnessTargetEffect(0, 0, Duration.EndOfGame).setTargetPointer(new FixedTargets(permanents, game)), source);
    for (Permanent permanent : permanents) {
        permanent.addCounters(CounterType.P1P1.createInstance(4), source.getControllerId(), source, game);
    }
    return true;
}
Also used : FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) AddCardTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardTypeTargetEffect)

Example 8 with SetPowerToughnessTargetEffect

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

the class SereneMasterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourceCreature = game.getPermanent(source.getSourceId());
    if (controller != null && sourceCreature != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature it's blocking");
        filter.add(new BlockedByIdPredicate((source.getSourceId())));
        Target target = new TargetCreaturePermanent(filter);
        if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
            if (controller.chooseTarget(outcome, target, source, game)) {
                Permanent attackingCreature = game.getPermanent(target.getFirstTarget());
                if (attackingCreature != null) {
                    int newSourcePower = attackingCreature.getPower().getValue();
                    int newAttackerPower = sourceCreature.getPower().getValue();
                    ContinuousEffect effect = new SetPowerToughnessTargetEffect(newSourcePower, sourceCreature.getToughness().getValue(), Duration.EndOfCombat);
                    effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
                    game.addEffect(effect, source);
                    effect = new SetPowerToughnessTargetEffect(newAttackerPower, attackingCreature.getToughness().getValue(), Duration.EndOfCombat);
                    effect.setTargetPointer(new FixedTarget(attackingCreature.getId(), game));
                    game.addEffect(effect, source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) BlockedByIdPredicate(mage.filter.predicate.permanent.BlockedByIdPredicate)

Example 9 with SetPowerToughnessTargetEffect

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

the class ExuberantWolfbearEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    game.addEffect(new SetPowerToughnessTargetEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn), source);
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect)

Example 10 with SetPowerToughnessTargetEffect

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

the class IslandOfWakWakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(source.getFirstTarget());
    if (targetCreature != null) {
        int toughness = targetCreature.getToughness().getBaseValueModified();
        game.addEffect(new SetPowerToughnessTargetEffect(0, toughness, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect)

Aggregations

SetPowerToughnessTargetEffect (mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect)10 Permanent (mage.game.permanent.Permanent)7 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 Player (mage.players.Player)4 AddCardTypeTargetEffect (mage.abilities.effects.common.continuous.AddCardTypeTargetEffect)3 FilterPermanent (mage.filter.FilterPermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 TargetPermanent (mage.target.TargetPermanent)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 FilterControlledArtifactPermanent (mage.filter.common.FilterControlledArtifactPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 Collection (java.util.Collection)1 Objects (java.util.Objects)1 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)1 AddCardSubTypeTargetEffect (mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 FilterArtifactPermanent (mage.filter.common.FilterArtifactPermanent)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1