Search in sources :

Example 1 with DrewCardEvent

use of mage.game.events.DrewCardEvent in project mage by magefree.

the class MageDrawAction method drawCard.

/**
 * Draw a card if possible (there is no replacement effect that prevent us
 * from drawing). Fire event about card drawn.
 *
 * @param source
 * @param originalDrawEvent original draw event for replacement effects, can be null for normal calls
 * @param game
 * @return
 */
protected int drawCard(Ability source, GameEvent originalDrawEvent, Game game) {
    GameEvent event = new DrawCardEvent(this.player.getId(), source, originalDrawEvent);
    if (!game.replaceEvent(event)) {
        Card card = player.getLibrary().removeFromTop(game);
        if (card != null) {
            drawnCards.add(card);
            // if you want to use event.getSourceId() here then thinks x10 times
            card.moveToZone(Zone.HAND, source, game, false);
            if (player.isTopCardRevealed()) {
                game.fireInformEvent(player.getLogName() + " draws a revealed card  (" + card.getLogName() + ')');
            }
            game.fireEvent(new DrewCardEvent(card.getId(), player.getId(), source, originalDrawEvent));
            return ArtificialScoringSystem.inst.getCardScore(card);
        }
    }
    return NEGATIVE_VALUE;
}
Also used : GameEvent(mage.game.events.GameEvent) DrawCardEvent(mage.game.events.DrawCardEvent) DrewCardEvent(mage.game.events.DrewCardEvent) Card(mage.cards.Card)

Aggregations

Card (mage.cards.Card)1 DrawCardEvent (mage.game.events.DrawCardEvent)1 DrewCardEvent (mage.game.events.DrewCardEvent)1 GameEvent (mage.game.events.GameEvent)1