Search in sources :

Example 1 with LoseAbilityTargetEffect

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

the class WalkingSpongeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        ChoiceImpl chooseAbility = new ChoiceImpl();
        chooseAbility.setMessage("Choose an ability to remove (default is flying)");
        Set<String> choice = new LinkedHashSet<>();
        choice.add("Flying");
        choice.add("First strike");
        choice.add("Trample");
        chooseAbility.setChoices(choice);
        // since the player can't pick "no ability", let's default to the first option
        Ability ability = FlyingAbility.getInstance();
        if (controller.choose(Outcome.UnboostCreature, chooseAbility, game)) {
            String chosenAbility = chooseAbility.getChoice();
            if (chosenAbility.equals("First strike")) {
                ability = FirstStrikeAbility.getInstance();
            } else if (chosenAbility.equals("Trample")) {
                ability = TrampleAbility.getInstance();
            }
        } else {
            return false;
        }
        game.informPlayers(controller.getLogName() + " has chosen " + ability.getRule());
        ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) Ability(mage.abilities.Ability) LoseAbilityTargetEffect(mage.abilities.effects.common.continuous.LoseAbilityTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ChoiceImpl(mage.choices.ChoiceImpl) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 2 with LoseAbilityTargetEffect

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

the class UrborgEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player == null || permanent == null) {
        return false;
    }
    Ability ability;
    if (player.chooseUse(Outcome.UnboostCreature, "Which ability should be lost?", null, "First Strike", "Swampwalk", source, game)) {
        ability = FirstStrikeAbility.getInstance();
    } else {
        ability = new SwampwalkAbility();
    }
    ContinuousEffect effect = new LoseAbilityTargetEffect(ability, Duration.EndOfTurn);
    // effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) BlackManaAbility(mage.abilities.mana.BlackManaAbility) SwampwalkAbility(mage.abilities.keyword.SwampwalkAbility) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) Ability(mage.abilities.Ability) LoseAbilityTargetEffect(mage.abilities.effects.common.continuous.LoseAbilityTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SwampwalkAbility(mage.abilities.keyword.SwampwalkAbility)

Example 3 with LoseAbilityTargetEffect

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

the class BurnFromWithinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
        int amount = source.getManaCostsToPay().getX();
        if (creature != null) {
            game.addEffect(new DiesReplacementEffect(new MageObjectReference(creature, game), Duration.EndOfTurn), source);
            int damageDealt = creature.damage(amount, source.getSourceId(), source, game, false, true);
            if (damageDealt > 0) {
                ContinuousEffect effect = new LoseAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTarget(creature.getId(), game));
                game.addEffect(effect, source);
            }
            return true;
        }
        Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
        if (targetPlayer != null) {
            targetPlayer.damage(amount, source.getSourceId(), source, game);
            return true;
        }
    }
    return false;
}
Also used : DiesReplacementEffect(mage.abilities.effects.common.replacement.DiesReplacementEffect) FixedTarget(mage.target.targetpointer.FixedTarget) LoseAbilityTargetEffect(mage.abilities.effects.common.continuous.LoseAbilityTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) MageObjectReference(mage.MageObjectReference)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 LoseAbilityTargetEffect (mage.abilities.effects.common.continuous.LoseAbilityTargetEffect)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)3 Ability (mage.abilities.Ability)2 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)2 FirstStrikeAbility (mage.abilities.keyword.FirstStrikeAbility)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 LinkedHashSet (java.util.LinkedHashSet)1 MageObjectReference (mage.MageObjectReference)1 DiesReplacementEffect (mage.abilities.effects.common.replacement.DiesReplacementEffect)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 SwampwalkAbility (mage.abilities.keyword.SwampwalkAbility)1 TrampleAbility (mage.abilities.keyword.TrampleAbility)1 BlackManaAbility (mage.abilities.mana.BlackManaAbility)1 ChoiceImpl (mage.choices.ChoiceImpl)1 FixedTarget (mage.target.targetpointer.FixedTarget)1