Sha256: 102ff06454353ed3a90b62f09c2f26018524c74bddd5a34b04d51a66d22e9b25

Contents?: true

Size: 681 Bytes

Versions: 3

Compression:

Stored size: 681 Bytes

Contents

# frozen string_literal: true

require 'dry-initializer'
require 'spy_alley_application/types/game_board'

module SpyAlleyApplication
  module Models
    class GameBoard < Dry::Struct
      class EmbassyVictory
        def call(game_board:)
          player = game_board.players.find{|p| p.seat.eql?(game_board.game_state.seat)}
          other_players = game_board.players.reject{|p| p.seat.eql?(game_board.game_state.seat)}

          game_state = {name: 'game_over', reason: {name: 'by_embassy'}, seat: player.seat}

          SpyAlleyApplication::Types::GameBoard.call(
            game_board.to_h.tap{|g| g[:game_state] = game_state})
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spy_alley_application-0.3.2 lib/spy_alley_application/models/game_board/embassy_victory.rb
spy_alley_application-0.3.1 lib/spy_alley_application/models/game_board/embassy_victory.rb
spy_alley_application-0.3.0 lib/spy_alley_application/models/game_board/embassy_victory.rb