class BCDice::GameSystem::Fiasco
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/Fiasco.rb, line 25 def eval_game_system_specific_command(command) roll_fs(command) || roll_white_black(command) || roll_white_black_single(command) end
Private Instance Methods
color(c)
click to toggle source
# File lib/bcdice/game_system/Fiasco.rb, line 97 def color(c) c == "W" ? translate("Fiasco.white") : translate("Fiasco.black") end
roll_fs(command)
click to toggle source
6面ダイスを複数ダイスロールして、各面が出た個数をカウントする @param command [String] @return [String, nil]
# File lib/bcdice/game_system/Fiasco.rb, line 34 def roll_fs(command) m = /^FS(\d+)$/.match(command) unless m return nil end dice_count = m[1].to_i dice_list = @randomizer.roll_barabara(dice_count, 6) # 各出目の個数を数える bucket = [nil, 0, 0, 0, 0, 0, 0] dice_list.each do |val| bucket[val] += 1 end # "n個" 表記にする bucket.map! { |count| translate("Fiasco.fs.count", count: count) } return "1 => #{bucket[1]}, 2 => #{bucket[2]}, 3 => #{bucket[3]}, 4 => #{bucket[4]}, 5 => #{bucket[5]}, 6 => #{bucket[6]}" end
roll_white_black(command)
click to toggle source
白黒両方ダイスロールして、その差分を表示する @param command [String] @return [String, nil]
# File lib/bcdice/game_system/Fiasco.rb, line 75 def roll_white_black(command) m = /^([WB])(\d+)([WB])(\d+)$/.match(command) unless m return nil end case command when /^W\d+W\d+$/ return "#{command}:#{translate('Fiasco.wb.duplicate_error.white')}" when /^B\d+B\d+$/ return "#{command}:#{translate('Fiasco.wb.duplicate_error.black')}" end a = Side.new(color(m[1]), m[2].to_i) result_a = a.roll(@randomizer) b = Side.new(color(m[3]), m[4].to_i) result_b = b.roll(@randomizer) return "#{result_a} #{result_b} > #{a.diff(b)}" end
roll_white_black_single(command)
click to toggle source
白か黒かの片方だけダイスロールする
“W4”, “B6” など @param command [String] @return [String, nil]
# File lib/bcdice/game_system/Fiasco.rb, line 60 def roll_white_black_single(command) m = /^([WB])(\d+)$/.match(command) unless m return nil end a = Side.new(color(m[1]), m[2].to_i) result = a.roll(@randomizer) return "#{result} > #{a.color}#{a.total}" end