class BCDice::GameSystem::DoubleCross::ValueGroup

出目のグループを表すクラス

Attributes

critical_value[R]

クリティカル値 @return [Integer]

values[R]

出目の配列 @return [Array<Integer>]

Public Class Methods

new(values, critical_value) click to toggle source

出目のグループを初期化する @param [Array<Integer>] values 出目の配列 @param [Integer] critical_value クリティカル値

# File lib/bcdice/game_system/DoubleCross.rb, line 163
def initialize(values, critical_value)
  @values = values.sort
  @critical_value = critical_value
end

Public Instance Methods

max() click to toggle source

出目のグループ中の最大値を返す @return [Integer]

クリティカル値以上の出目が含まれていた場合は10を返す。

3rd ルールブック1 pp. 185-186
# File lib/bcdice/game_system/DoubleCross.rb, line 179
def max
  @values.any? { |value| critical?(value) } ? 10 : @values.max
end
num_of_critical_occurrences() click to toggle source

クリティカルの発生数を返す @return [Integer]

# File lib/bcdice/game_system/DoubleCross.rb, line 185
def num_of_critical_occurrences
  @values.count { |value| critical?(value) }
end
to_s() click to toggle source

出目のグループの文字列表記を返す @return [String]

# File lib/bcdice/game_system/DoubleCross.rb, line 170
def to_s
  "#{max}[#{@values.join(',')}]"
end

Private Instance Methods

critical?(value) click to toggle source

クリティカルが発生したかを返す @param [Integer] value 出目 @return [Boolean]

クリティカル値以上の値が出た場合、クリティカルとする。

3rd ルールブック1 pp. 185-186
# File lib/bcdice/game_system/DoubleCross.rb, line 197
def critical?(value)
  value >= @critical_value
end