jcbantuelle/dominion-meteor

View on GitHub
app/cards/renaissance/priest.js

Summary

Maintainability
A
0 mins
Test Coverage
Priest = class Priest extends Card {

  types() {
    return this.capitalism_types(['action'])
  }

  capitalism() {
    return true
  }

  coin_cost() {
    return 4
  }

  play(game, player_cards, card_player) {
    let coin_gainer = new CoinGainer(game, player_cards, card_player)
    coin_gainer.gain(2)

    if (_.size(player_cards.hand) > 1) {
      let turn_event_id = TurnEventModel.insert({
        game_id: game._id,
        player_id: player_cards.player_id,
        username: player_cards.username,
        type: 'choose_cards',
        player_cards: true,
        instructions: 'Choose a card to trash:',
        cards: player_cards.hand,
        minimum: 1,
        maximum: 1
      })
      let turn_event_processor = new TurnEventProcessor(game, player_cards, turn_event_id)
      turn_event_processor.process(Priest.trash_card)
    } else if (_.size(player_cards.hand) === 1) {
      Prist.trash_card(game, player_cards, player_cards.hand)
    } else {
      game.log.push(`  but there are no cards in hand`)
    }

    game.turn.priests += 1
  }

  static trash_card(game, player_cards, selected_cards) {
    let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
    card_trasher.trash()
  }

  trash_event(trasher) {
    let coin_gainer = new CoinGainer(trasher.game, trasher.player_cards)
    coin_gainer.gain(2)
  }

}