Search in sources :

Example 11 with SetPowerToughnessSourceEffect

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

the class MinionOfTheWastesEffect 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 payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of 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) Permanent(mage.game.permanent.Permanent) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) Card(mage.cards.Card)

Example 12 with SetPowerToughnessSourceEffect

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

the class ElvishImpersonatorsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
        int firstRoll = results.get(0);
        int secondRoll = results.get(1);
        game.addEffect(new SetPowerToughnessSourceEffect(firstRoll, secondRoll, Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source);
        return true;
    }
    return false;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player)

Example 13 with SetPowerToughnessSourceEffect

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

the class EvraHalcyonWitnessEffect 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.getPower().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(life, Integer.MIN_VALUE, 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 14 with SetPowerToughnessSourceEffect

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

the class TrenchGorgerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterLandCard("any number of land cards"));
        target.choose(outcome, controller.getId(), controller.getId(), game);
        int count = 0;
        for (UUID cardId : target.getTargets()) {
            Card card = game.getCard(cardId);
            if (card != null) {
                controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.LIBRARY, true);
                count++;
            }
        }
        controller.shuffleLibrary(source, game);
        game.addEffect(new SetPowerToughnessSourceEffect(count, count, Duration.EndOfGame, SubLayer.SetPT_7b), source);
        return true;
    }
    return false;
}
Also used : SetPowerToughnessSourceEffect(mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect) Player(mage.players.Player) FilterLandCard(mage.filter.common.FilterLandCard) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterLandCard(mage.filter.common.FilterLandCard) Card(mage.cards.Card)

Example 15 with SetPowerToughnessSourceEffect

use of mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect 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

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