diff --git a/lib/bcdice/game_system.rb b/lib/bcdice/game_system.rb index 9bfd7fe1e..69136c40c 100644 --- a/lib/bcdice/game_system.rb +++ b/lib/bcdice/game_system.rb @@ -171,6 +171,7 @@ require "bcdice/game_system/SamsaraBallad" require "bcdice/game_system/Satasupe" require "bcdice/game_system/ScreamHighSchool" +require "bcdice/game_system/Sengensyou" require "bcdice/game_system/SevenFortressMobius" require "bcdice/game_system/ShadowRun" require "bcdice/game_system/ShadowRun4" diff --git a/lib/bcdice/game_system/Sengensyou.rb b/lib/bcdice/game_system/Sengensyou.rb new file mode 100644 index 000000000..365b0435c --- /dev/null +++ b/lib/bcdice/game_system/Sengensyou.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module BCDice + module GameSystem + class Sengensyou < Base + # ゲームシステムの識別子 + ID = 'Sengensyou' + + # ゲームシステム名 + NAME = '千幻抄' + + # ゲームシステム名の読みがな + SORT_KEY = 'せんけんしよう' + + # ダイスボットの使い方 + HELP_MESSAGE = <<~INFO_MESSAGE_TEXT + ・SGS 命中判定・回避判定 + INFO_MESSAGE_TEXT + + register_prefix('SGS') + + def eval_game_system_specific_command(command) + # 命中判定・回避判定 + parser = Command::Parser.new('SGS', round_type: @round_type).restrict_cmp_op_to(nil) + command = parser.parse(command) + + unless command + return nil + end + + dice_list = @randomizer.roll_barabara(3, 6) + dice_total = dice_list.sum() + is_critical = dice_total >= 16 + is_fumble = dice_total <= 5 + additional_text = + if is_critical + "クリティカル" + elsif is_fumble + "ファンブル" + end + modify_text = "#{dice_total}#{Format.modifier(command.modify_number)}" if command.modify_number != 0 + sequence = [ + "(3D6#{Format.modifier(command.modify_number)})", + "#{dice_total}[#{dice_list.join(',')}]", + modify_text, + (dice_total + command.modify_number).to_s, + additional_text, + ].compact + + result = Result.new.tap do |r| + r.text = sequence.join(" > ") + r.critical = is_critical + r.fumble = is_fumble + end + return result + end + end + end +end diff --git a/test/data/Sengensyou.toml b/test/data/Sengensyou.toml new file mode 100644 index 000000000..b9ddc4949 --- /dev/null +++ b/test/data/Sengensyou.toml @@ -0,0 +1,69 @@ +[[ test ]] +game_system = "Sengensyou" +input = "SGS" +output = "(3D6) > 8[4,1,3] > 8" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS" +output = "(3D6) > 16[5,5,6] > 16 > クリティカル" +critical = true +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 5 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS" +output = "(3D6) > 5[1,2,2] > 5 > ファンブル" +fumble = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 2 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS+4+6" +output = "(3D6+10) > 8[4,1,3] > 8+10 > 18" +rands = [ + { sides = 6, value = 4 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS+4+6" +output = "(3D6+10) > 16[5,5,6] > 16+10 > 26 > クリティカル" +critical = true +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 5 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS+4+6" +output = "(3D6+10) > 5[1,2,2] > 5+10 > 15 > ファンブル" +fumble = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 2 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "Sengensyou" +input = "SGS>=5" +output = "" +rands = []