Search in sources :

Example 66 with Player

use of mage.players.Player in project mage by magefree.

the class EllywickTumblestrumEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6));
    TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_CREATURE);
    player.choose(outcome, cards, target, game);
    Card card = cards.get(target.getFirstTarget(), game);
    if (card != null) {
        player.revealCards(source, new CardsImpl(card), game);
        player.moveCards(card, Zone.HAND, source, game);
        cards.remove(card);
        if (card.isLegendary()) {
            player.gainLife(3, game, source);
        }
    }
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 67 with Player

use of mage.players.Player in project mage by magefree.

the class ElkinLairPutIntoGraveyardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player != null && sourcePermanent != null) {
        Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]);
        if (cards.length > 0) {
            Card card = cards[RandomUtil.nextInt(cards.length)];
            if (card != null) {
                String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
                player.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
                if (game.getState().getZone(card.getId()) == Zone.EXILED) {
                    ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(card, game));
                    game.addEffect(effect, source);
                    DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
                    game.addDelayedTriggeredAbility(delayed, source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 68 with Player

use of mage.players.Player in project mage by magefree.

the class EligethCrossroadsAugurReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    // original event is not a draw event, so skip it in params
    player.drawCards(event.getAmount(), source, game);
    return true;
}
Also used : Player(mage.players.Player)

Example 69 with Player

use of mage.players.Player in project mage by magefree.

the class ElkinBottleCastFromExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            controller.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
            ContinuousEffect effect = new ElkinBottleCastFromExileEffect();
            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) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 70 with Player

use of mage.players.Player in project mage by magefree.

the class EmberwildeDjinnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
    if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
        if (cost.pay(source, game, source, player.getId(), false)) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
            effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
            game.addEffect(effect, source);
            player.resetStoredBookmark(game);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) OrCost(mage.abilities.costs.OrCost) MageObject(mage.MageObject) PayLifeCost(mage.abilities.costs.common.PayLifeCost) ContinuousEffect(mage.abilities.effects.ContinuousEffect) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Cost(mage.abilities.costs.Cost) OrCost(mage.abilities.costs.OrCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Aggregations

Player (mage.players.Player)3909 Permanent (mage.game.permanent.Permanent)1705 Card (mage.cards.Card)1099 UUID (java.util.UUID)962 MageObject (mage.MageObject)556 FilterCard (mage.filter.FilterCard)515 CardsImpl (mage.cards.CardsImpl)498 FixedTarget (mage.target.targetpointer.FixedTarget)387 TargetPermanent (mage.target.TargetPermanent)353 Cards (mage.cards.Cards)345 TargetCard (mage.target.TargetCard)328 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)317 TargetPlayer (mage.target.TargetPlayer)312 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)301 FilterPermanent (mage.filter.FilterPermanent)292 Target (mage.target.Target)289 OneShotEffect (mage.abilities.effects.OneShotEffect)230 ContinuousEffect (mage.abilities.effects.ContinuousEffect)227 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)207 Effect (mage.abilities.effects.Effect)170