class BCDice::GameSystem::SteamPunkers
Constants
- HELP_MESSAGE
- ID
- NAME
- SORT_KEY
- TABLES
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/SteamPunkers.rb, line 32 def eval_game_system_specific_command(command) result = roll_tables(command, TABLES) return result if result return roll_sp(command) end
roll_sp(command)
click to toggle source
# File lib/bcdice/game_system/SteamPunkers.rb, line 39 def roll_sp(command) m = /^SP(\d+)(?:>=(\d+))?$/i.match(command) unless m return nil end dice_count = m[1].to_i target_number = m[2]&.to_i dice_list = @randomizer.roll_barabara(dice_count, 6) dice_list_text = dice_list.join(',') successes = dice_list.count(6) * 2 + dice_list.count(5) failures = dice_list.count { |x| x <= 4 } result = if dice_list.all? { |x| x == 1 } Result.fumble("ファンブル") elsif target_number successes >= target_number ? Result.success("成功") : Result.failure("失敗") else Result.new end result.text = [ "(#{command})", "[#{dice_list_text}]", "成功数:#{successes}, 失敗数:#{failures}", result.text ].compact.join(" > ") result.critical = dice_list.include?(6) return result end