Search in sources :

Example 1 with GainLifeEffect

use of mage.abilities.effects.common.GainLifeEffect in project mage by magefree.

the class LuminescentRainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) {
        FilterControlledPermanent filter = new FilterControlledPermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 2 with GainLifeEffect

use of mage.abilities.effects.common.GainLifeEffect in project mage by magefree.

the class RighteousFuryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int destroyedCreature = 0;
        FilterCreaturePermanent filter = new FilterCreaturePermanent("all tapped creatures");
        filter.add(TappedPredicate.TAPPED);
        for (Permanent creature : game.getState().getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
            if (creature.destroy(source, game, false)) {
                destroyedCreature++;
            }
        }
        if (destroyedCreature > 0) {
            new GainLifeEffect(destroyedCreature * 2).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 3 with GainLifeEffect

use of mage.abilities.effects.common.GainLifeEffect in project mage by magefree.

the class ScentOfJasmineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new GainLifeEffect(2 * xValue).apply(game, source);
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 4 with GainLifeEffect

use of mage.abilities.effects.common.GainLifeEffect in project mage by magefree.

the class TrevaTheRenewerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (controller.choose(outcome, choice, game)) {
        game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
        if (cardsWithColor > 0) {
            new GainLifeEffect(cardsWithColor).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ChoiceColor(mage.choices.ChoiceColor) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 5 with GainLifeEffect

use of mage.abilities.effects.common.GainLifeEffect in project mage by magefree.

the class JasmineSeerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new GainLifeEffect(2 * xValue).apply(game, source);
}
Also used : RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) TargetCardInHand(mage.target.common.TargetCardInHand) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Aggregations

GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)27 Permanent (mage.game.permanent.Permanent)11 Ability (mage.abilities.Ability)7 LeavesBattlefieldTriggeredAbility (mage.abilities.common.LeavesBattlefieldTriggeredAbility)6 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)6 Player (mage.players.Player)6 Test (org.junit.Test)6 DamagedEvent (mage.game.events.DamagedEvent)5 UUID (java.util.UUID)4 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)4 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)4 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)4 RevealTargetFromHandCost (mage.abilities.costs.common.RevealTargetFromHandCost)2 Choice (mage.choices.Choice)2 TargetCardInHand (mage.target.common.TargetCardInHand)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 ArrayList (java.util.ArrayList)1 MageInt (mage.MageInt)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)1