From bb3d81d3da393a07314003f73d8d6c6579b42705 Mon Sep 17 00:00:00 2001 From: Faceless <117694056+Faceless192x@users.noreply.github.com> Date: Mon, 22 Jan 2024 21:58:19 +0900 Subject: [PATCH] =?UTF-8?q?=E3=80=8E=E3=82=A2=E3=83=8B=E3=83=9E=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=80=8F=E3=82=92=E8=BF=BD=E5=8A=A0=20(#669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 判定一式を実装、Rubocop通過済み * オフィシャルに合わせてリネーム * ヘルプの誤りを修正 * [AniMalus] コマンドを完全一致にする * [AniMalus] Array#count でブロックが不要な点を修正 * [AniMalus] 不要な #to_i を削除 --------- Co-authored-by: SAKATA Sinji --- lib/bcdice/game_system.rb | 1 + lib/bcdice/game_system/AniMalus.rb | 221 +++++++++++++++++++++++++++++ test/data/AniMalus.toml | 191 +++++++++++++++++++++++++ 3 files changed, 413 insertions(+) create mode 100644 lib/bcdice/game_system/AniMalus.rb create mode 100644 test/data/AniMalus.toml diff --git a/lib/bcdice/game_system.rb b/lib/bcdice/game_system.rb index b51f92223..aa9c61d01 100644 --- a/lib/bcdice/game_system.rb +++ b/lib/bcdice/game_system.rb @@ -12,6 +12,7 @@ require "bcdice/game_system/Amadeus_Korean" require "bcdice/game_system/AngelGear" require "bcdice/game_system/AnimaAnimus" +require "bcdice/game_system/AniMalus" require "bcdice/game_system/Aoharubaan" require "bcdice/game_system/Arianrhod" require "bcdice/game_system/ArknightsFan" diff --git a/lib/bcdice/game_system/AniMalus.rb b/lib/bcdice/game_system/AniMalus.rb new file mode 100644 index 000000000..25c878863 --- /dev/null +++ b/lib/bcdice/game_system/AniMalus.rb @@ -0,0 +1,221 @@ +# frozen_string_literal: true + +module BCDice + module GameSystem + class AniMalus < Base + # ゲームシステムの識別子 + ID = 'AniMalus' + + # ゲームシステム名 + NAME = 'アニマラス' + + # ゲームシステム名の読みがな + SORT_KEY = 'あにまらす' + + # ダイスボットの使い方 + HELP_MESSAGE = <<~INFO_MESSAGETEXT + ■ステータスのダイス判定 nAM<=t,x n:能力値 t:成功値 x:必要成功数 + 例)3AM<=2,1: ダイスを3個振って、成功値2,必要成功数1で判定。その結果(成功数,成功・失敗)を表示 + + ■探索技能のダイス判定 AI<=t,x t:探索技能レベル x:必要成功数 + 例)AI<=3,1: ダイスを3個振って、探索技能レベル3,必要成功数1で判定。その結果(成功数,成功・失敗)を表示 + + ■攻撃判定 AA<=t t:戦闘技能レベル + 例)AA<=3: ダイスを3個振って、戦闘技能レベル3で判定。その結果(成功・失敗,ダメージ,クリティカル,ファンブル)を表示 + + ■防御判定 AG=t t:攻撃技能レベル + 例)AG=2: ダイスを3個振って、攻撃技能レベル2で判定。その結果(成功・失敗,ダメージ,クリティカル,ファンブル)を表示 + + ■回避判定 AD=t t:攻撃技能レベル + 例)AD=3: ダイスを1個振って、攻撃技能レベル3で判定。その結果(成功・失敗)を表示 + INFO_MESSAGETEXT + + register_prefix('\d*A[MIAGD]') + + def initialize(command) + super(command) + + @sort_barabara_dice = true # バラバラロール(Bコマンド)でソート有 + end + + def eval_game_system_specific_command(command) + resolute_action(command) || + resolute_investigation(command) || + resolute_attacking(command) || + resolute_guarding(command) || + resolute_dodging(command) + end + + private + + # ステータスの判定 + # @param [String] command + # @return [Result] + def resolute_action(command) + m = /^(\d+)AM<=(\d+),(\d)$/.match(command) + return nil unless m + + num_dice = m[1].to_i + num_target = m[2].to_i + num_success = m[3].to_i + + dice = @randomizer.roll_barabara(num_dice, 6).sort + dice_text = dice.join(",") + success_num = dice.count { |val| val <= num_target } + output = "(#{num_dice}AM<=#{num_target},#{num_success}) > #{dice_text} > 成功数#{success_num}" + if success_num >= num_success + output += " > 成功" + return Result.success(output) + else + output += " > 失敗" + return Result.failure(output) + end + end + + # 探索技能の判定 + # @param [String] command + # @return [Result] + def resolute_investigation(command) + m = /^AI<=(\d+),(\d)$/.match(command) + return nil unless m + + num_target = m[1].to_i + num_success = m[2].to_i + + dice = @randomizer.roll_barabara(3, 6).sort + dice_text = dice.join(",") + success_num = dice.count { |val| val <= num_target } + output = "(AI<=#{num_target},#{num_success}) > #{dice_text} > 成功数#{success_num}" + if success_num >= num_success + output += " > 成功" + return Result.success(output) + else + output += " > 失敗" + return Result.failure(output) + end + end + + # 攻撃技能の判定 + # @param [String] command + # @return [Result] + def resolute_attacking(command) + m = /^AA<=(\d+)$/.match(command) + return nil unless m + + num_target = m[1].to_i + + dice = @randomizer.roll_barabara(3, 6).sort + dice_text = dice.join(",") + success_num = dice.count { |val| val <= num_target } + is_critical = (dice[0] == 1 && dice[1] == 2 && dice[2] == 3) + is_fumble = (dice[0] == 4 && dice[1] == 5 && dice[2] == 6) + damage1 = dice.max + damage2 = dice.max + if dice[0] == dice[1] && dice[1] == dice[2] && dice[2] <= num_target + damage2 += 6 + damage1 = damage2 + elsif dice[0] == dice[1] && dice[1] <= num_target + damage2 += 3 + elsif dice[1] == dice[2] && dice[2] <= num_target + damage2 += 3 + end + + return Result.new.tap do |result| + result.critical = is_critical + result.fumble = is_fumble + result.condition = (success_num > 0) + + sequence = [ + "(AA<=#{num_target})", + dice_text, + "成功数#{success_num}", + if result.success? + "成功" + else + "失敗" + end + ].compact + if result.success? + if damage1 == damage2 + sequence.push("ダメージ(#{damage1})") + else + sequence.push("ダメージ(#{damage1}か#{damage2})") + end + end + sequence.push("クリティカル") if result.critical? + sequence.push("ファンブル") if result.fumble? + + result.text = sequence.join(" > ") + end + end + + # 防御技能の判定 + # @param [String] command + # @return [Result] + def resolute_guarding(command) + m = /^AG=(\d+)$/.match(command) + return nil unless m + + num_target = m[1].to_i + + dice = @randomizer.roll_barabara(3, 6).sort + dice_text = dice.join(",") + success_num = dice.count(num_target) + is_critical = (dice[0] == 1 && dice[1] == 2 && dice[2] == 3) + is_fumble = (dice[0] == 4 && dice[1] == 5 && dice[2] == 6) + + return Result.new.tap do |result| + result.critical = is_critical + result.fumble = is_fumble + result.condition = (success_num > 0) + + sequence = [ + "(AG=#{num_target})", + dice_text, + "成功数#{success_num}", + if result.success? + "成功 > ダメージ軽減(#{success_num * 2})" + else + "失敗" + end + ].compact + sequence.push("クリティカル") if result.critical? + sequence.push("ファンブル") if result.fumble? + + result.text = sequence.join(" > ") + end + end + + # 回避技能の判定 + # @param [String] command + # @return [Result] + def resolute_dodging(command) + m = /^AD=(\d+)$/.match(command) + return nil unless m + + num_target = m[1].to_i + + dice = @randomizer.roll_barabara(1, 6) + dice_text = dice.join(",") + success_num = dice.count(num_target) + + return Result.new.tap do |result| + result.condition = (success_num > 0) + + sequence = [ + "(AD=#{num_target})", + dice_text, + "成功数#{success_num}", + if result.success? + "成功(ダメージ無効)" + else + "失敗" + end + ].compact + + result.text = sequence.join(" > ") + end + end + end + end +end diff --git a/test/data/AniMalus.toml b/test/data/AniMalus.toml new file mode 100644 index 000000000..a2fb83671 --- /dev/null +++ b/test/data/AniMalus.toml @@ -0,0 +1,191 @@ +[[ test ]] +game_system = "AniMalus" +input = "3AM<=2,1 ステータス判定、成功" +output = "(3AM<=2,1) > 2,6,6 > 成功数1 > 成功" +success = true +rands = [ + { sides = 6, value = 2 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "3AM<=2,2 失敗" +output = "(3AM<=2,2) > 3,6,6 > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 6 }, +] + + +[[ test ]] +game_system = "AniMalus" +input = "AI<=3,1 探索技能判定、成功" +output = "(AI<=3,1) > 3,6,6 > 成功数1 > 成功" +success = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AI<=3,1 探索技能判定、失敗" +output = "(AI<=3,1) > 4,6,6 > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 攻撃判定、成功" +output = "(AA<=3) > 3,6,6 > 成功数1 > 成功 > ダメージ(6)" +success = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 失敗" +output = "(AA<=3) > 4,6,6 > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 攻撃判定、成功、クリティカル" +output = "(AA<=3) > 1,2,3 > 成功数3 > 成功 > ダメージ(3) > クリティカル" +success = true +critical = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 失敗、ファンブル" +output = "(AA<=3) > 4,5,6 > 成功数0 > 失敗 > ファンブル" +failure = true +fumble = true +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 攻撃判定、二重成功" +output = "(AA<=3) > 3,3,6 > 成功数2 > 成功 > ダメージ(6か9)" +success = true +rands = [ + { sides = 6, value = 3 }, + { sides = 6, value = 3 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 攻撃判定、二重成功" +output = "(AA<=3) > 2,3,3 > 成功数3 > 成功 > ダメージ(3か6)" +success = true +rands = [ + { sides = 6, value = 2 }, + { sides = 6, value = 3 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AA<=3 攻撃判定、三重成功" +output = "(AA<=3) > 3,3,3 > 成功数3 > 成功 > ダメージ(9)" +success = true +rands = [ + { sides = 6, value = 3 }, + { sides = 6, value = 3 }, + { sides = 6, value = 3 }, +] + + +[[ test ]] +game_system = "AniMalus" +input = "AG=2 防御判定、成功" +output = "(AG=2) > 2,2,3 > 成功数2 > 成功 > ダメージ軽減(4)" +success = true +rands = [ + { sides = 6, value = 2 }, + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AG=2 失敗" +output = "(AG=2) > 4,6,6 > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AG=2 成功、クリティカル" +output = "(AG=2) > 1,2,3 > 成功数1 > 成功 > ダメージ軽減(2) > クリティカル" +success = true +critical = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AG=2 失敗、ファンブル" +output = "(AG=2) > 4,5,6 > 成功数0 > 失敗 > ファンブル" +failure = true +fumble = true +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, +] + + +[[ test ]] +game_system = "AniMalus" +input = "AD=2 防御判定、成功" +output = "(AD=2) > 2 > 成功数1 > 成功(ダメージ無効)" +success = true +rands = [ + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "AniMalus" +input = "AD=2 失敗" +output = "(AD=2) > 1 > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 6, value = 1 }, +] +