class BCDice::GameSystem::LostRoyal
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
Public Class Methods
new(command)
click to toggle source
Calls superclass method
BCDice::Base::new
# File lib/bcdice/game_system/LostRoyal.rb, line 40 def initialize(command) super(command) @sort_add_dice = true @d66_sort_type = D66SortType::NO_SORT end
Public Instance Methods
check_lostroyal(checking_table)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 64 def check_lostroyal(checking_table) keys = [] (0...3).each do |_i| key = @randomizer.roll_once(6) keys << key end scores = (keys.map { |k| checking_table[k - 1] }).to_a total_score = scores.inject(:+) chained_sequence = find_sequence(keys) text = "3D6 => [#{keys.join(',')}] => (#{scores.join('+')}) => #{total_score}" unless chained_sequence.nil? || chained_sequence.empty? bonus = fumble_?(keys, chained_sequence) ? 3 : chained_sequence.size text += " | #{chained_sequence.size} chain! (#{chained_sequence.join(',')}) => #{total_score + bonus}" if chained_sequence.size >= 3 text += " [スペシャル]" end if fumble_?(keys, chained_sequence) text += " [ファンブル]" end end return text end
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 47 def eval_game_system_specific_command(command) case command when /LR\[([0-5]),([0-5]),([0-5]),([0-5]),([0-5]),([0-5])\]/i return check_lostroyal([Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i, Regexp.last_match(4).to_i, Regexp.last_match(5).to_i, Regexp.last_match(6).to_i,]) when /FC/ return roll_fumble_chart when /WPC/ return roll_wind_power_chart when /EC/ return roll_emotion_chart when /HR([1-2])/ return roll_hope(Regexp.last_match(1).to_i) end return nil end
find_sequence(keys)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 95 def find_sequence(keys) keys = keys.sort sequences = (1...6).map do |start_key| find_sequence_from_start_key(keys, start_key) end sequences.select { |x| x.size > 1 }.max { |a, b| a.size <=> b.size } end
find_sequence_from_start_key(keys, start_key)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 104 def find_sequence_from_start_key(keys, start_key) chained_keys = [] key = start_key while keys.include? key chained_keys << key key += 1 end if !chained_keys.empty? && chained_keys[0] == 1 key = 6 while keys.include? key chained_keys.unshift key key -= 1 end end return chained_keys end
fumble_?(keys, chained_sequence)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 125 def fumble_?(keys, chained_sequence) chained_sequence.each do |k| if keys.count(k) >= 2 return true end end false end
is_1or2(n)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 234 def is_1or2(n) [1, 2].include?(n) end
roll_emotion_chart()
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 190 def roll_emotion_chart key = @randomizer.roll_once(6) text = [ "愛情/殺意", "友情/負目", "崇拝/嫌悪", "興味/侮蔑", "信頼/嫉妬", "守護/欲情", ][key - 1] return "1D6 => [#{key}] #{text}" end
roll_fumble_chart()
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 135 def roll_fumble_chart key = @randomizer.roll_once(6) text = [ "何かの問題で言い争い、主君に無礼を働いてしまう。あなたは主君の名誉点を1点失うか、【時間】を1点消費して和解の話し合いを持つか選べる。", "見過ごせば人々を不幸にする危険に遭遇する。あなたは逃げ出して冒険の名誉点を1点失うか、これに立ち向かい【命数】を2点減らすかを選べる。", "あなたが惹かれたのは好意に付け込む人だった。あなたはその場を去って恋慕の名誉点を1点失うか【正義】を1点減らして礼を尽くすかを選べる。", "金銭的な問題で、生命と魂の苦しみを背負う人に出会う。あなたは庇護の名誉点を1点失うか出費を3点増やすかを選べる。", "襲撃を受ける。苦もなく叩き伏せると、卑屈な態度で命乞いをしてきた。容赦なく命を奪い寛容の名誉点を1点失うか、密告によって【血路】が1D6点増えるかを選ぶことができる。", "風聞により、友が悪に身を貶めたと知る。共に並んだ戦場が色褪せる想いだ。戦友の名誉点を1点減らすか、【酒と歌】すべてを失うかを選べる。", ][key - 1] return "1D6 => [#{key}] #{text}" end
roll_hope(number_of_dice)
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 205 def roll_hope(number_of_dice) total = 0 text = "" loop do d1 = @randomizer.roll_once(6) d2 = 0 if number_of_dice >= 2 d2 = @randomizer.roll_once(6) end total += d1 + d2 if number_of_dice == 2 text += "2D6[#{d1},#{d2}]" else text += "1D6[#{d1}]" end if is_1or2(d1) || is_1or2(d2) text += " (振り足し) => " else text += " => 合計 #{total}" return text end end end
roll_wind_power_chart()
click to toggle source
# File lib/bcdice/game_system/LostRoyal.rb, line 150 def roll_wind_power_chart key = 0 total_bonus = 0 text = "" loop do dice = @randomizer.roll_once(6) key += dice add, bonus, current_text, = [ [true, 0, "ほぼ凪(振り足し)"], [true, 0, "弱い風(振り足し)"], [false, 0, "ゆるやかな風"], [false, 0, "ゆるやかな風"], [false, 1, "やや強い風(儀式点プラス1)"], [false, 2, "強い風(龍を幻視、儀式点プラス2)"], [false, 3, "体が揺らぐほどの風(龍を幻視、儀式点プラス3)"], ][[key, 7].min - 1] total_bonus += bonus if key != dice current_text = "1D6[#{dice}]+#{key - dice} #{current_text}" else current_text = "1D6[#{dice}] #{current_text}" end if text.empty? text = current_text else text = "#{text} => #{current_text}" end unless add text += " [合計:儀式点 +#{total_bonus} ]" return text end end end