Search in sources :

Example 11 with GainAbilityControlledEffect

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

the class AngelicSkirmisherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        Choice abilityChoice = new ChoiceImpl(true);
        Set<String> abilityChoices = new HashSet<>(3);
        abilityChoice.setMessage("Choose ability for your creatures");
        abilityChoices.add("First strike");
        abilityChoices.add("Vigilance");
        abilityChoices.add("Lifelink");
        abilityChoice.setChoices(abilityChoices);
        if (controller.choose(outcome, abilityChoice, game)) {
            Ability ability = null;
            switch(abilityChoice.getChoice()) {
                case "First strike":
                    ability = FirstStrikeAbility.getInstance();
                    break;
                case "Vigilance":
                    ability = VigilanceAbility.getInstance();
                    break;
                case "Lifelink":
                    ability = LifelinkAbility.getInstance();
                    break;
                default:
                    break;
            }
            if (ability != null) {
                GainAbilityControlledEffect effect = new GainAbilityControlledEffect(ability, Duration.EndOfTurn, new FilterControlledCreaturePermanent());
                game.addEffect(effect, source);
                game.informPlayers(sourcePermanent.getName() + ": " + controller.getLogName() + " has chosen " + abilityChoice.getChoice().toLowerCase(Locale.ENGLISH));
                return true;
            }
        }
    }
    return false;
}
Also used : BeginningOfCombatTriggeredAbility(mage.abilities.common.BeginningOfCombatTriggeredAbility) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ChoiceImpl(mage.choices.ChoiceImpl) HashSet(java.util.HashSet)

Aggregations

GainAbilityControlledEffect (mage.abilities.effects.common.continuous.GainAbilityControlledEffect)11 Permanent (mage.game.permanent.Permanent)5 Ability (mage.abilities.Ability)4 BoostControlledEffect (mage.abilities.effects.common.continuous.BoostControlledEffect)4 Player (mage.players.Player)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 GainAbilityControllerEffect (mage.abilities.effects.common.continuous.GainAbilityControllerEffect)3 FlyingAbility (mage.abilities.keyword.FlyingAbility)3 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 BeginningOfCombatTriggeredAbility (mage.abilities.common.BeginningOfCombatTriggeredAbility)2 ConditionalInterveningIfTriggeredAbility (mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)2 FilterCard (mage.filter.FilterCard)2 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)2 HashSet (java.util.HashSet)1 MageObject (mage.MageObject)1 ObjectColor (mage.ObjectColor)1 EntersBattlefieldTriggeredAbility (mage.abilities.common.EntersBattlefieldTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1