Sha256: b553c1ab1244605c4361eda8e662a9060b492f537c48fd9adff4385efaafebd5

Contents?: true

Size: 809 Bytes

Versions: 9

Compression:

Stored size: 809 Bytes

Contents

# frozen-string-literal: true
module Bioshogi
  class SfenImporter
    def initialize(container, sfen_info)
      @container = container
      @sfen_info = sfen_info
    end

    def import_initial
      @sfen_info.soldiers.each do |soldier|
        player = @container.player_at(soldier.location)
        player.board.place_on(soldier, validate: true)
      end
      @container.turn_info.handicap = @sfen_info.handicap?
      @container.turn_info.turn_base = @sfen_info.turn_base
      @sfen_info.piece_counts.each do |location_key, counts|
        @container.player_at(location_key).piece_box.set(counts)
      end
      @container.before_run_process
    end

    def import_all
      import_initial
      @sfen_info.move_infos.each do |e|
        @container.execute(e[:input])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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