Sha256: 06a95e840e089185b8c5e5ffbf56a525bda46187c93e10fdf4a9b5dc47c2c19d

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

module Bioshogi
  module Container
    concern :TestMethods do
      class_methods do
        def facade(params = {})
          container = new

          if params[:init]
            container.board.placement_from_human(params[:init])
          end

          if params[:pieces_set]
            container.pieces_set(params[:pieces_set])
          end

          container.execute(params[:execute])
          container
        end

        def player_test(params = {})
          params = {
            player: :black,
            initial_deal: true,
          }.merge(params)

          container = new
          player = container.player_at(params[:player])

          if params[:initial_deal]
            player.pieces_add("歩9角飛香2桂2銀2金2玉")
          end

          if v = params[:pieces_add]
            player.pieces_add(v)
          end

          if v = params[:init]
            player.soldier_create(v, from_stand: true)
          end

          Array.wrap(params[:execute]).each { |v| player.execute(v) }

          if v = params[:pieces_set]
            player.pieces_set(v)
          end

          player
        end

        def player_test_soldier_names(...)
          player_test(...).soldiers.collect(&:name).sort
        end

        def read_spec(params)
          container = new
          player = container.player_at(:black)
          player.pieces_add("歩9角飛香2桂2銀2金2玉")
          player.placement_from_human(Array(params[:init]).join.gsub(/_/, ""))
          Array.wrap(params[:execute]).each { |v| player.execute(v) }
          container.hand_logs.last.to_kif_ki2
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.14 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.10 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.9 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.8 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.7 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.5 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.4 lib/bioshogi/container/test_methods.rb
bioshogi-0.0.3 lib/bioshogi/container/test_methods.rb