Search in sources :

Example 91 with ContinuousEffect

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

the class SaheeliSublimeArtificerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent copyTo = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (copyTo != null) {
        Permanent copyFrom = game.getPermanentOrLKIBattlefield(source.getTargets().get(1).getFirstTarget());
        if (copyFrom != null) {
            game.copyPermanent(Duration.EndOfTurn, copyFrom, copyTo.getId(), source, new EmptyCopyApplier());
            ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT);
            effect.setTargetPointer(new FixedTarget(copyTo, game));
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCardTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardTypeTargetEffect)

Example 92 with ContinuousEffect

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

the class StrefanMaurerProgenitorPlayVampireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInHand(0, 1, vampireCardFilter);
    if (!player.choose(outcome, player.getHand(), target, game)) {
        return false;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    game.getCombat().addAttackingCreature(permanent.getId(), game);
    // Gains indestructable until end of turn
    ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
    game.addEffect(effect, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) TargetCardInHand(mage.target.common.TargetCardInHand) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 93 with ContinuousEffect

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

the class TemporalApertureTopCardCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.shuffleLibrary(source, game);
        Card topCard = controller.getLibrary().getFromTop(game);
        if (topCard != null) {
            Cards cards = new CardsImpl(topCard);
            controller.revealCards("Top card of " + controller.getName() + "'s library revealed", cards, game);
            ContinuousEffect effect = new TemporalApertureTopCardCastEffect(topCard);
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 94 with ContinuousEffect

use of mage.abilities.effects.ContinuousEffect 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 95 with ContinuousEffect

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

the class WakeToSlaughterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Cards pickedCards = new CardsImpl(getTargetPointer().getTargets(game, source));
    if (player != null && !pickedCards.isEmpty()) {
        Card cardToHand;
        if (pickedCards.size() == 1) {
            cardToHand = pickedCards.getRandom(game);
        } else {
            Player opponent;
            Set<UUID> opponents = game.getOpponents(player.getId());
            if (opponents.size() == 1) {
                opponent = game.getPlayer(opponents.iterator().next());
            } else {
                Target targetOpponent = new TargetOpponent(true);
                player.chooseTarget(Outcome.Detriment, targetOpponent, source, game);
                opponent = game.getPlayer(targetOpponent.getFirstTarget());
            }
            TargetCard target = new TargetCard(1, Zone.GRAVEYARD, new FilterCard());
            target.withChooseHint("Card to go to opponent's hand (other goes to battlefield)");
            opponent.chooseTarget(outcome, pickedCards, target, source, game);
            cardToHand = game.getCard(target.getFirstTarget());
        }
        for (Card card : pickedCards.getCards(game)) {
            if (card == cardToHand) {
                player.moveCards(cardToHand, Zone.HAND, source, game);
            } else {
                player.moveCards(card, Zone.BATTLEFIELD, source, game);
                FixedTarget fixedTarget = new FixedTarget(card, game);
                ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfGame);
                effect.setTargetPointer(fixedTarget);
                game.addEffect(effect, source);
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(fixedTarget);
                DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
                game.addDelayedTriggeredAbility(delayedAbility, source);
            }
        }
        pickedCards.clear();
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

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