class BCDice::GameSystem::GURPS
Constants
- FEAR_TABLE
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- REACTION_TABLE
- SORT_KEY
ゲームシステム名の読みがな
- TABLES
- Tuple
Public Class Methods
new(command)
click to toggle source
Calls superclass method
BCDice::Base::new
# File lib/bcdice/game_system/GURPS.rb, line 37 def initialize(command) super(command) @d66_sort_type = D66SortType::NO_SORT end
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 63 def eval_game_system_specific_command(command) roll_3d6(command) || roll_fear(command) || roll_react(command) || roll_tables(command, TABLES) end
result_nd6(total, dice_total, dice_list, cmp_op, target)
click to toggle source
ゲーム別成功度判定(nD6)
# File lib/bcdice/game_system/GURPS.rb, line 44 def result_nd6(total, dice_total, dice_list, cmp_op, target) return nil if target == "?" return nil unless dice_list.size == 3 && cmp_op == :<= success = target - total # 成功度 if critical?(dice_total, target) Result.critical("クリティカル(成功度:#{success})") elsif fumble?(dice_total, target) Result.fumble("ファンブル(失敗度:#{success})") elsif dice_total >= 17 Result.failure("自動失敗(失敗度:#{success})") elsif total <= target Result.success("成功(成功度:#{success})") else Result.failure("失敗(失敗度:#{success})") end end
Private Instance Methods
critical?(dice_total, target)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 69 def critical?(dice_total, target) (dice_total <= 6 && target >= 16) || (dice_total <= 5 && target >= 15) || dice_total <= 4 end
fumble?(dice_total, target)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 73 def fumble?(dice_total, target) (target - dice_total <= -10) || (dice_total >= 17 && target <= 15) || dice_total >= 18 end
reaction(number)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 160 def reaction(number) REACTION_TABLE.find { |tuple| tuple.range.include?(number) }.text end
roll_3d6(command)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 77 def roll_3d6(command) m = /^([\d+\-]+)-3D6?([\d+\-]*)$/.match(command) return nil unless m target_number = ArithmeticEvaluator.eval(m[1]) modifier = ArithmeticEvaluator.eval(m[2]) formated_modifier = Format.modifier(modifier) cmd = "3D6#{formated_modifier}<=#{target_number}" return CommonCommand::AddDice.eval(cmd, self, @randomizer) end
roll_fear(command)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 89 def roll_fear(command) m = /^FEAR(\+?\d+)?$/.match(command) return nil unless m modifier = m[1].to_i dice = @randomizer.roll_sum(3, 6) number = dice + modifier num = if number > 40 36 else number - 4 end "恐怖表(#{number}) > #{FEAR_TABLE[num]}" end
roll_react(command)
click to toggle source
# File lib/bcdice/game_system/GURPS.rb, line 148 def roll_react(command) m = /^REACT([+-]?\d*)$/.match(command) return nil unless m modifier = m[1].to_i dice = @randomizer.roll_sum(3, 6) number = dice + modifier "反応表(#{number}) > #{reaction(number)}" end