Search in sources :

Example 6 with SetPowerToughnessSourceEffect

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

the class MasterOfWindsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int power = player.chooseUse(Outcome.Neutral, "Have this creature become a 4/1 or a 1/4?", null, "4/1", "1/4", source, game) ? 4 : 1;
    game.addEffect(new SetPowerToughnessSourceEffect(power, 5 - power, Duration.EndOfTurn, SubLayer.SetPT_7b), source);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player)

Example 7 with SetPowerToughnessSourceEffect

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

the class NamelessRaceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller == null || permanent == null) {
        return false;
    }
    int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null);
    int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null);
    int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife());
    int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game);
    Cost cost = new PayLifeCost(payAmount);
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    Card sourceCard = game.getCard(source.getSourceId());
    game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life");
    game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a), source);
    permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) Cost(mage.abilities.costs.Cost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 8 with SetPowerToughnessSourceEffect

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

the class AquamorphEntityReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent permanent;
    if (event instanceof EntersTheBattlefieldEvent) {
        permanent = ((EntersTheBattlefieldEvent) event).getTarget();
    } else {
        permanent = game.getPermanent(event.getTargetId());
    }
    if (permanent == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Choose what the creature becomes to");
    choice.getChoices().add(choice51);
    choice.getChoices().add(choice15);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) {
        discard();
        return false;
    }
    int power = 0;
    int toughness = 0;
    switch(choice.getChoice()) {
        case choice51:
            power = 5;
            toughness = 1;
            break;
        case choice15:
            power = 1;
            toughness = 5;
            break;
    }
    game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
    return true;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) ChoiceImpl(mage.choices.ChoiceImpl)

Example 9 with SetPowerToughnessSourceEffect

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

the class SwornDefenderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (controller != null && targetPermanent != null) {
        int newPower = CardUtil.overflowDec(targetPermanent.getToughness().getValue(), 1);
        int newToughness = CardUtil.overflowInc(targetPermanent.getPower().getValue(), 1);
        game.addEffect(new SetPowerToughnessSourceEffect(newPower, newToughness, Duration.EndOfTurn, 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) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Example 10 with SetPowerToughnessSourceEffect

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

the class ShapeStealerEffect 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 SetPowerToughnessSourceEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn, SubLayer.SetPT_7b);
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

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