Search in sources :

Example 51 with GainAbilityTargetEffect

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

the class DawnOfTheDeadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && card != null) {
        if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            Permanent creature = game.getPermanent(card.getId());
            if (creature != null) {
                // gains haste
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTarget(creature, game));
                game.addEffect(effect, source);
                // Exile at begin of next end step
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(creature, game));
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 52 with GainAbilityTargetEffect

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

the class DauntlessBodyguardGainAbilityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourcePermanent == null) {
        return false;
    }
    MageObjectReference mor = (MageObjectReference) game.getState().getValue(sourcePermanent.getId() + "_chosenCreature");
    if (mor == null) {
        return false;
    }
    Permanent chosenPermanent = mor.getPermanent(game);
    if (chosenPermanent != null) {
        ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(chosenPermanent, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) MageObjectReference(mage.MageObjectReference)

Example 53 with GainAbilityTargetEffect

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

the class GideonBlackbladeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player == null || permanent == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Choose an ability to give to " + permanent.getLogName());
    choice.setChoices(choices);
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    Ability ability = null;
    switch(choice.getChoice()) {
        case "Vigilance":
            ability = VigilanceAbility.getInstance();
            break;
        case "Lifelink":
            ability = LifelinkAbility.getInstance();
            break;
        case "Indestructible":
            ability = IndestructibleAbility.getInstance();
            break;
    }
    if (ability != null) {
        game.addEffect(new GainAbilityTargetEffect(ability, Duration.EndOfTurn), source);
    }
    return true;
}
Also used : IndestructibleAbility(mage.abilities.keyword.IndestructibleAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) LoyaltyAbility(mage.abilities.LoyaltyAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 54 with GainAbilityTargetEffect

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

the class GhoulsNightOutTypeChangingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID controllerId = source.getControllerId();
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        Set<Card> cardsToBattlefield = new HashSet<>();
        for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                boolean creatureInGraveyard = false;
                for (UUID cardId : player.getGraveyard()) {
                    Card card = game.getCard(cardId);
                    if (card != null && card.isCreature(game)) {
                        creatureInGraveyard = true;
                        break;
                    }
                }
                if (creatureInGraveyard) {
                    FilterCreatureCard filter = new FilterCreatureCard("creature card in " + player.getName() + "'s graveyard");
                    TargetCard target = new TargetCard(Zone.GRAVEYARD, filter);
                    target.setNotTarget(true);
                    controller.chooseTarget(controllerId.equals(playerId) ? Outcome.Benefit : Outcome.Detriment, player.getGraveyard(), target, source, game);
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        cardsToBattlefield.add(card);
                    }
                }
            }
        }
        if (!cardsToBattlefield.isEmpty()) {
            controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
            cardsToBattlefield.removeIf(card -> game.getState().getZone(card.getId()) != Zone.BATTLEFIELD);
            if (!cardsToBattlefield.isEmpty()) {
                game.addEffect(new GhoulsNightOutTypeChangingEffect().setTargetPointer(new FixedTargets(cardsToBattlefield, game)), source);
                game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cardsToBattlefield, game)), source);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCard(mage.target.TargetCard) DecayedAbility(mage.abilities.keyword.DecayedAbility) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 55 with GainAbilityTargetEffect

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

the class GruesomeEncoreReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
        controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        Permanent permanent = game.getPermanent(card.getId());
        if (permanent != null) {
            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
            ExileTargetEffect exileEffect = new ExileTargetEffect();
            exileEffect.setTargetPointer(new FixedTarget(permanent, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)125 FixedTarget (mage.target.targetpointer.FixedTarget)96 Permanent (mage.game.permanent.Permanent)93 ContinuousEffect (mage.abilities.effects.ContinuousEffect)76 Player (mage.players.Player)76 Card (mage.cards.Card)42 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)28 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)22 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)21 UUID (java.util.UUID)18 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)17 Effect (mage.abilities.effects.Effect)16 OneShotEffect (mage.abilities.effects.OneShotEffect)15 FilterCard (mage.filter.FilterCard)15 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)15 TargetPermanent (mage.target.TargetPermanent)15 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)14 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)13 FilterCreatureCard (mage.filter.common.FilterCreatureCard)12 FixedTargets (mage.target.targetpointer.FixedTargets)12