class LoveLetterApplication::Models::Effects::NextPlayerDrawCard
Public Instance Methods
call(game_board:, next_player_id:)
click to toggle source
# File lib/love_letter_application/models/effects/next_player_draw_card.rb, line 12 def call(game_board:, next_player_id:) draw_pile = game_board.draw_pile player_replacement = get_replacement(game_board.players, next_player_id, draw_pile) players = game_board .players .reject{|player| player.id.to_i.eql?(next_player_id.to_i)} .push(player_replacement) .freeze draw_pile = game_board.draw_pile[1..-1].map(&:itself).freeze LoveLetterApplication::Models::GameBoard::new( players: players, draw_pile: draw_pile, set_aside_card: game_board.set_aside_card, current_player_id: next_player_id, game_state: LoveLetterApplication::Types::GameStateEnum.call('card_drawn')) end
Private Instance Methods
get_replacement(players, player_id, draw_pile)
click to toggle source
# File lib/love_letter_application/models/effects/next_player_draw_card.rb, line 32 def get_replacement(players, player_id, draw_pile) next_player = players.find{|player| player.id.eql?(player_id.to_i)} LoveLetterApplication::Models::Player::new( id: next_player.id.to_i, seat: next_player.seat.to_i, played_cards: next_player.played_cards.map(&:itself).freeze, hand: next_player.hand.map(&:itself).push(draw_pile.first).freeze, active?: next_player.active?, targetable?: true) # limitations on being targeted expire when player's turn again end