Sha256: 95bf8c8ca9fd41a697b189a21c2b2e783a15f9b1dfbc1301250cd1ce0ea68279

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# frozen-string-literal: true

module Bioshogi
  class Player
    module SoldierMethods
      def soldiers
        board.surface.values.find_all { |e| e.location == location }
      end

      def king_soldier
        soldiers.find { |e| e.piece.key == :king }
      end

      def to_s_soldiers
        soldiers.collect(&:name_without_location).sort.join(" ")
      end

      # 入玉宣言時の盤上にある駒の得点合計
      def soldiers_ek_score
        soldiers.sum(&:ek_score)
      end

      # 入玉している?
      def king_soldier_entered?
        if soldier = king_soldier
          soldier.place.opp_side?(location)
        end
      end

      # 玉を除く駒が10毎以上相手陣に入っているか?
      def many_soliders_are_in_the_opponent_area?
        entered_soldiers.count >= Piece::EkScoreInfo::N_SOLIDIERS_IN_OPPONENT_AREA_WITHOUT_KING
      end

      # 相手陣に入っている玉を除く駒
      def entered_soldiers
        soldiers.find_all do |e|
          if e.piece.key != :king
            e.place.opp_side?(location)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/player/soldier_methods.rb