Search in sources :

Example 16 with GainAbilitySourceEffect

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

the class FlowstoneSculptureEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose ability to add");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        String chosen = choice.getChoice();
        if (chosen.equals("+1/+1 counter")) {
            return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
        } else {
            Ability gainedAbility;
            switch(chosen) {
                case "Flying":
                    gainedAbility = FlyingAbility.getInstance();
                    break;
                case "First strike":
                    gainedAbility = FirstStrikeAbility.getInstance();
                    break;
                default:
                    gainedAbility = TrampleAbility.getInstance();
                    break;
            }
            game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source);
            return true;
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 17 with GainAbilitySourceEffect

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

the class GargantuanGorillaFightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
        SacrificeTargetCost cost = new SacrificeTargetCost(target);
        if (!controller.chooseUse(Outcome.Benefit, "Sacrifice a Forest?", source, game) || !cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
            sourcePermanent.sacrifice(source, game);
            controller.damage(7, sourcePermanent.getId(), source, game);
        } else if (cost.isPaid()) {
            for (Permanent permanent : cost.getPermanents()) {
                if (filterSnow.match(permanent, game)) {
                    game.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn), source);
                    break;
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

Example 18 with GainAbilitySourceEffect

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

the class GuileSonicSoldierEffect method makeAbility.

private static final ReflexiveTriggeredAbility makeAbility() {
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(4), false);
    ability.addTarget(new TargetAnyTarget());
    Mode mode = new Mode(new GainAbilitySourceEffect(LifelinkAbility.getInstance(), Duration.EndOfTurn).setText("{this} gains lifelink"));
    mode.addEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn).setText("and indestructible until end of turn"));
    ability.withFirstModeFlavorWord("Sonic Boom").addMode(mode.withFlavorWord("Flash Kick"));
    return ability;
}
Also used : GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) Mode(mage.abilities.Mode) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 19 with GainAbilitySourceEffect

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

the class LunarAvengerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose ability to add");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        Ability gainedAbility;
        String chosen = choice.getChoice();
        switch(chosen) {
            case "Flying":
                gainedAbility = FlyingAbility.getInstance();
                break;
            case "First strike":
                gainedAbility = FirstStrikeAbility.getInstance();
                break;
            default:
                gainedAbility = HasteAbility.getInstance();
                break;
        }
        game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) SunburstAbility(mage.abilities.keyword.SunburstAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 20 with GainAbilitySourceEffect

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

the class ShiftingCeratopsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Choose an ability");
    choice.setChoices(choices);
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    Ability ability = null;
    switch(choice.getChoice()) {
        case "Reach":
            ability = ReachAbility.getInstance();
            break;
        case "Trample":
            ability = TrampleAbility.getInstance();
            break;
        case "Haste":
            ability = HasteAbility.getInstance();
            break;
    }
    if (ability != null) {
        game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
    }
    return true;
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) CantBeCounteredSourceAbility(mage.abilities.common.CantBeCounteredSourceAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ReachAbility(mage.abilities.keyword.ReachAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Aggregations

GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)33 Player (mage.players.Player)21 Permanent (mage.game.permanent.Permanent)11 Ability (mage.abilities.Ability)9 MageObject (mage.MageObject)7 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)6 ChoiceImpl (mage.choices.ChoiceImpl)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)5 Choice (mage.choices.Choice)5 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)4 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 FirstStrikeAbility (mage.abilities.keyword.FirstStrikeAbility)3 FlyingAbility (mage.abilities.keyword.FlyingAbility)3 HasteAbility (mage.abilities.keyword.HasteAbility)3 TrampleAbility (mage.abilities.keyword.TrampleAbility)3 HashSet (java.util.HashSet)2 AddCardSubTypeSourceEffect (mage.abilities.effects.common.continuous.AddCardSubTypeSourceEffect)2 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)2 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2