class BCDice::GameSystem::SkynautsBouken
Constants
- DIRECTION_INFOS
- D_REGEXP
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
- TABLES
Public Class Methods
new(command)
click to toggle source
Calls superclass method
BCDice::Base::new
# File lib/bcdice/game_system/SkynautsBouken.rb, line 66 def initialize(command) super(command) @round_type = RoundType::FLOOR # 端数切り捨て end
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 71 def eval_game_system_specific_command(command) command_sn(command) || command_d(command) || command_avo(command) || command_snavo(command) || command_snd(command) || roll_tables(command, TABLES) end
Private Instance Methods
command_avo(command)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 152 def command_avo(command) debug("AVO", command) dmg = command.match(/^AVO@([2468])(.*?)$/) return nil unless dmg dir = DIRECTION_INFOS[dmg[1].to_i] diff_x, diff_y = dir[:position_diff] "《回避運動》#{dir[:name]} > " + dmg[2].gsub(/\(?\[(\d),(\d{1,2})\]\)?/) do y = Regexp.last_match(1).to_i + diff_y x = Regexp.last_match(2).to_i + diff_x get_xy_text(x, y) end end
command_d(command)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 130 def command_d(command) m = D_REGEXP.match(command) return nil unless m fire_count = m[3].to_i # 砲撃回数 fire_range = m[1].to_s # 砲撃範囲 ballistics = m[5].to_i # 《弾道学》 points = get_fire_points(fire_count, fire_range) command = command.sub("SF/", "[大揺れ,火災]/").sub("FS/", "[火災,大揺れ]/").sub("F/", "[火災]/").sub("S/", "[大揺れ]/") result = ["(#{command})", get_points_text(points, 0, 0)] if ballistics != 0 dir = DIRECTION_INFOS[ballistics] diff_x, diff_y = dir[:position_diff] result[-1] += "\n" result << "《弾道学》#{dir[:name]}" result << get_points_text(points, diff_x, diff_y) end result.compact.join(" > ") end
command_sn(command)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 93 def command_sn(command) debug("SN", command) cmd = Command::Parser.new(/[1-9]?SN(\d{0,2})/, round_type: round_type) .restrict_cmp_op_to(nil) .enable_fumble.parse(command) return nil unless cmd # [dice_count]SN[target] dice_count, target = cmd.command.split("SN", 2).map(&:to_i) dice_count = 2 if dice_count == 0 target = 7 if target == 0 fumble = cmd.fumble.nil? ? 1 : cmd.fumble debug("SN Parsed", dice_count, target, fumble) dice_list = @randomizer.roll_barabara(dice_count, 6) dice_top_two = dice_list.sort[-2..-1] res = if dice_top_two == [6, 6] Result.critical("スペシャル(【生命点】1d6回復)") elsif dice_list.max <= fumble Result.fumble("ファンブル(ファンブル表FT)") elsif dice_top_two.sum >= target Result.success("成功") else Result.failure("失敗") end if dice_count == 2 res.text = ["(#{dice_count}SN#{target}##{fumble})", "#{dice_top_two.sum}[#{dice_list.join(',')}]", res.text] .compact.join(" > ") else res.text = ["(#{dice_count}SN#{target}##{fumble})", "[" + dice_list.join(",") + "]", "#{dice_top_two.sum}[#{dice_top_two.join(',')}]", res.text] .compact.join(" > ") end res end
command_snd(command)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 181 def command_snd(command) sn, d = command.split(%r{/?D}, 2) debug("SND", sn, d) m = D_REGEXP.match("D#{d}") return nil unless m res = command_sn(sn) return nil unless res if res.success? res.text += "\n > #{command_d('D' + d)}" end res end
get_fire_points(fire_count, fire_range)
click to toggle source
命中場所と範囲から、ダメージ位置を割り出す
# File lib/bcdice/game_system/SkynautsBouken.rb, line 214 def get_fire_points(fire_count, fire_range) range = fire_range.chars.map(&:to_i) fire_count.times.map do y = @randomizer.roll_once(6) # 縦 x = @randomizer.roll_sum(2, 6) # 横 [[x, y]] + range.map do |r| xdiff, ydiff = DIRECTION_INFOS[r][:position_diff] [x + xdiff, y + ydiff] end end end
get_points_text(points, diff_x, diff_y)
click to toggle source
# File lib/bcdice/game_system/SkynautsBouken.rb, line 196 def get_points_text(points, diff_x, diff_y) "[縦,横]=" + points.map do |list| list.map do |x, y| get_xy_text(x + diff_x, y + diff_y) end.join() end.join(",") end