class BCDice::GameSystem::CodeLayerd
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/CodeLayerd.rb, line 35 def initialize(command) super(command) @sides_implicit_d = 10 end
Public Instance Methods
check_roll(command, base, target, critical_target, diff, modifier)
click to toggle source
# File lib/bcdice/game_system/CodeLayerd.rb, line 56 def check_roll(command, base, target, critical_target, diff, modifier) if base <= 0 # クリティカルしない1D critical_target = 0 base = 1 end result = Result.new target = 10 if target > 10 dice_list = @randomizer.roll_barabara(base, 10).sort success_count = dice_list.count { |x| x <= target } critical_count = dice_list.count { |x| x <= critical_target } result.critical = critical_count > 0 success_total = success_count + critical_count + modifier mod_text = Format.modifier(modifier) # (10d10+5) text = "#{command} > (#{base}d10#{mod_text}) > [#{dice_list.join(',')}]#{mod_text} > " text += "判定値[#{target}] " unless target == 6 text += "クリティカル値[#{critical_target}] " unless critical_target == 1 text += "達成値[#{success_count}]" if success_count <= 0 result.fumble = true result.failure = true result.text = "#{text} > ファンブル!" return result end text += "+クリティカル[#{critical_count}]" if result.critical? text += mod_text text += "=[#{success_total}]" if result.critical? || modifier != 0 if diff.nil? result.text = "#{text} > #{success_total}" elsif success_total >= diff result.text = "#{text} > 成功" result.success = true else result.text = "#{text} > 失敗" result.failure = true end return result end
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/CodeLayerd.rb, line 41 def eval_game_system_specific_command(command) debug('eval_game_system_specific_command command', command) m = /([+-]?\d+)?CL([+-]\d+)?(@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i.match(command) return nil unless m base = (m[1] || 1).to_i modifier1 = m[2].to_i target = (m[4] || 6).to_i critical_target = (m[6] || 1).to_i modifier2 = m[7].to_i diff = m[9].to_i if m[9] check_roll(command, base, target, critical_target, diff, modifier1 + modifier2) end