app/cards/seaside/salvager.js
Salvager = class Salvager extends Card {
types() {
return this.capitalism_types(['action'])
}
capitalism() {
return true
}
coin_cost() {
return 4
}
play(game, player_cards, card_player) {
let buy_gainer = new BuyGainer(game, player_cards)
buy_gainer.gain(1)
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, card_player)
turn_event_processor.process(Salvager.trash_card)
} else if (_.size(player_cards.hand) === 1) {
Salvager.trash_card(game, player_cards, player_cards.hand)
} else {
game.log.push(` but there are no cards in hand`)
}
}
static trash_card(game, player_cards, selected_cards, card_player) {
let coin_cost = CostCalculator.calculate(game, selected_cards[0])
let card_trasher = new CardTrasher(game, player_cards, 'hand', selected_cards)
card_trasher.trash()
let coin_gainer = new CoinGainer(game, player_cards, card_player)
coin_gainer.gain(coin_cost)
}
}