Search in sources :

Example 11 with GainAbilitySourceEffect

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

the class IllusionaryPresenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject mageObject = game.getObject(source.getSourceId());
    if (mageObject != null) {
        SubType landTypeChoice = SubType.byDescription((String) game.getState().getValue(mageObject.getId().toString() + "BasicLandType"));
        if (landTypeChoice != null) {
            switch(landTypeChoice) {
                case PLAINS:
                    gainedAbility = new PlainswalkAbility();
                    break;
                case FOREST:
                    gainedAbility = new ForestwalkAbility();
                    break;
                case SWAMP:
                    gainedAbility = new SwampwalkAbility();
                    break;
                case ISLAND:
                    gainedAbility = new IslandwalkAbility();
                    break;
                case MOUNTAIN:
                    gainedAbility = new MountainwalkAbility();
                    break;
            }
            if (gainedAbility != null) {
                GainAbilitySourceEffect effect = new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn);
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : IslandwalkAbility(mage.abilities.keyword.IslandwalkAbility) SubType(mage.constants.SubType) PlainswalkAbility(mage.abilities.keyword.PlainswalkAbility) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) MountainwalkAbility(mage.abilities.keyword.MountainwalkAbility) MageObject(mage.MageObject) ForestwalkAbility(mage.abilities.keyword.ForestwalkAbility) SwampwalkAbility(mage.abilities.keyword.SwampwalkAbility)

Example 12 with GainAbilitySourceEffect

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

the class ButcherOfTheHordeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Choice abilityChoice = new ChoiceImpl();
        abilityChoice.setMessage("Choose an ability to add");
        Set<String> abilities = new HashSet<>();
        abilities.add(VigilanceAbility.getInstance().getRule());
        abilities.add(LifelinkAbility.getInstance().getRule());
        abilities.add(HasteAbility.getInstance().getRule());
        abilityChoice.setChoices(abilities);
        controller.choose(Outcome.AddAbility, abilityChoice, game);
        if (!abilityChoice.isChosen()) {
            return false;
        }
        String chosen = abilityChoice.getChoice();
        Ability ability = null;
        if (VigilanceAbility.getInstance().getRule().equals(chosen)) {
            ability = VigilanceAbility.getInstance();
        } else if (LifelinkAbility.getInstance().getRule().equals(chosen)) {
            ability = LifelinkAbility.getInstance();
        } else if (HasteAbility.getInstance().getRule().equals(chosen)) {
            ability = HasteAbility.getInstance();
        }
        if (ability != null) {
            game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen: " + chosen);
            ContinuousEffect effect = new GainAbilitySourceEffect(ability, Duration.EndOfTurn);
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) HasteAbility(mage.abilities.keyword.HasteAbility) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) MageObject(mage.MageObject) ChoiceImpl(mage.choices.ChoiceImpl) ContinuousEffect(mage.abilities.effects.ContinuousEffect) HashSet(java.util.HashSet)

Example 13 with GainAbilitySourceEffect

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

the class CouncilGuardianVote method apply.

@Override
public boolean apply(Game game, Ability source) {
    CouncilGuardianVote vote = new CouncilGuardianVote();
    vote.doVotes(source, game);
    for (String color : vote.getMostVoted()) {
        if (color == null) {
            continue;
        }
        game.addEffect(new GainAbilitySourceEffect(ProtectionAbility.from(ChoiceColor.getColorFromString(color)), Duration.Custom), source);
    }
    return true;
}
Also used : GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

Example 14 with GainAbilitySourceEffect

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

the class RiotReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (creature != null && controller != null) {
        if (controller.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
            game.informPlayers(controller.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
            creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
        } else {
            game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.Custom), source);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

Example 15 with GainAbilitySourceEffect

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

the class JodahsAvengerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    if (sourceObject != null) {
        sourceObject.addPower(-1);
        sourceObject.addToughness(-1);
        game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

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