Search in sources :

Example 21 with GainAbilityTargetEffect

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

the class RhythmOfTheWildEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player player = game.getPlayer(source.getControllerId());
    if (creature == null || player == null) {
        return false;
    }
    if (player.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(player.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
        creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
    } else {
        ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
        effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
        game.addEffect(effect, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 22 with GainAbilityTargetEffect

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

the class RideDownEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent blockingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (blockingCreature != null) {
            for (CombatGroup combatGroup : game.getCombat().getGroups()) {
                if (combatGroup.getBlockers().contains(blockingCreature.getId())) {
                    for (UUID attackerId : combatGroup.getAttackers()) {
                        ContinuousEffect effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
                        effect.setTargetPointer(new FixedTarget(attackerId, game));
                        game.addEffect(effect, source);
                    }
                    break;
                }
            }
            blockingCreature.destroy(source, game, false);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CombatGroup(mage.game.combat.CombatGroup)

Example 23 with GainAbilityTargetEffect

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

the class ShowOfDominanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int highestPower = Integer.MIN_VALUE;
        Permanent selectedCreature = null;
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), game)) {
            if (highestPower < permanent.getPower().getValue()) {
                highestPower = permanent.getPower().getValue();
                selectedCreature = permanent;
            } else if (highestPower == permanent.getPower().getValue()) {
                highestPower = permanent.getPower().getValue();
                selectedCreature = null;
            }
        }
        if (highestPower != Integer.MIN_VALUE) {
            if (selectedCreature == null) {
                FilterPermanent filter = new FilterCreaturePermanent("creature with power " + highestPower);
                filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, highestPower));
                Target target = new TargetPermanent(1, 1, filter, true);
                if (controller.chooseTarget(outcome, target, source, game)) {
                    selectedCreature = game.getPermanent(target.getFirstTarget());
                }
            }
            if (selectedCreature != null) {
                FixedTarget target = new FixedTarget(selectedCreature.getId(), game);
                Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(4));
                effect.setTargetPointer(target);
                effect.apply(game, source);
                ContinuousEffect continuousEffect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
                continuousEffect.setTargetPointer(target);
                game.addEffect(continuousEffect, source);
                return true;
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 24 with GainAbilityTargetEffect

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

the class TreacherousUrgeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (opponent != null && sourceObject != null) {
        opponent.revealCards(sourceObject.getName(), opponent.getHand(), game);
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            int cardsHand = opponent.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game);
            Card card = null;
            if (cardsHand > 0) {
                TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
                if (controller.choose(Outcome.Benefit, opponent.getHand(), target, game)) {
                    card = opponent.getHand().get(target.getFirstTarget(), game);
                    if (card != null) {
                        if (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);
                                SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
                                sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                                game.addDelayedTriggeredAbility(delayedAbility, source);
                                return true;
                            }
                        }
                    }
                    return false;
                }
            }
        }
        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) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 25 with GainAbilityTargetEffect

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

the class BesmirchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (game.getPermanent(source.getFirstTarget()) != null) {
        TargetPointer target = new FixedTarget(source.getFirstTarget(), game);
        // gain control
        game.addEffect(new GainControlTargetEffect(Duration.EndOfTurn).setTargetPointer(target), source);
        // haste
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(target), source);
        // goad
        game.addEffect(new GoadTargetEffect().setTargetPointer(target), source);
        // untap
        new UntapTargetEffect().setTargetPointer(target).apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) TargetPointer(mage.target.targetpointer.TargetPointer) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) GoadTargetEffect(mage.abilities.effects.common.combat.GoadTargetEffect)

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