Search in sources :

Example 96 with GainAbilityTargetEffect

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

the class OffspringsRevengeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, false, false, null, 1, 1, false);
    effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
    player.moveCards(card, Zone.EXILED, source, game);
    effect.apply(game, source);
    effect.getAddedPermanents().stream().forEach(permanent -> {
        ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
        continuousEffect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(continuousEffect, source);
    });
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 97 with GainAbilityTargetEffect

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

the class PrismaticBoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(ProtectionAbility.from(choice.getColor()), Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 98 with GainAbilityTargetEffect

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

the class TidalFlatsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Player player = game.getPlayer(game.getActivePlayerId());
    if (player == null) {
        return false;
    }
    Cost cost = new ManaCostsImpl("{1}");
    List<Permanent> affectedPermanents = new ArrayList<>();
    for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
        cost.clearPaid();
        String message = "Pay " + cost.getText() + " for " + permanent.getLogName() + "? If you don't, creatures " + controller.getLogName() + " controls blocking it gain first strike until end of turn.";
        if (player.chooseUse(Outcome.Benefit, message, source, game)) {
            if (cost.pay(source, game, source, player.getId(), false, null)) {
                game.informPlayers(player.getLogName() + " paid " + cost.getText() + " for " + permanent.getLogName());
            } else {
                game.informPlayers(player.getLogName() + " didn't pay " + cost.getText() + " for " + permanent.getLogName());
                affectedPermanents.add(permanent);
            }
        } else {
            game.informPlayers(player.getLogName() + " didn't pay " + cost.getText() + " for " + permanent.getLogName());
            affectedPermanents.add(permanent);
        }
    }
    for (Permanent permanent : affectedPermanents) {
        CombatGroup group = game.getCombat().findGroup(permanent.getId());
        if (group != null) {
            for (UUID blockerId : group.getBlockers()) {
                Permanent blocker = game.getPermanent(blockerId);
                if (blocker != null && Objects.equals(blocker.getControllerId(), controller.getId())) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(blocker.getId(), game));
                    game.addEffect(effect, source);
                }
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) CombatGroup(mage.game.combat.CombatGroup)

Example 99 with GainAbilityTargetEffect

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

the class UrzasEngineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent != null) {
        for (UUID bandedId : sourcePermanent.getBandedCards()) {
            Permanent banded = game.getPermanent(bandedId);
            if (banded != null && banded.isAttacking() && banded.getBandedCards() != null && banded.getBandedCards().contains(sourcePermanent.getId())) {
                GainAbilityTargetEffect effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTarget(bandedId, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) UUID(java.util.UUID)

Example 100 with GainAbilityTargetEffect

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

the class WarrenWeirdingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player == null) {
        return false;
    }
    FilterControlledPermanent filter = new FilterControlledPermanent("creature");
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ControllerIdPredicate(player.getId()));
    TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
    // had, if thats the case this ability should fizzle.
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            permanent.sacrifice(source, game);
            if (filterGoblin.match(permanent, game)) {
                for (int i = 0; i < 2; i++) {
                    Token token = new GoblinRogueToken();
                    Effect effect = new CreateTokenTargetEffect(token);
                    effect.setTargetPointer(new FixedTarget(player.getId()));
                    if (effect.apply(game, source)) {
                        Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
                        if (tokenPermanent != null) {
                            ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                            hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
                            game.addEffect(hasteEffect, source);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) Token(mage.game.permanent.token.Token) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) GoblinRogueToken(mage.game.permanent.token.GoblinRogueToken) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

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