Search in sources :

Example 1 with SetPowerToughnessSourceEffect

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

the class FigureOfDestinyWarriorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game)) {
        return false;
    }
    game.addEffect(new AddCardSubTypeSourceEffect(Duration.Custom, SubType.KITHKIN, SubType.SPIRIT, SubType.WARRIOR, SubType.AVATAR), source);
    game.addEffect(new SetPowerToughnessSourceEffect(8, 8, Duration.Custom, SubLayer.SetPT_7b), source);
    game.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.Custom), source);
    game.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.Custom), source);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Permanent(mage.game.permanent.Permanent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) AddCardSubTypeSourceEffect(mage.abilities.effects.common.continuous.AddCardSubTypeSourceEffect)

Example 2 with SetPowerToughnessSourceEffect

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

the class DracoplasmEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (creature != null && controller != null) {
        Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);
        if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            return false;
        }
        controller.chooseTarget(Outcome.Detriment, target, source, game);
        if (!target.getTargets().isEmpty()) {
            int power = 0;
            int toughness = 0;
            for (UUID targetId : target.getTargets()) {
                Permanent targetCreature = game.getPermanent(targetId);
                if (targetCreature != null && targetCreature.sacrifice(source, game)) {
                    power = CardUtil.overflowInc(power, targetCreature.getPower().getValue());
                    toughness = CardUtil.overflowInc(toughness, targetCreature.getToughness().getValue());
                }
            }
            ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
            game.addEffect(effect, source);
        }
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 3 with SetPowerToughnessSourceEffect

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

the class GigantoplasmCopyApplier method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    DynamicValue variableMana = ManacostVariableValue.REGULAR;
    Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
    effect.setText("This creature has base power and toughness X/X");
    Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
    blueprint.getAbilities().add(ability);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) EntersBattlefieldAbility(mage.abilities.common.EntersBattlefieldAbility) Ability(mage.abilities.Ability) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) CopyPermanentEffect(mage.abilities.effects.common.CopyPermanentEffect) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Effect(mage.abilities.effects.Effect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 4 with SetPowerToughnessSourceEffect

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

the class TreeOfRedemptionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null && player.isLifeTotalCanChange()) {
        Permanent perm = game.getPermanent(source.getSourceId());
        if (perm != null) {
            int amount = perm.getToughness().getValue();
            int life = player.getLife();
            if (life == amount) {
                return false;
            }
            if (life < amount && !player.isCanGainLife()) {
                return false;
            }
            if (life > amount && !player.isCanLoseLife()) {
                return false;
            }
            player.setLife(amount, game, source);
            game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source);
            return true;
        }
    }
    return false;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 5 with SetPowerToughnessSourceEffect

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

the class WoodElementalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (controller != null && sourceCard != null) {
        Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseTarget(Outcome.Detriment, target, source, game)) {
            if (!target.getTargets().isEmpty()) {
                int sacrificedForests = target.getTargets().size();
                game.informPlayers(controller.getLogName() + " sacrifices " + sacrificedForests + " untapped Forests for " + sourceCard.getLogName());
                for (UUID targetId : target.getTargets()) {
                    Permanent targetPermanent = game.getPermanent(targetId);
                    if (targetPermanent != null) {
                        targetPermanent.sacrifice(source, game);
                    }
                }
                game.addEffect(new SetPowerToughnessSourceEffect(sacrificedForests, sacrificedForests, Duration.Custom, SubLayer.SetPT_7b), source);
                return true;
            }
        }
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) Target(mage.target.Target) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) UUID(java.util.UUID) Card(mage.cards.Card)

Aggregations

SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)16 Player (mage.players.Player)13 Permanent (mage.game.permanent.Permanent)10 Card (mage.cards.Card)4 UUID (java.util.UUID)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 Ability (mage.abilities.Ability)2 Cost (mage.abilities.costs.Cost)2 PayLifeCost (mage.abilities.costs.common.PayLifeCost)2 GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)2 EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)2 Target (mage.target.Target)2 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)2 ArrayList (java.util.ArrayList)1 EntersBattlefieldAbility (mage.abilities.common.EntersBattlefieldAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 Condition (mage.abilities.condition.Condition)1 SourceHasCounterCondition (mage.abilities.condition.common.SourceHasCounterCondition)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1