Class: BCDice::GameSystem::SwordWorld2_0::TranscendentTest
- Inherits:
-
Object
- Object
- BCDice::GameSystem::SwordWorld2_0::TranscendentTest
- Defined in:
- lib/bcdice/game_system/sword_world/transcendent_test.rb
Overview
超越判定のノード
Instance Method Summary collapse
-
#execute(randomizer) ⇒ String
超越判定を行う.
-
#initialize(critical_value, modifier, cmp_op, target) ⇒ TranscendentTest
constructor
A new instance of TranscendentTest.
Constructor Details
#initialize(critical_value, modifier, cmp_op, target) ⇒ TranscendentTest
Returns a new instance of TranscendentTest.
10 11 12 13 14 15 16 17 18 |
# File 'lib/bcdice/game_system/sword_world/transcendent_test.rb', line 10 def initialize(critical_value, modifier, cmp_op, target) @critical_value = critical_value @modifier = modifier @cmp_op = cmp_op @target = target @modifier_str = Format.modifier(@modifier) @expression = node_expression() end |
Instance Method Details
#execute(randomizer) ⇒ String
超越判定を行う
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bcdice/game_system/sword_world/transcendent_test.rb', line 23 def execute(randomizer) if @critical_value < 3 return "(#{@expression}) > クリティカル値が小さすぎます。3以上を指定してください。" end first_value_group = randomizer.(2, 6) value_groups = [first_value_group] fumble = first_value_group == [1, 1] critical = first_value_group == [6, 6] if !fumble && !critical while sum_of_dice(value_groups.last) >= @critical_value value_groups.push(randomizer.(2, 6)) end end sum = sum_of_dice(value_groups) total_sum = sum + @modifier parts = [ "(#{@expression})", "#{dice_str(value_groups, sum)}#{@modifier_str}", total_sum, @target && result_str(total_sum, value_groups.length, fumble, critical) ].compact return parts.join(" > ") end |