class BCDice::GameSystem::ArsMagica
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
Public Instance Methods
eval_game_system_specific_command(string)
click to toggle source
# File lib/bcdice/game_system/ArsMagica.rb, line 31 def eval_game_system_specific_command(string) unless parse_ars(string) || parse_1r10(string) return nil end diff = @target_numner || 0 botch = @botch bonus = @modify_number crit_mul = 1 total = 0 cmp_op = @cmp_op die = @randomizer.roll_once(10) - 1 output = "(#{expr()}) > " if die == 0 # botch? count0 = 0 dice_n = [] botch.times do |_i| botch_die = @randomizer.roll_once(10) - 1 count0 += 1 if botch_die == 0 dice_n.push(botch_die) end output += "0[#{die},#{dice_n.join(',')}]" if count0 != 0 if count0 > 1 output += " > #{count0}Botch!" else output += " > Botch!" end # Botchの時には目標値を使った判定はしない cmp_op = nil else if bonus > 0 output += "+#{bonus} > #{bonus}" elsif bonus < 0 output += "#{bonus} > #{bonus}" else output += " > 0" end total = bonus end elsif die == 1 # Crit crit_dice = "" while die == 1 crit_mul *= 2 die = @randomizer.roll_once(10) crit_dice += "#{die}," end total = die * crit_mul crit_dice = crit_dice.sub(/,$/, '') output += total.to_s output += "[1,#{crit_dice}]" total += bonus if bonus > 0 output += "+#{bonus} > #{total}" elsif bonus < 0 output += "#{bonus} > #{total}" end else total = die + bonus if bonus > 0 output += "#{die}+#{bonus} > #{total}" elsif bonus < 0 output += "#{die}#{bonus} > #{total}" else output += total.to_s end end if cmp_op == :>= output += (total >= diff ? " > 成功" : " > 失敗") end return output.to_s end
Private Instance Methods
expr()
click to toggle source
# File lib/bcdice/game_system/ArsMagica.rb, line 142 def expr() modifier = Format.modifier(@modify_number) "1R10#{modifier}[#{@botch}]#{@cmp_op}#{@target_numner}" end
parse_1r10(command)
click to toggle source
# File lib/bcdice/game_system/ArsMagica.rb, line 128 def parse_1r10(command) m = /^1R10((?:[+-]-?\d+)+)?(?:\[(\d+)\])?(?:([>=]+)(\d+))?$/i.match(command) unless m return false end @modify_number = ArithmeticEvaluator.eval(m[1] || "") @botch = m[2]&.to_i || 1 @cmp_op = Normalize.comparison_operator(m[3]) @target_numner = m[4]&.to_i return true end
parse_ars(command)
click to toggle source
# File lib/bcdice/game_system/ArsMagica.rb, line 114 def parse_ars(command) m = /^ArS(\d+)?((?:[+-]-?\d+)+)?(?:([>=]+)(\d+))?$/i.match(command) unless m return false end @botch = m[1]&.to_i || 1 @modify_number = ArithmeticEvaluator.eval(m[2] || "") @cmp_op = Normalize.comparison_operator(m[3]) @target_numner = m[4]&.to_i return true end