Sha256: c62a75ab0e12c92030a6b808a3522dd501358227907daad8d9c5eb2eb7484625
Contents?: true
Size: 1.24 KB
Versions: 8
Compression:
Stored size: 1.24 KB
Contents
# frozen-string-literal: true module Bioshogi module Dimension class PlaceY < Base cattr_accessor(:promotable_depth) { 3 } # 相手の陣地の成れる縦幅 class << self def char_infos @char_infos ||= CharInfo.take(dimension) end # 一時的に成れない状況にする def promotable_disabled(&block) old_value = promotable_depth PlaceY.promotable_depth = nil if block_given? begin yield ensure self.promotable_depth = old_value end else old_value end end end def name char_info.number_kanji end def to_sfen ("a".ord + value).chr end # 人間向けの数字で 68 なら 8 def to_human_int value + 1 end # 成れるか? # @example # Place.fetch("1三").promotable?(:black) # => true # Place.fetch("1四").promotable?(:black) # => false def promotable?(location) v = self if location.white? v = v.flip end if promotable_depth v.value < promotable_depth end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems