Class: BCDice::GameSystem::SwordWorld2_0::TranscendentTest
- Inherits:
-
Object
- Object
- BCDice::GameSystem::SwordWorld2_0::TranscendentTest
- Includes:
- Translate
- 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, locale) ⇒ TranscendentTest
constructor
A new instance of TranscendentTest.
Methods included from Translate
Constructor Details
#initialize(critical_value, modifier, cmp_op, target, locale) ⇒ TranscendentTest
Returns a new instance of TranscendentTest.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bcdice/game_system/sword_world/transcendent_test.rb', line 17 def initialize(critical_value, modifier, cmp_op, target, locale) @critical_value = critical_value @modifier = modifier @cmp_op = cmp_op @target = target @locale = locale @modifier_str = Format.modifier(@modifier) @expression = node_expression() end |
Instance Method Details
#execute(randomizer) ⇒ String
超越判定を行う
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bcdice/game_system/sword_world/transcendent_test.rb', line 31 def execute(randomizer) if @critical_value < 3 return translate("SwordWorld2_0.transcendent_critical_too_small", expression: @expression) end first_value_group = randomizer.(2, 6) value_groups = [first_value_group] fumble = first_value_group == [1, 1] critical = first_value_group == [6, 6] unless fumble 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 result = result_status(total_sum, value_groups.length, fumble, critical) result_str = { success: translate("success"), failure: translate("failure"), super_success: translate("SwordWorld2_0.super_success"), critical: translate("SwordWorld.critical"), fumble: translate("SwordWorld.fumble"), }.freeze[result] parts = [ "(#{@expression})", "#{dice_str(value_groups, sum)}#{@modifier_str}", total_sum, result_str, ].compact return Result.new.tap do |r| r.text = parts.join(" > ") r.fumble = result == :fumble r.critical = result == :critical r.success = [:success, :super_success, :critical].include?(result) r.failure = [:failure, :fumble].include?(result) end end |