Search in sources :

Example 1 with GainLifeTargetEffect

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

the class KravTheUnredeemedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = GetXValue.instance.calculate(game, source, this);
    new DrawCardTargetEffect(xValue).apply(game, source);
    new GainLifeTargetEffect(xValue).apply(game, source);
    new AddCountersSourceEffect(CounterType.P1P1.createInstance(xValue)).apply(game, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect)

Example 2 with GainLifeTargetEffect

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

the class FieldsOfSummerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Plane cPlane = game.getState().getCurrentPlane();
    if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_FIELDS_OF_SUMMER)) {
        return false;
    }
    Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (owner != null && owner.canRespond() && owner.chooseUse(Outcome.Benefit, "Gain 2 life?", source, game)) {
        Effect effect = new GainLifeTargetEffect(2);
        effect.setTargetPointer(new FixedTarget(owner.getId())).apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Plane(mage.game.command.Plane) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect) RollPlanarDieEffect(mage.abilities.effects.common.RollPlanarDieEffect) PlanarDieRollCostIncreasingEffect(mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) Effect(mage.abilities.effects.Effect) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect)

Example 3 with GainLifeTargetEffect

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

the class CurseOfVitalityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new GainLifeTargetEffect(2);
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) GainLifeTargetEffect(mage.abilities.effects.common.GainLifeTargetEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Aggregations

GainLifeTargetEffect (mage.abilities.effects.common.GainLifeTargetEffect)3 Effect (mage.abilities.effects.Effect)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 Player (mage.players.Player)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 AttachEffect (mage.abilities.effects.common.AttachEffect)1 DrawCardTargetEffect (mage.abilities.effects.common.DrawCardTargetEffect)1 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)1 RollPlanarDieEffect (mage.abilities.effects.common.RollPlanarDieEffect)1 PlanarDieRollCostIncreasingEffect (mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 Plane (mage.game.command.Plane)1 Permanent (mage.game.permanent.Permanent)1 TargetPlayer (mage.target.TargetPlayer)1