Search in sources :

Example 1 with DrawCardsEvent

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

the class MageDrawAction method doAction.

/**
 * Draw and set action score.
 *
 * @param source
 * @param game     Game context.
 * @return
 */
@Override
public int doAction(Ability source, Game game) {
    int numDrawn = 0;
    int score = 0;
    GameEvent event = new DrawCardsEvent(this.player.getId(), source, this.originalDrawEvent, this.amount);
    if (amount < 2 || !game.replaceEvent(event)) {
        amount = event.getAmount();
        for (int i = 0; i < amount; i++) {
            int value = drawCard(source, this.originalDrawEvent, game);
            if (value == NEGATIVE_VALUE) {
                continue;
            }
            numDrawn++;
            score += value;
        }
        if (!player.isTopCardRevealed() && numDrawn > 0) {
            game.fireInformEvent(player.getLogName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : ""));
        }
        setScore(player, score);
    }
    return numDrawn;
}
Also used : DrawCardsEvent(mage.game.events.DrawCardsEvent) GameEvent(mage.game.events.GameEvent)

Aggregations

DrawCardsEvent (mage.game.events.DrawCardsEvent)1 GameEvent (mage.game.events.GameEvent)1