Search in sources :

Example 1 with PreventCombatDamageBySourceEffect

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

the class MtendaLionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(source.getSourceId(), game));
    if (player == null) {
        return false;
    }
    Cost cost = new ManaCostsImpl("{U}");
    if (!player.chooseUse(outcome, "Pay {U} to prevent damage?", source, game) || !cost.pay(source, game, source, player.getId(), false)) {
        return false;
    }
    game.addEffect(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) PreventCombatDamageBySourceEffect(mage.abilities.effects.common.PreventCombatDamageBySourceEffect)

Example 2 with PreventCombatDamageBySourceEffect

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

the class UrzasScienceFairProjectEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = controller.rollDice(outcome, source, game, 6);
        Effect effect = null;
        // 6 - gets +2/+2 until end of turn";
        if (amount == 1) {
            game.addEffect(new BoostSourceEffect(-2, -2, Duration.EndOfTurn), source);
        } else if (amount == 2) {
            game.addEffect(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn), source);
        } else if (amount == 3) {
            game.addEffect(new GainAbilitySourceEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn), source);
        } else if (amount == 4) {
            game.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), source);
        } else if (amount == 5) {
            game.addEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), source);
        } else if (amount == 6) {
            game.addEffect(new BoostSourceEffect(+2, +2, Duration.EndOfTurn), source);
        }
        return true;
    }
    return false;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Player(mage.players.Player) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) PreventCombatDamageBySourceEffect(mage.abilities.effects.common.PreventCombatDamageBySourceEffect) BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Effect(mage.abilities.effects.Effect) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) PreventCombatDamageBySourceEffect(mage.abilities.effects.common.PreventCombatDamageBySourceEffect)

Aggregations

PreventCombatDamageBySourceEffect (mage.abilities.effects.common.PreventCombatDamageBySourceEffect)2 Player (mage.players.Player)2 Cost (mage.abilities.costs.Cost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)1 GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)1