Class: BCDice::GameSystem::DoubleCross::ValueGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/game_system/DoubleCross.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values, critical_value) ⇒ ValueGroup

出目のグループを初期化する

Parameters:

  • values (Array<Integer>)

    出目の配列

  • critical_value (Integer)

    クリティカル値



171
172
173
174
# File 'lib/bcdice/game_system/DoubleCross.rb', line 171

def initialize(values, critical_value)
  @values = values.sort
  @critical_value = critical_value
end

Instance Attribute Details

#critical_valueInteger (readonly)

クリティカル値

Returns:

  • (Integer)


166
167
168
# File 'lib/bcdice/game_system/DoubleCross.rb', line 166

def critical_value
  @critical_value
end

#valuesArray<Integer> (readonly)

出目の配列

Returns:

  • (Array<Integer>)


163
164
165
# File 'lib/bcdice/game_system/DoubleCross.rb', line 163

def values
  @values
end

Instance Method Details

#maxInteger

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

3rd ルールブック1 pp. 185-186

Returns:

  • (Integer)


187
188
189
# File 'lib/bcdice/game_system/DoubleCross.rb', line 187

def max
  @values.any? { |value| critical?(value) } ? 10 : @values.max
end

#num_of_critical_occurrencesInteger

クリティカルの発生数を返す

Returns:

  • (Integer)


193
194
195
# File 'lib/bcdice/game_system/DoubleCross.rb', line 193

def num_of_critical_occurrences
  @values.count { |value| critical?(value) }
end

#to_sString

出目のグループの文字列表記を返す

Returns:

  • (String)


178
179
180
# File 'lib/bcdice/game_system/DoubleCross.rb', line 178

def to_s
  "#{max}[#{@values.join(',')}]"
end