Sha256: d1baad6b10806f48ba2694d73d6eddadf8c0c5b1e45d7cf2dfec153cbf052b80

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

# frozen-string-literal: true

module Bioshogi
  class Player
    module OtherMethods
      attr_writer :king_moved_counter
      attr_accessor :king_place
      attr_accessor :king_first_moved_turn # 玉が最初に動いた手数
      attr_accessor :death_counter         # 駒が死んだ数

      def king_moved_counter
        @king_moved_counter ||= 0
      end

      def king_place
        @king_place ||= king_soldier&.place
      end

      def king_place_update
        @king_place = king_soldier&.place
      end

      def used_piece_counts
        @used_piece_counts ||= Hash.new(0)
      end

      # 大駒コンプリートしている?
      def stronger_piece_completed?
        stronger_piece_have_count >= 4
      end

      def stronger_piece_have_count
        c = 0

        # 持駒の大駒
        c += piece_box[:rook] || 0
        c += piece_box[:bishop] || 0

        # 盤上の大駒
        key = location.key
        c += board.piece_count_of(key, :rook)
        c += board.piece_count_of(key, :bishop)

        c
      end

      # 入玉宣言時の得点合計(仮)
      def ek_score_without_cond
        soldiers_ek_score + piece_box.ek_score
      end

      # 入玉宣言時の得点合計(最終)
      def ek_score_with_cond
        if king_soldier_entered? && many_soliders_are_in_the_opponent_area?
          ek_score_without_cond
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bioshogi-0.0.10 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.9 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.8 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.7 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.5 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.4 lib/bioshogi/player/other_methods.rb
bioshogi-0.0.3 lib/bioshogi/player/other_methods.rb