class BCDice::GameSystem::ChaosFlare
Constants
- FATE_TABLE
表を振るのに使う定数的なやつ。
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/ChaosFlare.rb, line 77 def eval_game_system_specific_command(command) if command.start_with? "FT" roll_fate_table(command) else cf_roll(command) end end
result_2d6(total, dice_total, _dice_list, cmp_op, target)
click to toggle source
ゲーム別成功度判定(2D6)。以前の処理をそのまま残しています。
# File lib/bcdice/game_system/ChaosFlare.rb, line 45 def result_2d6(total, dice_total, _dice_list, cmp_op, target) return nil unless cmp_op == :>= sequence = [] result = Result.new if dice_total <= 2 total -= 20 sequence.push("ファンブル(-20)") result.fumble = true end if target != '?' if total >= target sequence.push("成功") result.success = true else sequence.push("失敗") result.failure = true end if total - target != 0 sequence.push("差分値#{total - target}") end end return Result.nothing if sequence.empty? result.text = sequence.join(" > ") return result end
Private Instance Methods
cf_roll(command)
click to toggle source
カオスフレア専用コマンド @param command [String] @return [String, nil]
# File lib/bcdice/game_system/ChaosFlare.rb, line 114 def cf_roll(command) parser = Command::Parser.new(/\d*CF/, round_type: round_type) .enable_critical .enable_fumble @cmd = parser.parse(command) unless @cmd return nil end times = @cmd.command == "CF" ? 2 : @cmd.command.to_i critical = @cmd.critical || 12 fumble = @cmd.fumble || 2 @cmd.dollar = nil if times < 0 || ![:>=, nil].include?(@cmd.cmp_op) return nil end dice_list = @randomizer.roll_barabara(times, 6) dice_total = dice_list.sum() dice_list_text = dice_list.join(",") is_critical = dice_total >= critical is_fumble = dice_total <= fumble total = if is_critical 30 elsif is_fumble -20 else dice_total end total += @cmd.modify_number sequence = [ "(#{@cmd.to_s(:after_modify_number)})", "#{dice_total}[#{dice_list_text}]", total.to_s, ("0" if total < 0), ("クリティカル" if is_critical), ("ファンブル" if is_fumble), ("差分値 #{difference(total)}" if @cmd.target_number), ].compact return sequence.join(" > ") end
difference(total)
click to toggle source
@param total [Integer] 合計値 @return [Integer] 差分値
# File lib/bcdice/game_system/ChaosFlare.rb, line 166 def difference(total) if total < 0 -@cmd.target_number else total - @cmd.target_number end end
roll_fate_table(command)
click to toggle source
因縁表
# File lib/bcdice/game_system/ChaosFlare.rb, line 88 def roll_fate_table(command) m = /^FT(\d+)?/.match(command) if m[1] num = m[1].to_i if [0, 7].include?(num) return "因果表(#{num}) > #{FATE_TABLE[num][0]}" end dice1 = num / 10 dice2 = num % 10 if !(1..6).include?(dice1) || !(1..6).include?(dice2) return nil end else dice1 = @randomizer.roll_once(6) dice2 = @randomizer.roll_once(6) end index1 = dice1 index2 = (dice2 / 2) - 1 return "因果表(#{dice1}#{dice2}) > #{FATE_TABLE[index1][index2]}" end