From 9fe05163615f3ef8be5853582458120d58080a56 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sat, 17 Feb 2024 22:22:10 +0900 Subject: [PATCH 01/20] =?UTF-8?q?HELP=5FMESSAGE=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 35 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 0b552afc3..a12c993bb 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -13,25 +13,38 @@ class ArknightsFan < Base SORT_KEY = "ああくないつTRPGはいたふと" HELP_MESSAGE = <<~TEXT - ■ 判定 (nADm>=x) - nDmのダイスロールをして、x 以下であれば成功。 + ■ 能力値判定 (nADm<=x) + nDmのダイスロールをして、出目が x 以下であれば成功。 出目が91以上でエラー。 出目が10以下でクリティカル。 - ■ 判定 (nABm>=x) + ■ 攻撃/防御判定 (nABm<=x) nBmのダイスロールをして、 - x 以下であれば成功数+1。 - 出目が91以上でエラー。成功数+1。 - 出目が10以下でクリティカル。成功数-1。 + 出目が x 以下であれば成功数+1。 + 出目が91以上でエラー。成功数-1。 + 出目が10以下でクリティカル。成功数+1。 上記による成功数をカウント。 - ■ 判定 (nABm>=x--役職) + ■ 役職効果付き攻撃判定 (nABm<=x--役職名) nBmのダイスロールをして、 出目が x 以下であれば成功数+1。 - 出目が91以上でエラー。成功数+1。 - 出目が10以下でクリティカル。成功数-1。 - 上記による成功数をカウントした上で、以下の役職による成功数増加効果を適応。 - 狙撃(SNIPER) 成功数1以上のとき、成功数+1。 + 出目が91以上でエラー。成功数-1。 + 出目が10以下でクリティカル。成功数+1。 + 上記による成功数をカウントした上で、以下の役職名による成功数増加効果を適応。 + 狙撃(SNIPER): 成功数1以上のとき、成功数+1。 + + ■ 増悪判定(--WORSENING) + 症状を「末梢神経障害」「内臓機能不全」「精神症状」からランダムに選択。 + 継続ラウンド数を1d6+1で判定。 + + ■ 中毒判定(--ADDICTION) + 症状を「中枢神経障害」「多臓器不全」「急性ストレス反応」からランダムに選択。 + + ■ 判定の省略表記 + nADm、nABm、nABmにおいて、 + n(ダイス個数)を省略した場合、1として扱われる。 + m(ダイス種類)を省略した場合、100として扱われる。 + 例えば、AD<=90は1AD100<=90として解釈される。 TEXT register_prefix('\d*AD\d*', '\d*AB\d*', '--ADDICTION', '--WORSENING') From 385f64b42d550bc2810359c032651f89d9d54d95 Mon Sep 17 00:00:00 2001 From: Ayase00 Date: Sun, 28 Apr 2024 21:58:38 +0900 Subject: [PATCH 02/20] Defined func check_roll(), enum-like module Status To clearfy the priority of "success", "falure", "critical", "error". --- lib/bcdice/game_system/ArknightsFan.rb | 85 ++++++++++++++++++-------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index a12c993bb..013991283 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -55,6 +55,51 @@ def eval_game_system_specific_command(command) private + module Status + CRITICAL = 1 + SUCCESS = 2 + FAILURE = 3 + ERROR = 4 + end + + STATUS_NAME = { + Status::CRITICAL => 'クリティカル!', + Status::SUCCESS => '成功', + Status::FAILURE => '失敗', + Status::ERROR => 'エラー' + } + + # クリティカル、エラー、成功失敗周りの閾値や優先関係が複雑かつルールが変動する可能性があるため、明示的にルール管理するための関数。 + def check_roll(roll_result, target) + success = roll_result <= target + + crierror = + if roll_result <= 10 + "Critical" + elsif roll_result >= 91 + "Error" + else + "Neutral" + end + + result = + if success && (crierror == "Critical") + Status::CRITICAL + elsif success && (crierror == "Neutral") + Status::SUCCESS + elsif success && (crierror == "Error") + Status::SUCCESS + elsif !success && (crierror == "Critical") + Status::FAILURE + elsif !success && (crierror == "Neutral") + Status::FAILURE + elsif !success && (crierror == "Error") + Status::ERROR + end + + return result + end + def roll_ad(command) m = /^(\d*)AD(\d*)<=(\d+)$/.match(command) return nil unless m @@ -89,31 +134,9 @@ def roll_ab(command) def roll_d(command, times, sides, target) dice_list = @randomizer.roll_barabara(times, sides).sort total = dice_list.sum - success = total <= target - crierror = - if total <= 10 - "Critical" - elsif total >= 91 - "Error" - else - "Neutral" - end - - result = - if success && (crierror == "Critical") - "クリティカル!" - elsif success && (crierror == "Neutral") - "成功" - elsif success && (crierror == "Error") - "成功" - elsif !success && (crierror == "Critical") - "失敗" - elsif !success && (crierror == "Neutral") - "失敗" - elsif !success && (crierror == "Error") - "エラー" - end + result = check_roll(roll_result = total, target) + result = STATUS_NAME[result] if times == 1 return "(#{command}) > #{dice_list.join(',')} > #{result}" @@ -152,9 +175,17 @@ def process_b(times, sides, target) error_count = 0 dice_list.each do |value| - success_count += 1 if value <= target - critical_count += 1 if value <= 10 - error_count += 1 if value >= 91 + case check_roll(roll_result = value, target) + when Status::CRITICAL + critical_count += 1 + success_count += 1 + when Status::SUCCESS + success_count += 1 + when Status::FAILURE + # Nothing to do + when Status::ERROR + error_count += 1 + end end return [dice_list, success_count, critical_count, error_count] From 01ba181042e41cc9a1aeab8efbbcdc27806fdb4b Mon Sep 17 00:00:00 2001 From: Ayase00 Date: Sun, 28 Apr 2024 23:07:56 +0900 Subject: [PATCH 03/20] Enable "Type"1 (e.g. Sniper1) in roll_ab. --- lib/bcdice/game_system/ArknightsFan.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 013991283..1d7d0935c 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -113,18 +113,19 @@ def roll_ad(command) end def roll_ab(command) - m = /^(\d*)AB(\d*)<=(\d+)(?:--([^\d\s]+)(0)?)?$/.match(command) + m = /^(\d*)AB(\d*)<=(\d+)(?:--([^\d\s]+)(0|1)?)?$/.match(command) return nil unless m times = m[1] sides = m[2] target = m[3].to_i type = m[4] - suffix = m[5] + type_enable = m[5] times = !times.empty? ? times.to_i : 1 sides = !sides.empty? ? sides.to_i : 100 + type_enable = !type_enable.nil? ? type_enable.to_i : 1 - if suffix || type.nil? + if type.nil? || (type_enable == 0) roll_b(command, times, sides, target) else roll_b_withtype(command, times, sides, target, type) From 32eaa6378276f0b74c1816315e29ac4ded2884b8 Mon Sep 17 00:00:00 2001 From: Ayase00 Date: Sun, 28 Apr 2024 23:09:27 +0900 Subject: [PATCH 04/20] Add test caces for last 2 commits. --- test/data/ArknightsFan.toml | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 2d09d9980..007189a7b 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -54,6 +54,14 @@ rands = [ { sides = 100, value = 95 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=5" +output = "(AD<=5) > 9 > 失敗" +rands = [ + { sides = 100, value = 9 }, +] + [[ test ]] game_system = "ArknightsFan" input = "AB<=70" @@ -146,6 +154,36 @@ rands = [ { sides = 100, value = 10 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=5" +output = "(3AB100<=5) > [9,10,11] > 0+0C-0E > 成功数0" +rands = [ + { sides = 100, value = 9 }, + { sides = 100, value = 10 }, + { sides = 100, value = 11 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=5" +output = "(3AB100<=5) > [5,10,11] > 1+1C-0E > 成功数2" +rands = [ + { sides = 100, value = 5 }, + { sides = 100, value = 10 }, + { sides = 100, value = 11 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=95" +output = "(3AB100<=95) > [90,95,96] > 2+0C-1E > 成功数1" +rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 95 }, + { sides = 100, value = 96 }, +] + [[ test ]] game_system = "ArknightsFan" input = "4AB100<=60" @@ -360,6 +398,16 @@ rands = [ { sides = 100, value = 50 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=70--Sniper1" +output = "(3AB100<=70--SNIPER1) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, +] + [[ test ]] game_system = "ArknightsFan" input = "3AB100<=70--先鋒" @@ -370,6 +418,26 @@ rands = [ { sides = 100, value = 50 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=70--先鋒1" +output = "(3AB100<=70--先鋒1) > [50,50,90] > 2+0C-0E+0(先鋒) > 成功数2" +rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=70--先鋒0" +output = "(3AB100<=70--先鋒0) > [50,50,90] > 2+0C-0E > 成功数2" +rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, +] + [[ test ]] game_system = "ArknightsFan" input = "--WORSENING" From 5c7e76047f457e0c33826278b11375bd389615aa Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Thu, 8 Aug 2024 22:01:05 +0900 Subject: [PATCH 05/20] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=B9=E6=95=B0?= =?UTF-8?q?=E3=81=A8=E7=9B=AE=E6=A8=99=E5=80=A4=E3=82=92=E5=9B=9B=E5=89=87?= =?UTF-8?q?=E6=BC=94=E7=AE=97=E5=8F=AF=E8=83=BD=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1+2AB<=40*2 とかできるよ! --- lib/bcdice/game_system/ArknightsFan.rb | 16 ++-- test/data/ArknightsFan.toml | 117 ++++++++++++++++++++++++- 2 files changed, 124 insertions(+), 9 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 1d7d0935c..016cbc6f4 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -47,7 +47,7 @@ class ArknightsFan < Base 例えば、AD<=90は1AD100<=90として解釈される。 TEXT - register_prefix('\d*AD\d*', '\d*AB\d*', '--ADDICTION', '--WORSENING') + register_prefix('[-+*/\d]*AD\d*', '[-+*/\d]*AB\d*', '--ADDICTION', '--WORSENING') def eval_game_system_specific_command(command) roll_ad(command) || roll_ab(command) || roll_addiction(command) || roll_worsening(command) @@ -101,27 +101,29 @@ def check_roll(roll_result, target) end def roll_ad(command) - m = /^(\d*)AD(\d*)<=(\d+)$/.match(command) + # -は文字クラスの先頭または最後に置く。 + # そうしないと範囲指定子として解釈される。 + m = %r{^([-+*/\d]*)AD(\d*)<=([-+*/\d]+)$}.match(command) return nil unless m times = m[1] sides = m[2] - target = m[3].to_i - times = !times.empty? ? times.to_i : 1 + target = Arithmetic.eval(m[3], @round_type) + times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 return roll_d(command, times, sides, target) end def roll_ab(command) - m = /^(\d*)AB(\d*)<=(\d+)(?:--([^\d\s]+)(0|1)?)?$/.match(command) + m = %r{^([-+*/\d]*)AB(\d*)<=([-+*/\d]+)(?:--([^\d\s]+)(0|1)?)?$}.match(command) return nil unless m times = m[1] sides = m[2] - target = m[3].to_i + target = Arithmetic.eval(m[3], @round_type) type = m[4] type_enable = m[5] - times = !times.empty? ? times.to_i : 1 + times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 type_enable = !type_enable.nil? ? type_enable.to_i : 1 diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 007189a7b..9241f64a4 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -62,6 +62,46 @@ rands = [ { sides = 100, value = 9 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=10+20" +output = "(AD<=10+20) > 30 > 成功" +rands = [ + { sides = 100, value = 30 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=40-10" +output = "(AD<=40-10) > 30 > 成功" +rands = [ + { sides = 100, value = 30 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=20*2" +output = "(AD<=20*2) > 40 > 成功" +rands = [ + { sides = 100, value = 40 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=69/5" +output = "(AD<=69/5) > 13 > 成功" +rands = [ + { sides = 100, value = 13 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AD<=69/5" +output = "(AD<=69/5) > 14 > 失敗" +rands = [ + { sides = 100, value = 14 }, +] + [[ test ]] game_system = "ArknightsFan" input = "AB<=70" @@ -285,8 +325,41 @@ rands = [ [[ test ]] game_system = "ArknightsFan" -input = "4AB100<=60" -output = "(4AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +input = "2+2AB100<=60" +output = "(2+2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +rands = [ + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, + { sides = 100, value = 1 }, + { sides = 100, value = 1 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "2*2AB<=60" +output = "(2*2AB<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +rands = [ + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, + { sides = 100, value = 1 }, + { sides = 100, value = 1 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "6-2AB100<=60" +output = "(6-2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +rands = [ + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, + { sides = 100, value = 1 }, + { sides = 100, value = 1 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "9/2AB100<=60" +output = "(9/2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" rands = [ { sides = 100, value = 50 }, { sides = 100, value = 50 }, @@ -294,6 +367,46 @@ rands = [ { sides = 100, value = 1 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "AB<=10+20" +output = "(AB<=10+20) > [30] > 1+0C-0E > 成功数1" +rands = [ + { sides = 100, value = 30 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AB<=40-10" +output = "(AB<=40-10) > [30] > 1+0C-0E > 成功数1" +rands = [ + { sides = 100, value = 30 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AB<=20*2" +output = "(AB<=20*2) > [40] > 1+0C-0E > 成功数1" +rands = [ + { sides = 100, value = 40 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AB<=69/5" +output = "(AB<=69/5) > [13] > 1+0C-0E > 成功数1" +rands = [ + { sides = 100, value = 13 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "AB<=69/5" +output = "(AB<=69/5) > [14] > 0+0C-0E > 成功数0" +rands = [ + { sides = 100, value = 14 }, +] + [[ test ]] game_system = "ArknightsFan" input = "AB<=70--Sniper" From 1f879051daf0a86f2ba270de1795f2b710899504 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Thu, 8 Aug 2024 22:44:02 +0900 Subject: [PATCH 06/20] Rubocopped. --- lib/bcdice/game_system/ArknightsFan.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 016cbc6f4..a13ed1794 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -64,10 +64,10 @@ module Status STATUS_NAME = { Status::CRITICAL => 'クリティカル!', - Status::SUCCESS => '成功', - Status::FAILURE => '失敗', - Status::ERROR => 'エラー' - } + Status::SUCCESS => '成功', + Status::FAILURE => '失敗', + Status::ERROR => 'エラー' + }.freeze # クリティカル、エラー、成功失敗周りの閾値や優先関係が複雑かつルールが変動する可能性があるため、明示的にルール管理するための関数。 def check_roll(roll_result, target) @@ -103,7 +103,7 @@ def check_roll(roll_result, target) def roll_ad(command) # -は文字クラスの先頭または最後に置く。 # そうしないと範囲指定子として解釈される。 - m = %r{^([-+*/\d]*)AD(\d*)<=([-+*/\d]+)$}.match(command) + m = %r{^([-+*/\d]*)AD(\d*)<=([-+*/\d]+)$}.match(command) return nil unless m times = m[1] @@ -138,7 +138,7 @@ def roll_d(command, times, sides, target) dice_list = @randomizer.roll_barabara(times, sides).sort total = dice_list.sum - result = check_roll(roll_result = total, target) + result = check_roll(total, target) result = STATUS_NAME[result] if times == 1 @@ -178,7 +178,7 @@ def process_b(times, sides, target) error_count = 0 dice_list.each do |value| - case check_roll(roll_result = value, target) + case check_roll(value, target) when Status::CRITICAL critical_count += 1 success_count += 1 From abba1e492721d0f305830c4c43184c4b56734062 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Mon, 12 Aug 2024 14:16:12 +0900 Subject: [PATCH 07/20] =?UTF-8?q?AD=E3=83=80=E3=82=A4=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E7=B5=90=E6=9E=9C=E3=82=92Result=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=A7=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 15 ++++++++++++--- test/data/ArknightsFan.toml | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index a13ed1794..04ecc8ec6 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -139,12 +139,21 @@ def roll_d(command, times, sides, target) total = dice_list.sum result = check_roll(total, target) - result = STATUS_NAME[result] if times == 1 - return "(#{command}) > #{dice_list.join(',')} > #{result}" + result_text = "(#{command}) > #{dice_list.join(',')} > #{STATUS_NAME[result]}" else - return "(#{command}) > #{total}[#{dice_list.join(',')}] > #{result}" + result_text = "(#{command}) > #{total}[#{dice_list.join(',')}] > #{STATUS_NAME[result]}" + end + case result + when Status::CRITICAL + Result.critical(result_text) + when Status::SUCCESS + Result.success(result_text) + when Status::FAILURE + Result.failure(result_text) + when Status::ERROR + Result.fumble(result_text) end end diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 9241f64a4..26e23bd5e 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -2,6 +2,7 @@ game_system = "ArknightsFan" input = "AD<=70" output = "(AD<=70) > 50 > 成功" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -10,6 +11,7 @@ rands = [ game_system = "ArknightsFan" input = "AD100<=70" output = "(AD100<=70) > 50 > 成功" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -18,6 +20,7 @@ rands = [ game_system = "ArknightsFan" input = "1AD<=70" output = "(1AD<=70) > 50 > 成功" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -26,6 +29,7 @@ rands = [ game_system = "ArknightsFan" input = "1AD100<=70" output = "(1AD100<=70) > 50 > 成功" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -34,6 +38,8 @@ rands = [ game_system = "ArknightsFan" input = "AD<=70" output = "(AD<=70) > 10 > クリティカル!" +critical = true +success = true rands = [ { sides = 100, value = 10 }, ] @@ -42,6 +48,8 @@ rands = [ game_system = "ArknightsFan" input = "AD<=70" output = "(AD<=70) > 91 > エラー" +fumble = true +failure = true rands = [ { sides = 100, value = 91 }, ] @@ -50,6 +58,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=99" output = "(AD<=99) > 95 > 成功" +success = true rands = [ { sides = 100, value = 95 }, ] @@ -58,6 +67,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=5" output = "(AD<=5) > 9 > 失敗" +failure = true rands = [ { sides = 100, value = 9 }, ] @@ -66,6 +76,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=10+20" output = "(AD<=10+20) > 30 > 成功" +success = true rands = [ { sides = 100, value = 30 }, ] @@ -74,6 +85,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=40-10" output = "(AD<=40-10) > 30 > 成功" +success = true rands = [ { sides = 100, value = 30 }, ] @@ -82,6 +94,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=20*2" output = "(AD<=20*2) > 40 > 成功" +success = true rands = [ { sides = 100, value = 40 }, ] @@ -90,6 +103,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=69/5" output = "(AD<=69/5) > 13 > 成功" +success = true rands = [ { sides = 100, value = 13 }, ] @@ -98,6 +112,7 @@ rands = [ game_system = "ArknightsFan" input = "AD<=69/5" output = "(AD<=69/5) > 14 > 失敗" +failure = true rands = [ { sides = 100, value = 14 }, ] From 4134d378846ef4f9dab50806f7b040ea68909733 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Mon, 12 Aug 2024 14:44:19 +0900 Subject: [PATCH 08/20] =?UTF-8?q?AB=E3=83=80=E3=82=A4=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E7=B5=90=E6=9E=9C=E3=82=92Result=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=A7=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 16 +++++- test/data/ArknightsFan.toml | 72 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 04ecc8ec6..2f53e3e14 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -161,7 +161,13 @@ def roll_b(command, times, sides, target) dice_list, success_count, critical_count, error_count = process_b(times, sides, target) result_count = success_count + critical_count - error_count - return "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E > 成功数#{result_count}" + result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E > 成功数#{result_count}" + Result.new.tap do |r| + r.text = result_text + r.condition = result_count > 0 + r.critical = critical_count > 0 + r.fumble = error_count > 0 + end end def roll_b_withtype(command, times, sides, target, type) @@ -176,7 +182,13 @@ def roll_b_withtype(command, times, sides, target, type) end result_count += type_effect - return "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E+#{type_effect}(#{type}) > 成功数#{result_count}" + result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E+#{type_effect}(#{type}) > 成功数#{result_count}" + Result.new.tap do |r| + r.text = result_text + r.condition = result_count > 0 + r.critical = critical_count > 0 + r.fumble = error_count > 0 + end end def process_b(times, sides, target) diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 26e23bd5e..f785012af 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -121,6 +121,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=70" output = "(AB<=70) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -129,6 +130,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB<=70" output = "(1AB<=70) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -137,6 +139,7 @@ rands = [ game_system = "ArknightsFan" input = "AB100<=70" output = "(AB100<=70) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -145,6 +148,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB100<=70" output = "(1AB100<=70) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -153,6 +157,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70" output = "(3AB100<=70) > [50,50,90] > 2+0C-0E > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -163,6 +168,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB<=70" output = "(3AB<=70) > [50,50,90] > 2+0C-0E > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -173,6 +179,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70 いろは" output = "(3AB100<=70) > [50,50,90] > 2+0C-0E > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -183,6 +190,8 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70" output = "(3AB100<=70) > [50,50,91] > 2+0C-1E > 成功数1" +fumble = true +success = true rands = [ { sides = 100, value = 91 }, { sides = 100, value = 50 }, @@ -193,6 +202,8 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70" output = "(3AB100<=70) > [50,50,100] > 2+0C-1E > 成功数1" +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 50 }, @@ -203,6 +214,9 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70" output = "(3AB100<=70) > [10,50,100] > 2+1C-1E > 成功数2" +critical = true +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 50 }, @@ -213,6 +227,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=5" output = "(3AB100<=5) > [9,10,11] > 0+0C-0E > 成功数0" +failure = true rands = [ { sides = 100, value = 9 }, { sides = 100, value = 10 }, @@ -223,6 +238,8 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=5" output = "(3AB100<=5) > [5,10,11] > 1+1C-0E > 成功数2" +critical = true +success = true rands = [ { sides = 100, value = 5 }, { sides = 100, value = 10 }, @@ -233,6 +250,8 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=95" output = "(3AB100<=95) > [90,95,96] > 2+0C-1E > 成功数1" +fumble = true +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 95 }, @@ -243,6 +262,9 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,1,100,100] > 2+2C-2E > 成功数2" +critical = true +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -254,6 +276,9 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,50,100,100] > 2+1C-2E > 成功数1" +critical = true +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -265,6 +290,9 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,70,100,100] > 1+1C-2E > 成功数0" +critical = true +fumble = true +failure = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -276,6 +304,8 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [50,50,100,100] > 2+0C-2E > 成功数0" +fumble = true +failure = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -287,6 +317,8 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [50,70,100,100] > 1+0C-2E > 成功数-1" +fumble = true +failure = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -298,6 +330,8 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [70,70,100,100] > 0+0C-2E > 成功数-2" +fumble = true +failure = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -309,6 +343,9 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,1,70,100] > 2+2C-1E > 成功数3" +critical = true +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 70 }, @@ -320,6 +357,9 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,1,50,100] > 3+2C-1E > 成功数4" +critical = true +fumble = true +success = true rands = [ { sides = 100, value = 100 }, { sides = 100, value = 50 }, @@ -331,6 +371,8 @@ rands = [ game_system = "ArknightsFan" input = "4AB100<=60" output = "(4AB100<=60) > [1,1,50,70] > 3+2C-0E > 成功数5" +critical = true +success = true rands = [ { sides = 100, value = 70 }, { sides = 100, value = 50 }, @@ -342,6 +384,8 @@ rands = [ game_system = "ArknightsFan" input = "2+2AB100<=60" output = "(2+2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +critical = true +success = true rands = [ { sides = 100, value = 50 }, { sides = 100, value = 50 }, @@ -353,6 +397,8 @@ rands = [ game_system = "ArknightsFan" input = "2*2AB<=60" output = "(2*2AB<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +critical = true +success = true rands = [ { sides = 100, value = 50 }, { sides = 100, value = 50 }, @@ -364,6 +410,8 @@ rands = [ game_system = "ArknightsFan" input = "6-2AB100<=60" output = "(6-2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +critical = true +success = true rands = [ { sides = 100, value = 50 }, { sides = 100, value = 50 }, @@ -375,6 +423,8 @@ rands = [ game_system = "ArknightsFan" input = "9/2AB100<=60" output = "(9/2AB100<=60) > [1,1,50,50] > 4+2C-0E > 成功数6" +critical = true +success = true rands = [ { sides = 100, value = 50 }, { sides = 100, value = 50 }, @@ -386,6 +436,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=10+20" output = "(AB<=10+20) > [30] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 30 }, ] @@ -394,6 +445,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=40-10" output = "(AB<=40-10) > [30] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 30 }, ] @@ -402,6 +454,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=20*2" output = "(AB<=20*2) > [40] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 40 }, ] @@ -410,6 +463,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=69/5" output = "(AB<=69/5) > [13] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 13 }, ] @@ -418,6 +472,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=69/5" output = "(AB<=69/5) > [14] > 0+0C-0E > 成功数0" +failure = true rands = [ { sides = 100, value = 14 }, ] @@ -426,6 +481,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=70--Sniper" output = "(AB<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -434,6 +490,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB<=70--Sniper" output = "(1AB<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -442,6 +499,7 @@ rands = [ game_system = "ArknightsFan" input = "AB100<=70--Sniper" output = "(AB100<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -450,6 +508,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB100<=70--Sniper" output = "(1AB100<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -458,6 +517,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--Sniper" output = "(3AB100<=70--SNIPER) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -468,6 +528,8 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--Sniper" output = "(3AB100<=70--SNIPER) > [50,80,91] > 1+0C-1E+0(SNIPER) > 成功数0" +fumble = true +failure = true rands = [ { sides = 100, value = 91 }, { sides = 100, value = 50 }, @@ -478,6 +540,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--Sniper あ" output = "(3AB100<=70--SNIPER) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -488,6 +551,7 @@ rands = [ game_system = "ArknightsFan" input = "AB<=70--Sniper0" output = "(AB<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -496,6 +560,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB<=70--Sniper0" output = "(1AB<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -504,6 +569,7 @@ rands = [ game_system = "ArknightsFan" input = "AB100<=70--Sniper0" output = "(AB100<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -512,6 +578,7 @@ rands = [ game_system = "ArknightsFan" input = "1AB100<=70--Sniper0" output = "(1AB100<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +success = true rands = [ { sides = 100, value = 50 }, ] @@ -520,6 +587,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--Sniper0" output = "(3AB100<=70--SNIPER0) > [50,50,90] > 2+0C-0E > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -530,6 +598,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--Sniper1" output = "(3AB100<=70--SNIPER1) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -540,6 +609,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--先鋒" output = "(3AB100<=70--先鋒) > [50,50,90] > 2+0C-0E+0(先鋒) > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -550,6 +620,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--先鋒1" output = "(3AB100<=70--先鋒1) > [50,50,90] > 2+0C-0E+0(先鋒) > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, @@ -560,6 +631,7 @@ rands = [ game_system = "ArknightsFan" input = "3AB100<=70--先鋒0" output = "(3AB100<=70--先鋒0) > [50,50,90] > 2+0C-0E > 成功数2" +success = true rands = [ { sides = 100, value = 90 }, { sides = 100, value = 50 }, From 8b290ee4032fef16a38f4bcc16aad598a7fd2dc9 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 29 Sep 2024 16:21:26 +0900 Subject: [PATCH 09/20] =?UTF-8?q?SNIPER=E3=81=AE=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=E3=81=A8=E5=8B=95=E4=BD=9C=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 今後の役職フラグ追加に向けて、roll_b_withtypeにtype_status(旧 type_enable)も渡す仕様に変更 - SNIPERフラグが指定されたが発動しなかったとき、発動しなかった理由に関 わらず+0(SNIPER)が表示されるようにした --- lib/bcdice/game_system/ArknightsFan.rb | 28 ++++++++++------- test/data/ArknightsFan.toml | 43 +++----------------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 2f53e3e14..0cb7cc065 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -122,15 +122,15 @@ def roll_ab(command) sides = m[2] target = Arithmetic.eval(m[3], @round_type) type = m[4] - type_enable = m[5] + type_status = m[5] times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 - type_enable = !type_enable.nil? ? type_enable.to_i : 1 + type_status = !type_status.nil? ? type_status.to_i : 1 - if type.nil? || (type_enable == 0) + if type.nil? roll_b(command, times, sides, target) else - roll_b_withtype(command, times, sides, target, type) + roll_b_withtype(command, times, sides, target, type, type_status) end end @@ -170,19 +170,25 @@ def roll_b(command, times, sides, target) end end - def roll_b_withtype(command, times, sides, target, type) + def roll_b_withtype(command, times, sides, target, type, type_status) dice_list, success_count, critical_count, error_count = process_b(times, sides, target) result_count = success_count + critical_count - error_count - type_effect = - if (type == "SNIPER") && (result_count > 0) - 1 + case type + when "SNIPER" + if (type_status != 0) && (result_count > 0) + result_mod = 1 else - 0 + result_mod = 0 end - result_count += type_effect + end - result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E+#{type_effect}(#{type}) > 成功数#{result_count}" + if !result_mod.nil? + result_count += result_mod + result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E+#{result_mod}(#{type}) > 成功数#{result_count}" + else + result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E > 成功数#{result_count}" + end Result.new.tap do |r| r.text = result_text r.condition = result_count > 0 diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index f785012af..63fdc44ab 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -550,7 +550,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "AB<=70--Sniper0" -output = "(AB<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +output = "(AB<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" success = true rands = [ { sides = 100, value = 50 }, @@ -559,7 +559,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "1AB<=70--Sniper0" -output = "(1AB<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +output = "(1AB<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" success = true rands = [ { sides = 100, value = 50 }, @@ -568,7 +568,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "AB100<=70--Sniper0" -output = "(AB100<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +output = "(AB100<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" success = true rands = [ { sides = 100, value = 50 }, @@ -577,7 +577,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "1AB100<=70--Sniper0" -output = "(1AB100<=70--SNIPER0) > [50] > 1+0C-0E > 成功数1" +output = "(1AB100<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" success = true rands = [ { sides = 100, value = 50 }, @@ -586,7 +586,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "3AB100<=70--Sniper0" -output = "(3AB100<=70--SNIPER0) > [50,50,90] > 2+0C-0E > 成功数2" +output = "(3AB100<=70--SNIPER0) > [50,50,90] > 2+0C-0E+0(SNIPER) > 成功数2" success = true rands = [ { sides = 100, value = 90 }, @@ -605,39 +605,6 @@ rands = [ { sides = 100, value = 50 }, ] -[[ test ]] -game_system = "ArknightsFan" -input = "3AB100<=70--先鋒" -output = "(3AB100<=70--先鋒) > [50,50,90] > 2+0C-0E+0(先鋒) > 成功数2" -success = true -rands = [ - { sides = 100, value = 90 }, - { sides = 100, value = 50 }, - { sides = 100, value = 50 }, -] - -[[ test ]] -game_system = "ArknightsFan" -input = "3AB100<=70--先鋒1" -output = "(3AB100<=70--先鋒1) > [50,50,90] > 2+0C-0E+0(先鋒) > 成功数2" -success = true -rands = [ - { sides = 100, value = 90 }, - { sides = 100, value = 50 }, - { sides = 100, value = 50 }, -] - -[[ test ]] -game_system = "ArknightsFan" -input = "3AB100<=70--先鋒0" -output = "(3AB100<=70--先鋒0) > [50,50,90] > 2+0C-0E > 成功数2" -success = true -rands = [ - { sides = 100, value = 90 }, - { sides = 100, value = 50 }, - { sides = 100, value = 50 }, -] - [[ test ]] game_system = "ArknightsFan" input = "--WORSENING" From 833b9d0b9347411c5913d2df1be0f75545473e60 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 29 Sep 2024 17:55:56 +0900 Subject: [PATCH 10/20] =?UTF-8?q?=E5=BD=B9=E8=81=B7=E5=8A=B9=E6=9E=9C?= =?UTF-8?q?=E3=81=ABSNI=E3=82=92=E6=96=B0=E8=A8=AD=E3=81=97SNIPER=E3=82=92?= =?UTF-8?q?=E9=9D=9E=E6=8E=A8=E5=A5=A8=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 24 +++++++-- test/data/ArknightsFan.toml | 71 ++++++++++++++++---------- 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 0cb7cc065..07d791895 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -25,13 +25,15 @@ class ArknightsFan < Base 出目が10以下でクリティカル。成功数+1。 上記による成功数をカウント。 - ■ 役職効果付き攻撃判定 (nABm<=x--役職名) + ■ 役職効果付き攻撃判定 (nABm<=x--役職名h) + h: 健康状態(0: 健康、1: 中等症、2: 重症) nBmのダイスロールをして、 出目が x 以下であれば成功数+1。 出目が91以上でエラー。成功数-1。 出目が10以下でクリティカル。成功数+1。 上記による成功数をカウントした上で、以下の役職名による成功数増加効果を適応。 - 狙撃(SNIPER): 成功数1以上のとき、成功数+1。 + 狙撃(SNI): 健康(h=0)かつ成功数1以上のとき、成功数+1。 + 健康状態hを省略した場合、健康(h=0)として扱われる。 ■ 増悪判定(--WORSENING) 症状を「末梢神経障害」「内臓機能不全」「精神症状」からランダムに選択。 @@ -115,7 +117,7 @@ def roll_ad(command) end def roll_ab(command) - m = %r{^([-+*/\d]*)AB(\d*)<=([-+*/\d]+)(?:--([^\d\s]+)(0|1)?)?$}.match(command) + m = %r{^([-+*/\d]*)AB(\d*)<=([-+*/\d]+)(?:--([^\d\s]+)([0-2])?)?$}.match(command) return nil unless m times = m[1] @@ -125,7 +127,13 @@ def roll_ab(command) type_status = m[5] times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 - type_status = !type_status.nil? ? type_status.to_i : 1 + if !type_status.nil? + type_status = type_status.to_i + elsif type == "SNIPER" # スプレッドシート版キャラシの後方互換性のために必要 + type_status = 1 + else + type_status = 0 + end if type.nil? roll_b(command, times, sides, target) @@ -175,7 +183,13 @@ def roll_b_withtype(command, times, sides, target, type, type_status) result_count = success_count + critical_count - error_count case type - when "SNIPER" + when "SNI" + if (type_status == 0) && (result_count > 0) + result_mod = 1 + else + result_mod = 0 + end + when "SNIPER" # スプレッドシート版キャラシの後方互換性のため残している if (type_status != 0) && (result_count > 0) result_mod = 1 else diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 63fdc44ab..589224410 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -479,8 +479,8 @@ rands = [ [[ test ]] game_system = "ArknightsFan" -input = "AB<=70--Sniper" -output = "(AB<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +input = "1AB100<=70--SNI" +output = "(1AB100<=70--SNI) > [50] > 1+0C-0E+1(SNI) > 成功数2" success = true rands = [ { sides = 100, value = 50 }, @@ -488,58 +488,69 @@ rands = [ [[ test ]] game_system = "ArknightsFan" -input = "1AB<=70--Sniper" -output = "(1AB<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +input = "3AB100<=70--Sni" +output = "(3AB100<=70--SNI) > [50,50,90] > 2+0C-0E+1(SNI) > 成功数3" success = true rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, { sides = 100, value = 50 }, ] [[ test ]] game_system = "ArknightsFan" -input = "AB100<=70--Sniper" -output = "(AB100<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" -success = true +input = "3AB100<=70--sni" +output = "(3AB100<=70--SNI) > [50,80,91] > 1+0C-1E+0(SNI) > 成功数0" +fumble = true +failure = true rands = [ + { sides = 100, value = 91 }, { sides = 100, value = 50 }, + { sides = 100, value = 80 }, ] [[ test ]] game_system = "ArknightsFan" -input = "1AB100<=70--Sniper" -output = "(1AB100<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +input = "3AB100<=70--Sni ほげ" +output = "(3AB100<=70--SNI) > [50,50,90] > 2+0C-0E+1(SNI) > 成功数3" success = true rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, { sides = 100, value = 50 }, ] [[ test ]] game_system = "ArknightsFan" -input = "3AB100<=70--Sniper" -output = "(3AB100<=70--SNIPER) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +input = "1AB100<=70--Sni0" +output = "(1AB100<=70--SNI0) > [50] > 1+0C-0E+1(SNI) > 成功数2" success = true rands = [ - { sides = 100, value = 90 }, { sides = 100, value = 50 }, +] + +[[ test ]] +game_system = "ArknightsFan" +input = "1AB100<=70--Sni1" +output = "(1AB100<=70--SNI1) > [50] > 1+0C-0E+0(SNI) > 成功数1" +success = true +rands = [ { sides = 100, value = 50 }, ] [[ test ]] game_system = "ArknightsFan" -input = "3AB100<=70--Sniper" -output = "(3AB100<=70--SNIPER) > [50,80,91] > 1+0C-1E+0(SNIPER) > 成功数0" -fumble = true -failure = true +input = "1AB100<=70--Sni2" +output = "(1AB100<=70--SNI2) > [50] > 1+0C-0E+0(SNI) > 成功数1" +success = true rands = [ - { sides = 100, value = 91 }, { sides = 100, value = 50 }, - { sides = 100, value = 80 }, ] [[ test ]] game_system = "ArknightsFan" -input = "3AB100<=70--Sniper あ" -output = "(3AB100<=70--SNIPER) > [50,50,90] > 2+0C-0E+1(SNIPER) > 成功数3" +input = "3AB100<=70--Sni0" +output = "(3AB100<=70--SNI0) > [50,50,90] > 2+0C-0E+1(SNI) > 成功数3" success = true rands = [ { sides = 100, value = 90 }, @@ -549,26 +560,30 @@ rands = [ [[ test ]] game_system = "ArknightsFan" -input = "AB<=70--Sniper0" -output = "(AB<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" +input = "3AB100<=70--Sni1" +output = "(3AB100<=70--SNI1) > [50,50,90] > 2+0C-0E+0(SNI) > 成功数2" success = true rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, { sides = 100, value = 50 }, ] [[ test ]] game_system = "ArknightsFan" -input = "1AB<=70--Sniper0" -output = "(1AB<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" +input = "3AB100<=70--Sni2" +output = "(3AB100<=70--SNI2) > [50,50,90] > 2+0C-0E+0(SNI) > 成功数2" success = true rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, { sides = 100, value = 50 }, ] [[ test ]] game_system = "ArknightsFan" -input = "AB100<=70--Sniper0" -output = "(AB100<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" +input = "1AB100<=70--Sniper0" +output = "(1AB100<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" success = true rands = [ { sides = 100, value = 50 }, @@ -576,8 +591,8 @@ rands = [ [[ test ]] game_system = "ArknightsFan" -input = "1AB100<=70--Sniper0" -output = "(1AB100<=70--SNIPER0) > [50] > 1+0C-0E+0(SNIPER) > 成功数1" +input = "1AB100<=70--Sniper1" +output = "(1AB100<=70--SNIPER1) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" success = true rands = [ { sides = 100, value = 50 }, From 11dfcb9837d648e1e174c73ab25ca748fb84c9bb Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sat, 28 Sep 2024 19:37:58 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E7=97=85=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E7=94=A8=E3=81=AE=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 50 ++++++++- test/data/ArknightsFan.toml | 141 +++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 2 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 07d791895..30b66d642 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -35,6 +35,10 @@ class ArknightsFan < Base 狙撃(SNI): 健康(h=0)かつ成功数1以上のとき、成功数+1。 健康状態hを省略した場合、健康(h=0)として扱われる。 + ■ 鉱石病判定 (ORP(p,q,n)+mD) + 生理的耐性pのOPが侵食度qに上昇した際の鉱石病判定、判定値補正n、ダイス数補正mで行う。 + 判定値補正とダイス数補正は省略可能。例えば、ORP(60,25)はORP(60,25,0)+0Dと同義。 + ■ 増悪判定(--WORSENING) 症状を「末梢神経障害」「内臓機能不全」「精神症状」からランダムに選択。 継続ラウンド数を1d6+1で判定。 @@ -49,10 +53,15 @@ class ArknightsFan < Base 例えば、AD<=90は1AD100<=90として解釈される。 TEXT - register_prefix('[-+*/\d]*AD\d*', '[-+*/\d]*AB\d*', '--ADDICTION', '--WORSENING') + register_prefix('[-+*/\d]*AD\d*', '[-+*/\d]*AB\d*', 'ORP', '--ADDICTION', '--WORSENING') + + def initialize(command) + super(command) + @sides_implicit_d = nil # 1D のようにダイスの面数が指定されていない場合にダイス表記に置換しない + end def eval_game_system_specific_command(command) - roll_ad(command) || roll_ab(command) || roll_addiction(command) || roll_worsening(command) + roll_ad(command) || roll_ab(command) || roll_orp(command) || roll_addiction(command) || roll_worsening(command) end private @@ -142,6 +151,18 @@ def roll_ab(command) end end + def roll_orp(command) + m = %r{^ORP\(([-+*/\d]+),([-+*/\d]+)(?:,([-+*/\d]+))?\)(?:\+([-+*/\d]+)D)?$}.match(command) + return nil unless m + + endurance = Arithmetic.eval(m[1], @round_type) + oripathy = Arithmetic.eval(m[2], @round_type) + target_mod = !m[3].nil? ? Arithmetic.eval(m[3], @round_type) : 0 + times_mod = !m[4].nil? ? Arithmetic.eval(m[4], @round_type) : 0 + + roll_oripathy(command, endurance, oripathy, target_mod, times_mod) + end + def roll_d(command, times, sides, target) dice_list = @randomizer.roll_barabara(times, sides).sort total = dice_list.sum @@ -211,6 +232,31 @@ def roll_b_withtype(command, times, sides, target, type, type_status) end end + ENDURANCE_LEVEL_TABLE = [20, 40, 70, 90, Float::INFINITY].freeze # 生理的耐性の実数値から能力評価への変換テーブル + ORP_TIMES_TABLE = [1, 2, 2, 3, 4].freeze # 生理的耐性の能力評価ごとのダイス数基本値 + def roll_oripathy(command, endurance, oripathy, target_mod, times_mod) + sides = 100 + + endurance_level = ENDURANCE_LEVEL_TABLE.find_index { |n| endurance <= n } + times = ORP_TIMES_TABLE[endurance_level] + times_mod + + oripathy_stage = (oripathy / 20).floor + target = (80 - oripathy_stage * 20) - (oripathy - oripathy_stage * 20) * 5 + target_mod + + if target <= 0 + return Result.failure("(#{command}) > ダイス数#{times}, 判定値#{target} > 自動失敗!") + end + + # 複数振ったダイスのうち1つでも判定値を下回れば成功なので、最も出目の小さいダイスのみを確認すればよい。 + # dice_listをソートした上で、dice_list[0]が最小の出目。 + dice_list = @randomizer.roll_barabara(times, sides).sort + if dice_list[0] <= target + Result.success("(#{command}) > ダイス数#{times}, 判定値#{target} > [#{dice_list.join(',')}] > 成功") + else + Result.failure("(#{command}) > ダイス数#{times}, 判定値#{target} > [#{dice_list.join(',')}] > 失敗") + end + end + def process_b(times, sides, target) dice_list = @randomizer.roll_barabara(times, sides).sort diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 589224410..d27f6cfac 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -1,3 +1,6 @@ +############## +### AD判定 ### +############## [[ test ]] game_system = "ArknightsFan" input = "AD<=70" @@ -117,6 +120,9 @@ rands = [ { sides = 100, value = 14 }, ] +############## +### AB判定 ### +############## [[ test ]] game_system = "ArknightsFan" input = "AB<=70" @@ -477,6 +483,9 @@ rands = [ { sides = 100, value = 14 }, ] +###################### +### 役職付きAB判定 ### +###################### [[ test ]] game_system = "ArknightsFan" input = "1AB100<=70--SNI" @@ -620,6 +629,137 @@ rands = [ { sides = 100, value = 50 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(60,25)" +output = "(ORP(60,25)) > ダイス数2, 判定値35 > [35,50] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +############### +### ORP判定 ### +############### +# ルルブp.32 例1, 成功例 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(70,25)" +output = "(ORP(70,25)) > ダイス数2, 判定値35 > [35,50] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# ルルブp. 32 例1, 失敗例 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(70,25)" +output = "(ORP(70,25)) > ダイス数2, 判定値35 > [36,50] > 失敗" +failure = true +rands = [ + { sides = 100, value = 36 }, + { sides = 100, value = 50 }, +] + +# ルルブp. 32 例1, 自動失敗例 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(90,68)" +output = "(ORP(90,68)) > ダイス数3, 判定値-20 > 自動失敗!" +failure = true +rands = [ +] + +# 判定値補正 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(70,25,10)" +output = "(ORP(70,25,10)) > ダイス数2, 判定値45 > [45,50] > 成功" +success = true +rands = [ + { sides = 100, value = 45 }, + { sides = 100, value = 50 }, +] + +# ダイス数補正 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(70,25)+2D" +output = "(ORP(70,25)+2D) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 生理的耐性: 欠落 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(20,25)" +output = "(ORP(20,25)) > ダイス数1, 判定値35 > [35] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, +] + +# 生理的耐性: 普通 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(40,25)" +output = "(ORP(40,25)) > ダイス数2, 判定値35 > [35,50] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# 生理的耐性: 優秀 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(90,25)" +output = "(ORP(90,25)) > ダイス数3, 判定値35 > [35,50,100] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, +] + +# 生理的耐性: 卓越 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(100,25)" +output = "(ORP(100,25)) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 数式表記 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP(30+40,35-10,5+5)++5-3D" +output = "(ORP(30+40,35-10,5+5)++5-3D) > ダイス数4, 判定値45 > [35,50,100,100] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + + +##################### +### 増悪/中毒判定 ### +##################### [[ test ]] game_system = "ArknightsFan" input = "--WORSENING" @@ -679,3 +819,4 @@ output = "--ADDICTION > 急性ストレス反応" rands = [ { sides = 3, value = 3 }, ] + From aa2ab9bea3aaf585a15e239c7136d4cbe5d1706c Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sat, 28 Sep 2024 19:38:43 +0800 Subject: [PATCH 12/20] =?UTF-8?q?=E9=80=9A=E5=B8=B8=E3=81=AE=E5=8A=A0?= =?UTF-8?q?=E7=AE=97=E3=83=80=E3=82=A4=E3=82=B9=E3=80=81=E3=83=90=E3=83=A9?= =?UTF-8?q?=E3=83=90=E3=83=A9=E3=83=80=E3=82=A4=E3=82=B9=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E6=9E=9C=E3=82=92=E3=82=BD=E3=83=BC=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 30b66d642..37ed65a99 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -57,6 +57,8 @@ class ArknightsFan < Base def initialize(command) super(command) + @sort_add_dice = true # 加算ダイスでダイス目をソートする + @sort_barabara_dice = true # バラバラダイスでダイス目をソートする @sides_implicit_d = nil # 1D のようにダイスの面数が指定されていない場合にダイス表記に置換しない end @@ -122,7 +124,8 @@ def roll_ad(command) target = Arithmetic.eval(m[3], @round_type) times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 - return roll_d(command, times, sides, target) + + roll_d(command, times, sides, target) end def roll_ab(command) From 7406fa476b1511f27d67389ab36639cb4c1bb72f Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 29 Sep 2024 14:07:21 +0900 Subject: [PATCH 13/20] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E7=97=85=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=AE=E6=9B=B8?= =?UTF-8?q?=E5=BC=8F=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ORP(x,y,t)+dD→ORPx@y+Dd+Tdに変更 ・dD表記はダイスボットの仕様で不可(前処理でdD100にされる) ・ダイス補正・判定値補正をどちらがどちらか分かりやすいように ・ダイス補正・判定値補正を逆順でも動作可能にした --- lib/bcdice/game_system/ArknightsFan.rb | 28 +++++---- test/data/ArknightsFan.toml | 80 +++++++++++++++----------- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 37ed65a99..dc43387eb 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -35,9 +35,11 @@ class ArknightsFan < Base 狙撃(SNI): 健康(h=0)かつ成功数1以上のとき、成功数+1。 健康状態hを省略した場合、健康(h=0)として扱われる。 - ■ 鉱石病判定 (ORP(p,q,n)+mD) - 生理的耐性pのOPが侵食度qに上昇した際の鉱石病判定、判定値補正n、ダイス数補正mで行う。 - 判定値補正とダイス数補正は省略可能。例えば、ORP(60,25)はORP(60,25,0)+0Dと同義。 + ■ 鉱石病判定 (ORPx@y+Dd+Tt) + x: 生理的耐性、y: 上昇後侵食度、d: ダイス補正、t: 判定値補正 + 生理的耐性xのOPが侵食度yに上昇した際の鉱石病判定を、ダイス数補正d、判定値補正tで行う。 + ダイス数補正と判定値補正は省略可能。例えば ORP60@25 は ORP60@25+D0+T0 と同義。 + また、ダイス数補正と判定値補正は逆順でも可。例えば ORP60@25+T10+D2 も可。 ■ 増悪判定(--WORSENING) 症状を「末梢神経障害」「内臓機能不全」「精神症状」からランダムに選択。 @@ -57,9 +59,9 @@ class ArknightsFan < Base def initialize(command) super(command) - @sort_add_dice = true # 加算ダイスでダイス目をソートする + @sort_add_dice = true # 加算ダイスでダイス目をソートする @sort_barabara_dice = true # バラバラダイスでダイス目をソートする - @sides_implicit_d = nil # 1D のようにダイスの面数が指定されていない場合にダイス表記に置換しない + @sides_implicit_d = 100 # 1D のようにダイスの面数が指定されていない場合に100面ダイスにする end def eval_game_system_specific_command(command) @@ -155,15 +157,17 @@ def roll_ab(command) end def roll_orp(command) - m = %r{^ORP\(([-+*/\d]+),([-+*/\d]+)(?:,([-+*/\d]+))?\)(?:\+([-+*/\d]+)D)?$}.match(command) + m = %r{^ORP(?'END'[-+*/\d]+)@(?'ORP'[-+*/\d]+)(?:\+D(?'DICE'[-+*/\d]+))?(?:\+T(?'TGT'[-+*/\d]+))?$}.match(command) + # D補正とT補正が逆順でも対応する + m ||= %r{^ORP(?'END'[-+*/\d]+)@(?'ORP'[-+*/\d]+)(?:\+T(?'TGT'[-+*/\d]+))?(?:\+D(?'DICE'[-+*/\d]+))?$}.match(command) return nil unless m - endurance = Arithmetic.eval(m[1], @round_type) - oripathy = Arithmetic.eval(m[2], @round_type) - target_mod = !m[3].nil? ? Arithmetic.eval(m[3], @round_type) : 0 - times_mod = !m[4].nil? ? Arithmetic.eval(m[4], @round_type) : 0 + endurance = Arithmetic.eval(m[:END], @round_type) + oripathy = Arithmetic.eval(m[:ORP], @round_type) + times_mod = !m[3].nil? ? Arithmetic.eval(m[:DICE], @round_type) : 0 + target_mod = !m[4].nil? ? Arithmetic.eval(m[:TGT], @round_type) : 0 - roll_oripathy(command, endurance, oripathy, target_mod, times_mod) + roll_oripathy(command, endurance, oripathy, times_mod, target_mod) end def roll_d(command, times, sides, target) @@ -237,7 +241,7 @@ def roll_b_withtype(command, times, sides, target, type, type_status) ENDURANCE_LEVEL_TABLE = [20, 40, 70, 90, Float::INFINITY].freeze # 生理的耐性の実数値から能力評価への変換テーブル ORP_TIMES_TABLE = [1, 2, 2, 3, 4].freeze # 生理的耐性の能力評価ごとのダイス数基本値 - def roll_oripathy(command, endurance, oripathy, target_mod, times_mod) + def roll_oripathy(command, endurance, oripathy, times_mod, target_mod) sides = 100 endurance_level = ENDURANCE_LEVEL_TABLE.find_index { |n| endurance <= n } diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index d27f6cfac..5e774f55a 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -629,24 +629,14 @@ rands = [ { sides = 100, value = 50 }, ] -[[ test ]] -game_system = "ArknightsFan" -input = "ORP(60,25)" -output = "(ORP(60,25)) > ダイス数2, 判定値35 > [35,50] > 成功" -success = true -rands = [ - { sides = 100, value = 35 }, - { sides = 100, value = 50 }, -] - ############### ### ORP判定 ### ############### # ルルブp.32 例1, 成功例 [[ test ]] game_system = "ArknightsFan" -input = "ORP(70,25)" -output = "(ORP(70,25)) > ダイス数2, 判定値35 > [35,50] > 成功" +input = "ORP70@25" +output = "(ORP70@25) > ダイス数2, 判定値35 > [35,50] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -656,8 +646,8 @@ rands = [ # ルルブp. 32 例1, 失敗例 [[ test ]] game_system = "ArknightsFan" -input = "ORP(70,25)" -output = "(ORP(70,25)) > ダイス数2, 判定値35 > [36,50] > 失敗" +input = "ORP70@25" +output = "(ORP70@25) > ダイス数2, 判定値35 > [36,50] > 失敗" failure = true rands = [ { sides = 100, value = 36 }, @@ -667,31 +657,57 @@ rands = [ # ルルブp. 32 例1, 自動失敗例 [[ test ]] game_system = "ArknightsFan" -input = "ORP(90,68)" -output = "(ORP(90,68)) > ダイス数3, 判定値-20 > 自動失敗!" +input = "ORP90@68" +output = "(ORP90@68) > ダイス数3, 判定値-20 > 自動失敗!" failure = true rands = [ ] +# ダイス数補正 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + # 判定値補正 [[ test ]] game_system = "ArknightsFan" -input = "ORP(70,25,10)" -output = "(ORP(70,25,10)) > ダイス数2, 判定値45 > [45,50] > 成功" +input = "ORP70@25+T10" +output = "(ORP70@25+T10) > ダイス数2, 判定値45 > [45,50] > 成功" success = true rands = [ { sides = 100, value = 45 }, { sides = 100, value = 50 }, ] -# ダイス数補正 +# ダイス数補正+判定値補正 [[ test ]] game_system = "ArknightsFan" -input = "ORP(70,25)+2D" -output = "(ORP(70,25)+2D) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +input = "ORP70@25+D2+T10" +output = "(ORP70@25+D2+T10) > ダイス数4, 判定値45 > [45,50,100,100] > 成功" success = true rands = [ - { sides = 100, value = 35 }, + { sides = 100, value = 45 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 判定値補正+ダイス数補正(逆順) +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+T10+D2" +output = "(ORP70@25+T10+D2) > ダイス数4, 判定値45 > [45,50,100,100] > 成功" +success = true +rands = [ + { sides = 100, value = 45 }, { sides = 100, value = 50 }, { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -700,8 +716,8 @@ rands = [ # 生理的耐性: 欠落 [[ test ]] game_system = "ArknightsFan" -input = "ORP(20,25)" -output = "(ORP(20,25)) > ダイス数1, 判定値35 > [35] > 成功" +input = "ORP20@25" +output = "(ORP20@25) > ダイス数1, 判定値35 > [35] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -710,8 +726,8 @@ rands = [ # 生理的耐性: 普通 [[ test ]] game_system = "ArknightsFan" -input = "ORP(40,25)" -output = "(ORP(40,25)) > ダイス数2, 判定値35 > [35,50] > 成功" +input = "ORP40@25" +output = "(ORP40@25) > ダイス数2, 判定値35 > [35,50] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -721,8 +737,8 @@ rands = [ # 生理的耐性: 優秀 [[ test ]] game_system = "ArknightsFan" -input = "ORP(90,25)" -output = "(ORP(90,25)) > ダイス数3, 判定値35 > [35,50,100] > 成功" +input = "ORP90@25" +output = "(ORP90@25) > ダイス数3, 判定値35 > [35,50,100] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -733,8 +749,8 @@ rands = [ # 生理的耐性: 卓越 [[ test ]] game_system = "ArknightsFan" -input = "ORP(100,25)" -output = "(ORP(100,25)) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +input = "ORP100@25" +output = "(ORP100@25) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -746,8 +762,8 @@ rands = [ # 数式表記 [[ test ]] game_system = "ArknightsFan" -input = "ORP(30+40,35-10,5+5)++5-3D" -output = "(ORP(30+40,35-10,5+5)++5-3D) > ダイス数4, 判定値45 > [35,50,100,100] > 成功" +input = "ORP30+40@35-10+D5-3+T5+5" +output = "(ORP30+40@35-10+D5-3+T5+5) > ダイス数4, 判定値45 > [35,50,100,100] > 成功" success = true rands = [ { sides = 100, value = 35 }, From 708cad0a357b398a779a53551d41ae2a2fe85ac8 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 29 Sep 2024 19:00:02 +0900 Subject: [PATCH 14/20] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E7=97=85=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E6=9E=9C=E8=A1=A8=E7=A4=BA=E3=82=92=E3=82=88=E3=82=8A=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 21 +++++++++++++----- test/data/ArknightsFan.toml | 30 +++++++++++++------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index dc43387eb..184f79a68 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -245,22 +245,33 @@ def roll_oripathy(command, endurance, oripathy, times_mod, target_mod) sides = 100 endurance_level = ENDURANCE_LEVEL_TABLE.find_index { |n| endurance <= n } - times = ORP_TIMES_TABLE[endurance_level] + times_mod + original_times = ORP_TIMES_TABLE[endurance_level] + times = original_times + times_mod oripathy_stage = (oripathy / 20).floor - target = (80 - oripathy_stage * 20) - (oripathy - oripathy_stage * 20) * 5 + target_mod + original_target = (80 - oripathy_stage * 20) - (oripathy - oripathy_stage * 20) * 5 + target = original_target + target_mod + dice_and_target_text = "ダイス数#{original_times}" + + (times_mod > 0 ? "+#{times_mod}" : "") + + "、判定値#{original_target}" + + (target_mod > 0 ? "+#{target_mod}" : "") + result_texts = ["(#{command})", dice_and_target_text, "#{times}B100<=#{target}"] if target <= 0 - return Result.failure("(#{command}) > ダイス数#{times}, 判定値#{target} > 自動失敗!") + result_texts += ["自動失敗!"] + return Result.failure(result_texts.join(" > ")) end # 複数振ったダイスのうち1つでも判定値を下回れば成功なので、最も出目の小さいダイスのみを確認すればよい。 # dice_listをソートした上で、dice_list[0]が最小の出目。 dice_list = @randomizer.roll_barabara(times, sides).sort + success_failure_list = dice_list.map { |n| n <= target ? "成功" : "失敗" } if dice_list[0] <= target - Result.success("(#{command}) > ダイス数#{times}, 判定値#{target} > [#{dice_list.join(',')}] > 成功") + result_texts += ["[#{dice_list.join(',')}]", "[#{success_failure_list.join('、')}]", "成功"] + Result.success(result_texts.join(" > ")) else - Result.failure("(#{command}) > ダイス数#{times}, 判定値#{target} > [#{dice_list.join(',')}] > 失敗") + result_texts += ["[#{dice_list.join(',')}]", "[#{success_failure_list.join('、')}]", "失敗"] + Result.failure(result_texts.join(" > ")) end end diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 5e774f55a..9671c0b74 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -636,7 +636,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25" -output = "(ORP70@25) > ダイス数2, 判定値35 > [35,50] > 成功" +output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > [成功、失敗] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -647,7 +647,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25" -output = "(ORP70@25) > ダイス数2, 判定値35 > [36,50] > 失敗" +output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [36,50] > [失敗、失敗] > 失敗" failure = true rands = [ { sides = 100, value = 36 }, @@ -658,7 +658,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP90@68" -output = "(ORP90@68) > ダイス数3, 判定値-20 > 自動失敗!" +output = "(ORP90@68) > ダイス数3、判定値-20 > 3B100<=-20 > 自動失敗!" failure = true rands = [ ] @@ -667,7 +667,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+D2" -output = "(ORP70@25+D2) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [35,50,100,100] > [成功、失敗、失敗、失敗] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -680,7 +680,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+T10" -output = "(ORP70@25+T10) > ダイス数2, 判定値45 > [45,50] > 成功" +output = "(ORP70@25+T10) > ダイス数2、判定値35+10 > 2B100<=45 > [45,50] > [成功、失敗] > 成功" success = true rands = [ { sides = 100, value = 45 }, @@ -691,12 +691,12 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+D2+T10" -output = "(ORP70@25+D2+T10) > ダイス数4, 判定値45 > [45,50,100,100] > 成功" +output = "(ORP70@25+D2+T10) > ダイス数2+2、判定値35+10 > 4B100<=45 > [35,45,46,100] > [成功、成功、失敗、失敗] > 成功" success = true rands = [ + { sides = 100, value = 35 }, { sides = 100, value = 45 }, - { sides = 100, value = 50 }, - { sides = 100, value = 100 }, + { sides = 100, value = 46 }, { sides = 100, value = 100 }, ] @@ -704,7 +704,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+T10+D2" -output = "(ORP70@25+T10+D2) > ダイス数4, 判定値45 > [45,50,100,100] > 成功" +output = "(ORP70@25+T10+D2) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > [成功、失敗、失敗、失敗] > 成功" success = true rands = [ { sides = 100, value = 45 }, @@ -717,7 +717,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP20@25" -output = "(ORP20@25) > ダイス数1, 判定値35 > [35] > 成功" +output = "(ORP20@25) > ダイス数1、判定値35 > 1B100<=35 > [35] > [成功] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -727,7 +727,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP40@25" -output = "(ORP40@25) > ダイス数2, 判定値35 > [35,50] > 成功" +output = "(ORP40@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > [成功、失敗] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -738,7 +738,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP90@25" -output = "(ORP90@25) > ダイス数3, 判定値35 > [35,50,100] > 成功" +output = "(ORP90@25) > ダイス数3、判定値35 > 3B100<=35 > [35,50,100] > [成功、失敗、失敗] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -750,7 +750,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP100@25" -output = "(ORP100@25) > ダイス数4, 判定値35 > [35,50,100,100] > 成功" +output = "(ORP100@25) > ダイス数4、判定値35 > 4B100<=35 > [35,50,100,100] > [成功、失敗、失敗、失敗] > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -763,10 +763,10 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP30+40@35-10+D5-3+T5+5" -output = "(ORP30+40@35-10+D5-3+T5+5) > ダイス数4, 判定値45 > [35,50,100,100] > 成功" +output = "(ORP30+40@35-10+D5-3+T5+5) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > [成功、失敗、失敗、失敗] > 成功" success = true rands = [ - { sides = 100, value = 35 }, + { sides = 100, value = 45 }, { sides = 100, value = 50 }, { sides = 100, value = 100 }, { sides = 100, value = 100 }, From a4221774e33046e22cdb47b7543c733700872c96 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 6 Oct 2024 20:58:53 +0900 Subject: [PATCH 15/20] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E7=97=85=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E6=9E=9C=E8=A1=A8=E7=A4=BA=E3=82=92=E5=BE=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [成功、失敗]表示は分かりにくいという意見をいただいたので 成功数表示に変更 --- lib/bcdice/game_system/ArknightsFan.rb | 8 +-- test/data/ArknightsFan.toml | 91 ++++++++++++++++++++++---- 2 files changed, 82 insertions(+), 17 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 184f79a68..695ef36fd 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -265,12 +265,12 @@ def roll_oripathy(command, endurance, oripathy, times_mod, target_mod) # 複数振ったダイスのうち1つでも判定値を下回れば成功なので、最も出目の小さいダイスのみを確認すればよい。 # dice_listをソートした上で、dice_list[0]が最小の出目。 dice_list = @randomizer.roll_barabara(times, sides).sort - success_failure_list = dice_list.map { |n| n <= target ? "成功" : "失敗" } - if dice_list[0] <= target - result_texts += ["[#{dice_list.join(',')}]", "[#{success_failure_list.join('、')}]", "成功"] + success_count = dice_list.count { |n| n <= target } + if success_count > 0 + result_texts += ["[#{dice_list.join(',')}]", "成功数#{success_count}", "成功"] Result.success(result_texts.join(" > ")) else - result_texts += ["[#{dice_list.join(',')}]", "[#{success_failure_list.join('、')}]", "失敗"] + result_texts += ["[#{dice_list.join(',')}]", "成功数#{success_count}", "失敗"] Result.failure(result_texts.join(" > ")) end end diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 9671c0b74..f9ff75307 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -483,9 +483,9 @@ rands = [ { sides = 100, value = 14 }, ] -###################### +####################### ### 役職付きAB判定 ### -###################### +####################### [[ test ]] game_system = "ArknightsFan" input = "1AB100<=70--SNI" @@ -636,7 +636,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25" -output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > [成功、失敗] > 成功" +output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -647,7 +647,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25" -output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [36,50] > [失敗、失敗] > 失敗" +output = "(ORP70@25) > ダイス数2、判定値35 > 2B100<=35 > [36,50] > 成功数0 > 失敗" failure = true rands = [ { sides = 100, value = 36 }, @@ -667,7 +667,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+D2" -output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [35,50,100,100] > [成功、失敗、失敗、失敗] > 成功" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [35,50,100,100] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -680,7 +680,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+T10" -output = "(ORP70@25+T10) > ダイス数2、判定値35+10 > 2B100<=45 > [45,50] > [成功、失敗] > 成功" +output = "(ORP70@25+T10) > ダイス数2、判定値35+10 > 2B100<=45 > [45,50] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 45 }, @@ -691,7 +691,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+D2+T10" -output = "(ORP70@25+D2+T10) > ダイス数2+2、判定値35+10 > 4B100<=45 > [35,45,46,100] > [成功、成功、失敗、失敗] > 成功" +output = "(ORP70@25+D2+T10) > ダイス数2+2、判定値35+10 > 4B100<=45 > [35,45,46,100] > 成功数2 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -704,7 +704,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP70@25+T10+D2" -output = "(ORP70@25+T10+D2) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > [成功、失敗、失敗、失敗] > 成功" +output = "(ORP70@25+T10+D2) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 45 }, @@ -713,11 +713,76 @@ rands = [ { sides = 100, value = 100 }, ] +# 成功数0 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [50,50,100,100] > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 成功数1 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [35,50,100,100] > 成功数1 > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 成功数2 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [25,35,100,100] > 成功数2 > 成功" +success = true +rands = [ + { sides = 100, value = 25 }, + { sides = 100, value = 35 }, + { sides = 100, value = 100 }, + { sides = 100, value = 100 }, +] + +# 成功数3 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [10,25,35,100] > 成功数3 > 成功" +success = true +rands = [ + { sides = 100, value = 10 }, + { sides = 100, value = 25 }, + { sides = 100, value = 35 }, + { sides = 100, value = 100 }, +] + +# 成功数4 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP70@25+D2" +output = "(ORP70@25+D2) > ダイス数2+2、判定値35 > 4B100<=35 > [1,10,25,35] > 成功数4 > 成功" +success = true +rands = [ + { sides = 100, value = 1 }, + { sides = 100, value = 10 }, + { sides = 100, value = 25 }, + { sides = 100, value = 35 }, +] + # 生理的耐性: 欠落 [[ test ]] game_system = "ArknightsFan" input = "ORP20@25" -output = "(ORP20@25) > ダイス数1、判定値35 > 1B100<=35 > [35] > [成功] > 成功" +output = "(ORP20@25) > ダイス数1、判定値35 > 1B100<=35 > [35] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -727,7 +792,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP40@25" -output = "(ORP40@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > [成功、失敗] > 成功" +output = "(ORP40@25) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -738,7 +803,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP90@25" -output = "(ORP90@25) > ダイス数3、判定値35 > 3B100<=35 > [35,50,100] > [成功、失敗、失敗] > 成功" +output = "(ORP90@25) > ダイス数3、判定値35 > 3B100<=35 > [35,50,100] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -750,7 +815,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP100@25" -output = "(ORP100@25) > ダイス数4、判定値35 > 4B100<=35 > [35,50,100,100] > [成功、失敗、失敗、失敗] > 成功" +output = "(ORP100@25) > ダイス数4、判定値35 > 4B100<=35 > [35,50,100,100] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 35 }, @@ -763,7 +828,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "ORP30+40@35-10+D5-3+T5+5" -output = "(ORP30+40@35-10+D5-3+T5+5) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > [成功、失敗、失敗、失敗] > 成功" +output = "(ORP30+40@35-10+D5-3+T5+5) > ダイス数2+2、判定値35+10 > 4B100<=45 > [45,50,100,100] > 成功数1 > 成功" success = true rands = [ { sides = 100, value = 45 }, From a6078861c63bd665ba50fdc7cd7a94c1e00b964d Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 6 Oct 2024 21:45:13 +0900 Subject: [PATCH 16/20] =?UTF-8?q?=E9=96=A2=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - コマンド解釈する関数: eval_{コマンド名} - ダイスロールを行う関数: roll_{コマンド名} - ダイスロール結果を処理する関数: process_{コマンド名} --- lib/bcdice/game_system/ArknightsFan.rb | 72 +++++++++++++------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 695ef36fd..6ac562eb7 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -55,7 +55,7 @@ class ArknightsFan < Base 例えば、AD<=90は1AD100<=90として解釈される。 TEXT - register_prefix('[-+*/\d]*AD\d*', '[-+*/\d]*AB\d*', 'ORP', '--ADDICTION', '--WORSENING') + register_prefix('[-+*/\d]*AD\d*', '[-+*/\d]*AB\d*', 'ORP', '--WORSENING', '--ADDICTION') def initialize(command) super(command) @@ -65,7 +65,7 @@ def initialize(command) end def eval_game_system_specific_command(command) - roll_ad(command) || roll_ab(command) || roll_orp(command) || roll_addiction(command) || roll_worsening(command) + eval_ad(command) || eval_ab(command) || eval_orp(command) || eval_worsening(command) || eval_addiction(command) end private @@ -115,7 +115,7 @@ def check_roll(roll_result, target) return result end - def roll_ad(command) + def eval_ad(command) # -は文字クラスの先頭または最後に置く。 # そうしないと範囲指定子として解釈される。 m = %r{^([-+*/\d]*)AD(\d*)<=([-+*/\d]+)$}.match(command) @@ -127,10 +127,10 @@ def roll_ad(command) times = !times.empty? ? Arithmetic.eval(m[1], @round_type) : 1 sides = !sides.empty? ? sides.to_i : 100 - roll_d(command, times, sides, target) + roll_ad(command, times, sides, target) end - def roll_ab(command) + def eval_ab(command) m = %r{^([-+*/\d]*)AB(\d*)<=([-+*/\d]+)(?:--([^\d\s]+)([0-2])?)?$}.match(command) return nil unless m @@ -150,13 +150,13 @@ def roll_ab(command) end if type.nil? - roll_b(command, times, sides, target) + roll_ab(command, times, sides, target) else - roll_b_withtype(command, times, sides, target, type, type_status) + roll_ab_withtype(command, times, sides, target, type, type_status) end end - def roll_orp(command) + def eval_orp(command) m = %r{^ORP(?'END'[-+*/\d]+)@(?'ORP'[-+*/\d]+)(?:\+D(?'DICE'[-+*/\d]+))?(?:\+T(?'TGT'[-+*/\d]+))?$}.match(command) # D補正とT補正が逆順でも対応する m ||= %r{^ORP(?'END'[-+*/\d]+)@(?'ORP'[-+*/\d]+)(?:\+T(?'TGT'[-+*/\d]+))?(?:\+D(?'DICE'[-+*/\d]+))?$}.match(command) @@ -167,10 +167,10 @@ def roll_orp(command) times_mod = !m[3].nil? ? Arithmetic.eval(m[:DICE], @round_type) : 0 target_mod = !m[4].nil? ? Arithmetic.eval(m[:TGT], @round_type) : 0 - roll_oripathy(command, endurance, oripathy, times_mod, target_mod) + roll_orp(command, endurance, oripathy, times_mod, target_mod) end - def roll_d(command, times, sides, target) + def roll_ad(command, times, sides, target) dice_list = @randomizer.roll_barabara(times, sides).sort total = dice_list.sum @@ -193,8 +193,10 @@ def roll_d(command, times, sides, target) end end - def roll_b(command, times, sides, target) - dice_list, success_count, critical_count, error_count = process_b(times, sides, target) + def roll_ab(command, times, sides, target) + dice_list = @randomizer.roll_barabara(times, sides).sort + + success_count, critical_count, error_count = process_ab(dice_list, target) result_count = success_count + critical_count - error_count result_text = "(#{command}) > [#{dice_list.join(',')}] > #{success_count}+#{critical_count}C-#{error_count}E > 成功数#{result_count}" @@ -206,8 +208,10 @@ def roll_b(command, times, sides, target) end end - def roll_b_withtype(command, times, sides, target, type, type_status) - dice_list, success_count, critical_count, error_count = process_b(times, sides, target) + def roll_ab_withtype(command, times, sides, target, type, type_status) + dice_list = @randomizer.roll_barabara(times, sides).sort + + success_count, critical_count, error_count = process_ab(dice_list, target) result_count = success_count + critical_count - error_count case type @@ -241,7 +245,7 @@ def roll_b_withtype(command, times, sides, target, type, type_status) ENDURANCE_LEVEL_TABLE = [20, 40, 70, 90, Float::INFINITY].freeze # 生理的耐性の実数値から能力評価への変換テーブル ORP_TIMES_TABLE = [1, 2, 2, 3, 4].freeze # 生理的耐性の能力評価ごとのダイス数基本値 - def roll_oripathy(command, endurance, oripathy, times_mod, target_mod) + def roll_orp(command, endurance, oripathy, times_mod, target_mod) sides = 100 endurance_level = ENDURANCE_LEVEL_TABLE.find_index { |n| endurance <= n } @@ -275,9 +279,7 @@ def roll_oripathy(command, endurance, oripathy, times_mod, target_mod) end end - def process_b(times, sides, target) - dice_list = @randomizer.roll_barabara(times, sides).sort - + def process_ab(dice_list, target) success_count = 0 critical_count = 0 error_count = 0 @@ -296,22 +298,7 @@ def process_b(times, sides, target) end end - return [dice_list, success_count, critical_count, error_count] - end - - ADDICTION_TABLE = [ - "中枢神経障害", - "多臓器不全", - "急性ストレス反応", - ].freeze - - def roll_addiction(command) - return nil if command != "--ADDICTION" - - value = @randomizer.roll_once(3) - chosen = ADDICTION_TABLE[value - 1] - - return "--ADDICTION > #{chosen}" + return [success_count, critical_count, error_count] end WORSENING_TABLE = [ @@ -320,7 +307,7 @@ def roll_addiction(command) "精神症状", ].freeze - def roll_worsening(command) + def eval_worsening(command) return nil if command != "--WORSENING" value = @randomizer.roll_once(3) @@ -329,6 +316,21 @@ def roll_worsening(command) return "--WORSENING > #{chosen}: #{elapse} rounds" end + + ADDICTION_TABLE = [ + "中枢神経障害", + "多臓器不全", + "急性ストレス反応", + ].freeze + + def eval_addiction(command) + return nil if command != "--ADDICTION" + + value = @randomizer.roll_once(3) + chosen = ADDICTION_TABLE[value - 1] + + return "--ADDICTION > #{chosen}" + end end end end From 6ddf50c2ce2f6e9a4882229a30792067c06b44b7 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sun, 6 Oct 2024 21:51:40 +0900 Subject: [PATCH 17/20] =?UTF-8?q?=E4=B8=AD=E6=AF=92=E7=97=87=E7=8A=B6?= =?UTF-8?q?=E3=81=AE=E5=90=8D=E7=A7=B0=E3=82=92=E3=83=AB=E3=83=AB=E3=83=96?= =?UTF-8?q?Ver2=E6=BA=96=E6=8B=A0=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/ArknightsFan.rb | 6 +++--- test/data/ArknightsFan.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 6ac562eb7..b1bfd55de 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -46,7 +46,7 @@ class ArknightsFan < Base 継続ラウンド数を1d6+1で判定。 ■ 中毒判定(--ADDICTION) - 症状を「中枢神経障害」「多臓器不全」「急性ストレス反応」からランダムに選択。 + 症状を「脳神経障害」「多臓器不全」「急性精神反応」からランダムに選択。 ■ 判定の省略表記 nADm、nABm、nABmにおいて、 @@ -318,9 +318,9 @@ def eval_worsening(command) end ADDICTION_TABLE = [ - "中枢神経障害", + "脳神経障害", "多臓器不全", - "急性ストレス反応", + "急性精神症状", ].freeze def eval_addiction(command) diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index f9ff75307..9a6f2e350 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -880,7 +880,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "--ADDICTION" -output = "--ADDICTION > 中枢神経障害" +output = "--ADDICTION > 脳神経障害" rands = [ { sides = 3, value = 1 }, ] @@ -896,7 +896,7 @@ rands = [ [[ test ]] game_system = "ArknightsFan" input = "--ADDICTION" -output = "--ADDICTION > 急性ストレス反応" +output = "--ADDICTION > 急性精神症状" rands = [ { sides = 3, value = 3 }, ] From 2e94599c349b9769f90c6485373ff5cfa2d3aac6 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Mon, 7 Oct 2024 07:19:34 +0900 Subject: [PATCH 18/20] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=81=A1=E3=82=87=E3=81=A3=E3=81=A8=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit カバレッジ確認したら足りてないのがいくつかあったので。 --- lib/bcdice/game_system/ArknightsFan.rb | 4 ++-- test/data/ArknightsFan.toml | 31 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index b1bfd55de..151aeb707 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -143,7 +143,7 @@ def eval_ab(command) sides = !sides.empty? ? sides.to_i : 100 if !type_status.nil? type_status = type_status.to_i - elsif type == "SNIPER" # スプレッドシート版キャラシの後方互換性のために必要 + elsif type == "SNIPER" # スプレッドシート版キャラシの後方互換性のために必要 type_status = 1 else type_status = 0 @@ -221,7 +221,7 @@ def roll_ab_withtype(command, times, sides, target, type, type_status) else result_mod = 0 end - when "SNIPER" # スプレッドシート版キャラシの後方互換性のため残している + when "SNIPER" # スプレッドシート版キャラシの後方互換性のため残している if (type_status != 0) && (result_count > 0) result_mod = 1 else diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 9a6f2e350..4b9a7ee72 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -120,6 +120,16 @@ rands = [ { sides = 100, value = 14 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "2AD<=120" +output = "(2AD<=120) > 110[50,60] > 成功" +success = true +rands = [ + { sides = 100, value = 60 }, + { sides = 100, value = 50 }, +] + ############## ### AB判定 ### ############## @@ -607,6 +617,15 @@ rands = [ { sides = 100, value = 50 }, ] +[[ test ]] +game_system = "ArknightsFan" +input = "1AB100<=70--Sniper" +output = "(1AB100<=70--SNIPER) > [50] > 1+0C-0E+1(SNIPER) > 成功数2" +success = true +rands = [ + { sides = 100, value = 50 }, +] + [[ test ]] game_system = "ArknightsFan" input = "3AB100<=70--Sniper0" @@ -629,6 +648,18 @@ rands = [ { sides = 100, value = 50 }, ] +# 未実装。実装方法検討中。 +[[ test ]] +game_system = "ArknightsFan" +input = "3AB100<=70--GUR" +output = "(3AB100<=70--GUR) > [50,50,90] > 2+0C-0E > 成功数2" +success = true +rands = [ + { sides = 100, value = 90 }, + { sides = 100, value = 50 }, + { sides = 100, value = 50 }, +] + ############### ### ORP判定 ### ############### From 3da19fc553e8c6fa22fd0caffa2a89d0dde0ccf1 Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sat, 2 Nov 2024 23:19:40 +0900 Subject: [PATCH 19/20] =?UTF-8?q?=E9=89=B1=E7=9F=B3=E7=97=85=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=81=AE=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3=E3=81=A8?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1=E3=83=BC=E3=82=B9=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 侵食度20, 40, 60, 80のときの病期の計算が 正しい病期より一つ上の段階として算出していた。 --- lib/bcdice/game_system/ArknightsFan.rb | 6 +- test/data/ArknightsFan.toml | 124 ++++++++++++++++++++++--- 2 files changed, 117 insertions(+), 13 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 151aeb707..0b469e98f 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -252,7 +252,11 @@ def roll_orp(command, endurance, oripathy, times_mod, target_mod) original_times = ORP_TIMES_TABLE[endurance_level] times = original_times + times_mod - oripathy_stage = (oripathy / 20).floor + if oripathy <= 20 + return Result.new("(#{command}) > 鉱石病判定が発生しない侵食度です。侵食度は21以上を指定してください。") + end + + oripathy_stage = (oripathy / 20.0).ceil - 1 original_target = (80 - oripathy_stage * 20) - (oripathy - oripathy_stage * 20) * 5 target = original_target + target_mod dice_and_target_text = "ダイス数#{original_times}" + diff --git a/test/data/ArknightsFan.toml b/test/data/ArknightsFan.toml index 4b9a7ee72..1e413ec85 100644 --- a/test/data/ArknightsFan.toml +++ b/test/data/ArknightsFan.toml @@ -648,18 +648,6 @@ rands = [ { sides = 100, value = 50 }, ] -# 未実装。実装方法検討中。 -[[ test ]] -game_system = "ArknightsFan" -input = "3AB100<=70--GUR" -output = "(3AB100<=70--GUR) > [50,50,90] > 2+0C-0E > 成功数2" -success = true -rands = [ - { sides = 100, value = 90 }, - { sides = 100, value = 50 }, - { sides = 100, value = 50 }, -] - ############### ### ORP判定 ### ############### @@ -868,6 +856,118 @@ rands = [ { sides = 100, value = 100 }, ] +# 侵食度が21未満のときのエラーメッセージ +[[ test ]] +game_system = "ArknightsFan" +input = "ORP30@20" +output = "(ORP30@20) > 鉱石病判定が発生しない侵食度です。侵食度は21以上を指定してください。" +success = false +failure = false +critical = false +fumble = false +rands = [ +] + +## エッジケース群 +# 侵食度21 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@21" +output = "(ORP40@21) > ダイス数2、判定値55 > 2B100<=55 > [35,50] > 成功数2 > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# 侵食度40 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@40" +output = "(ORP40@40) > ダイス数2、判定値-40 > 2B100<=-40 > 自動失敗!" +failure = true +rands = [ +] + +# 侵食度41 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@41" +output = "(ORP40@41) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > 成功数1 > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# 侵食度60 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@60" +output = "(ORP40@60) > ダイス数2、判定値-60 > 2B100<=-60 > 自動失敗!" +failure = true +rands = [ +] + +# 侵食度61 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@41" +output = "(ORP40@41) > ダイス数2、判定値35 > 2B100<=35 > [35,50] > 成功数1 > 成功" +success = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# 侵食度80 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@60" +output = "(ORP40@60) > ダイス数2、判定値-60 > 2B100<=-60 > 自動失敗!" +failure = true +rands = [ +] + +# 侵食度61 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@61" +output = "(ORP40@61) > ダイス数2、判定値15 > 2B100<=15 > [35,50] > 成功数0 > 失敗" +failure = true +rands = [ + { sides = 100, value = 35 }, + { sides = 100, value = 50 }, +] + +# 侵食度80 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@80" +output = "(ORP40@80) > ダイス数2、判定値-80 > 2B100<=-80 > 自動失敗!" +failure = true +rands = [ +] + +# 侵食度81 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@81+T10" +output = "(ORP40@81+T10) > ダイス数2、判定値-5+10 > 2B100<=5 > [5,50] > 成功数1 > 成功" +success = true +rands = [ + { sides = 100, value = 5 }, + { sides = 100, value = 50 }, +] + +# 侵食度99 +[[ test ]] +game_system = "ArknightsFan" +input = "ORP40@99+T10" +output = "(ORP40@99+T10) > ダイス数2、判定値-95+10 > 2B100<=-85 > 自動失敗!" +failure = true +rands = [ +] ##################### ### 増悪/中毒判定 ### From c4d9d7b9ce6fd27786f0363a46ed9295f95500ed Mon Sep 17 00:00:00 2001 From: Nobuto Kaitoh Date: Sat, 1 Feb 2025 08:54:53 +0900 Subject: [PATCH 20/20] =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E3=82=B7?= =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=A0=E5=90=8D=E3=81=A8=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E3=81=8C=E3=81=AA=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 作者様からの要望 --- lib/bcdice/game_system/ArknightsFan.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bcdice/game_system/ArknightsFan.rb b/lib/bcdice/game_system/ArknightsFan.rb index 0b469e98f..e1ce2d9d8 100644 --- a/lib/bcdice/game_system/ArknightsFan.rb +++ b/lib/bcdice/game_system/ArknightsFan.rb @@ -7,10 +7,10 @@ class ArknightsFan < Base ID = "ArknightsFan" # ゲームシステム名 - NAME = "アークナイツTRPG by Dapto" + NAME = "アークナイツTRPG by daaaper" # ゲームシステム名の読みがな - SORT_KEY = "ああくないつTRPGはいたふと" + SORT_KEY = "ああくないつTRPGはいてえはあ" HELP_MESSAGE = <<~TEXT ■ 能力値判定 (nADm<=x)