diff --git a/lib/bcdice/game_system/SwordWorld2_5.rb b/lib/bcdice/game_system/SwordWorld2_5.rb index 28e3b10f0..c15d0cb70 100644 --- a/lib/bcdice/game_system/SwordWorld2_5.rb +++ b/lib/bcdice/game_system/SwordWorld2_5.rb @@ -66,9 +66,29 @@ class SwordWorld2_5 < SwordWorld2_0 ・絡み効果表 (TT)  絡み効果表を出すことができます。 + + ・ドルイドの物理魔法用表 (Dru[2-6の値,7-9の値,10-12の値]) +  例)Dru[0,3,6]+10-3 INFO_MESSAGE_TEXT - register_prefix('H?K\d+.*', 'Gr(\d+)?', '2D6?@\d+.*', 'FT', 'TT') + register_prefix('H?K\d+.*', 'Gr(\d+)?', '2D6?@\d+.*', 'FT', 'TT', 'Dru\[\d+,\d+,\d+\].*') + + def eval_game_system_specific_command(command) + case command + when /^dru\[(\d+),(\d+),(\d+)\]/i + power_list = Regexp.last_match.captures.map(&:to_i) + druid_parser = Command::Parser.new(/dru\[\d+,\d+,\d+\]/i, round_type: BCDice::RoundType::CEIL) + + cmd = druid_parser.parse(command) + unless cmd + return nil + end + + druid_dice(cmd, power_list) + else + super(command) + end + end # コマンド実行前にメッセージを置換する # @param [String] string 受信したメッセージ @@ -82,6 +102,30 @@ def replace_text(string) end end + def druid_dice(command, power_list) + dice_list = @randomizer.roll_barabara(2, 6) + dice_total = dice_list.sum() + offset = + case dice_total + when 2..6 + 0 + when 7..9 + 1 + when 10..12 + 2 + end + power = power_list[offset] + total = power + command.modify_number + sequence = [ + "(#{command.command.capitalize}#{Format.modifier(command.modify_number)})", + "2D[#{dice_list.join(',')}]=#{dice_total}", + "#{power}#{Format.modifier(command.modify_number)}", + total + ] + + return sequence.join(" > ") + end + def getRatingCommandStrings super + "aA" end diff --git a/test/data/SwordWorld2_5.toml b/test/data/SwordWorld2_5.toml index 76a628517..37d30cb29 100644 --- a/test/data/SwordWorld2_5.toml +++ b/test/data/SwordWorld2_5.toml @@ -731,3 +731,84 @@ output = "絡み効果表(6) → 特殊:尻尾や翼などに命中。絡め rands = [ { sides = 6, value = 6 }, ] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[4,7,13]+10" +output = "(Dru[4,7,13]+10) > 2D[6,5]=11 > 13+10 > 23" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 5 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[4,7,13]+10" +output = "(Dru[4,7,13]+10) > 2D[6,6]=12 > 13+10 > 23" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[4,7,13]+10" +output = "(Dru[4,7,13]+10) > 2D[4,6]=10 > 13+10 > 23" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[4,7,13]+10" +output = "(Dru[4,7,13]+10) > 2D[4,5]=9 > 7+10 > 17" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 5 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "dru[0,3,6]+10+4-5" +output = "(Dru[0,3,6]+9) > 2D[2,3]=5 > 0+9 > 9" +rands = [ + { sides = 6, value = 2 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "dru[0,3,6]+10+4-5" +output = "(Dru[0,3,6]+9) > 2D[3,3]=6 > 0+9 > 9" +rands = [ + { sides = 6, value = 3 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "dru[0,3,6]+10+4-5" +output = "(Dru[0,3,6]+9) > 2D[4,3]=7 > 3+9 > 12" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[13,16,19]+12+8-10" +output = "(Dru[13,16,19]+10) > 2D[4,4]=8 > 16+10 > 26" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "SwordWorld2.5" +input = "Dru[13,16,19]+12+8-10" +output = "(Dru[13,16,19]+10) > 2D[4,5]=9 > 16+10 > 26" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 5 }, +]