Search in sources :

Example 16 with GainLifeEffect

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

the class SunhomeEnforcerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        if (event.getSourceId().equals(this.sourceId)) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 17 with GainLifeEffect

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

the class NoblePurposeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        Permanent permanent = game.getPermanent(event.getSourceId());
        if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.getControllerId())) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 18 with GainLifeEffect

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

the class CurryFavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = game.getBattlefield().getAllActivePermanents(source.getControllerId()).stream().filter(permanent -> permanent != null && permanent.hasSubtype(SubType.KNIGHT, game)).mapToInt(p -> 1).sum();
    new GainLifeEffect(xValue).apply(game, source);
    new LoseLifeOpponentsEffect(xValue).apply(game, source);
    return true;
}
Also used : Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) AdventureCard(mage.cards.AdventureCard) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) UUID(java.util.UUID) MageInt(mage.MageInt) SubType(mage.constants.SubType) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) LoseLifeOpponentsEffect(mage.abilities.effects.common.LoseLifeOpponentsEffect) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) LoseLifeOpponentsEffect(mage.abilities.effects.common.LoseLifeOpponentsEffect)

Example 19 with GainLifeEffect

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

the class TolsimirFriendToWolvesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    new GainLifeEffect(3).apply(game, source);
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return true;
    }
    Permanent wolf = wolfMor.getPermanent(game);
    if (wolf == null) {
        return false;
    }
    return wolf.fight(permanent, source, game);
}
Also used : TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 20 with GainLifeEffect

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

the class VigorousChargeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        if (event.getSourceId().equals(this.sourceId)) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) 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