Search in sources :

Example 66 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class MoltenPrimordialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetCreaturePermanent) {
            Permanent targetCreature = game.getPermanent(target.getFirstTarget());
            if (targetCreature != null) {
                ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
                effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect1, source);
                ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect2, source);
                targetCreature.untap(game);
                result = true;
            }
        }
    }
    return result;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) 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) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 67 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class NecromanticSelectionEffect 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) {
        Cards cards = new CardsImpl();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) {
            permanent.destroy(source, game, false);
            // Meren of the Clan Nel Toth bug #8515
            game.checkStateAndTriggered();
            if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                cards.add(permanent);
            }
        }
        FilterCard filter = new FilterCreatureCard("creature card put into a graveyard with " + sourceObject.getLogName());
        List<Predicate<MageObject>> cardIdPredicates = new ArrayList<>();
        for (UUID cardId : cards) {
            cardIdPredicates.add(new CardIdPredicate(cardId));
        }
        filter.add(Predicates.or(cardIdPredicates));
        Target target = new TargetCardInGraveyard(filter);
        target.setNotTarget(true);
        if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
                effect.setText("It's a black Zombie in addition to its other colors and types");
                effect.setTargetPointer(new FixedTarget(card.getId(), game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) ArrayList(java.util.ArrayList) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) Predicate(mage.filter.predicate.Predicate) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 68 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class RapidFireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && permanent != null) {
        if (!permanent.getAbilities().containsClass(RampageAbility.class)) {
            ContinuousEffect effect = new GainAbilityTargetEffect(new RampageAbility(2), Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) RampageAbility(mage.abilities.keyword.RampageAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 69 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class RohgahhOfKherKeepEffect 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) {
        return false;
    }
    Cost cost = new ManaCostsImpl("{R}{R}{R}");
    if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(Outcome.Benefit, "Pay {R}{R}{R}?", source, game) || !cost.pay(source, game, source, player.getId(), false)) {
        TargetOpponent target = new TargetOpponent();
        Player opponent = null;
        if (target.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
            opponent = game.getPlayer(target.getFirstTarget());
        }
        new TapAllEffect(filter).apply(game, source);
        if (permanent != null) {
            permanent.tap(source, game);
        }
        if (opponent != null) {
            new GainControlAllEffect(Duration.Custom, filter, opponent.getId()).apply(game, source);
            if (permanent != null) {
                ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, opponent.getId());
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : TapAllEffect(mage.abilities.effects.common.TapAllEffect) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) GainControlAllEffect(mage.abilities.effects.common.continuous.GainControlAllEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 70 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect in project mage by magefree.

the class RookieMistakeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        ContinuousEffect effect = new BoostTargetEffect(0, 2, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (permanent != null) {
        ContinuousEffect effect = new BoostTargetEffect(-2, 0, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)322 FixedTarget (mage.target.targetpointer.FixedTarget)245 Player (mage.players.Player)225 Permanent (mage.game.permanent.Permanent)202 Card (mage.cards.Card)97 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)76 UUID (java.util.UUID)65 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)55 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)50 MageObject (mage.MageObject)47 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)43 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)37 FilterCard (mage.filter.FilterCard)34 TargetPermanent (mage.target.TargetPermanent)33 Effect (mage.abilities.effects.Effect)32 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 OneShotEffect (mage.abilities.effects.OneShotEffect)30 Target (mage.target.Target)30 FilterPermanent (mage.filter.FilterPermanent)24 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)23