From 3f635c27e4c907c40b46cee194b38b249f32ba55 Mon Sep 17 00:00:00 2001 From: ViVi Date: Tue, 18 May 2021 00:34:46 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[StellarKnights]=20=E3=82=A2=E3=82=BF?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=88=A4=E5=AE=9A=E3=81=AE=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=82=B9=E6=95=B0=E3=81=AB=E5=8A=A0=E7=AE=97=E5=BC=8F=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/StellarKnights.rb | 23 +++++++++++++++++------ test/data/StellarKnights.toml | 13 +++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/bcdice/game_system/StellarKnights.rb b/lib/bcdice/game_system/StellarKnights.rb index 00a7c3fc1..3e4ebe242 100644 --- a/lib/bcdice/game_system/StellarKnights.rb +++ b/lib/bcdice/game_system/StellarKnights.rb @@ -23,6 +23,7 @@ class StellarKnights < Base d省略時はダイスを振った結果のみ表示。(nSKはnB6と同じ) 4SK: ダイスを4個振って、その結果を表示 + 4+2SK: ダイスを4+2 (=6) 個振って、その結果を表示 5SK3: 【アタック判定:5ダイス】、対象の防御力を3として成功数を表示 3SK,1>6: ダイスを3個振り、出目が1のダイスを全て6に変更し、その結果を表示 6SK4,1>6,2>6: 【アタック判定:6ダイス】、出目が1と2のダイスを全て6に変更、対象の防御力を4として成功数を表示 @@ -75,8 +76,12 @@ def eval_game_system_specific_command(command) if (table = self.class::TABLES[command]) table.roll(@randomizer) - elsif (m = /(\d+)SK(\d)?((,\d>\d)+)?/.match(command)) - resolute_action(m[1].to_i, m[2] && m[2].to_i, m[3], command) + elsif (m = /(\d+(\+\d+)*)SK(\d)?((,\d>\d)+)?/.match(command)) + resolute_action( + Arithmetic.eval(m[1], round_type: RoundType::FLOOR), + m[3] && m[3].to_i, + m[4] + ) elsif command == 'STB2' roll_all_situation_b2_tables elsif command == 'ALLS' @@ -94,13 +99,12 @@ def eval_game_system_specific_command(command) # @param [Integer] num_dices # @param [Integer | nil] defence # @param [String] dice_change_text - # @param [String] command # @return [Result, String] - def resolute_action(num_dices, defence, dice_change_text, command) + def resolute_action(num_dices, defence, dice_change_text) dices = @randomizer.roll_barabara(num_dices, 6).sort dice_text = dices.join(",") - output = "(#{command}) > #{dice_text}" + output = "(#{remake_command(num_dices, defence, dice_change_text)}) > #{dice_text}" if dices.empty? return output + translate("StellarKnights.SK.no_dice_error") end @@ -132,6 +136,13 @@ def resolute_action(num_dices, defence, dice_change_text, command) end end + def remake_command(num_dices, defence, dice_change_text) + command = "#{num_dices}SK" + command += defence.to_s unless defence.nil? + command += dice_change_text unless dice_change_text.nil? + command + end + def parse_dice_change_rules(text) return [] if text.nil? @@ -213,7 +224,7 @@ def translate_tables(locale) TABLES = translate_tables(:ja_jp) - register_prefix('\d+SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) + register_prefix('\d+(\+\d+)*SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) end end end diff --git a/test/data/StellarKnights.toml b/test/data/StellarKnights.toml index ea7934152..e9cd8f00f 100644 --- a/test/data/StellarKnights.toml +++ b/test/data/StellarKnights.toml @@ -15,6 +15,19 @@ input = "0SK" output = "(0SK) > ダイスが 0 個です(アタック判定が発生しません)" rands = [] +[[ test ]] +game_system = "StellarKnights" +input = "4+2SK" +output = "(6SK) > 1,1,3,4,5,6" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, +] + [[ test ]] game_system = "StellarKnights" input = "5SK3" From c4536b57338144916d27c57def1970ed31a81d4d Mon Sep 17 00:00:00 2001 From: ViVi Date: Tue, 4 May 2021 02:53:42 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[StellarKnights]=20=E3=82=A2=E3=82=BF?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=88=A4=E5=AE=9A=E3=81=AE=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=82=B9=E6=95=B0=E3=81=AB=E9=99=A4=E7=AE=97=E5=BC=8F=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 『マルジナリア』p42《我らを害す力よ消失せよ》などを想定 --- lib/bcdice/game_system/StellarKnights.rb | 5 +++-- test/data/StellarKnights.toml | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/bcdice/game_system/StellarKnights.rb b/lib/bcdice/game_system/StellarKnights.rb index 3e4ebe242..26f6736fc 100644 --- a/lib/bcdice/game_system/StellarKnights.rb +++ b/lib/bcdice/game_system/StellarKnights.rb @@ -24,6 +24,7 @@ class StellarKnights < Base 4SK: ダイスを4個振って、その結果を表示 4+2SK: ダイスを4+2 (=6) 個振って、その結果を表示 + 5/2SK: ダイスを5個の半分 (=2) 個振って、その結果を表示 5SK3: 【アタック判定:5ダイス】、対象の防御力を3として成功数を表示 3SK,1>6: ダイスを3個振り、出目が1のダイスを全て6に変更し、その結果を表示 6SK4,1>6,2>6: 【アタック判定:6ダイス】、出目が1と2のダイスを全て6に変更、対象の防御力を4として成功数を表示 @@ -76,7 +77,7 @@ def eval_game_system_specific_command(command) if (table = self.class::TABLES[command]) table.roll(@randomizer) - elsif (m = /(\d+(\+\d+)*)SK(\d)?((,\d>\d)+)?/.match(command)) + elsif (m = %r{(\d+([+/]\d+)*)SK(\d)?((,\d>\d)+)?}.match(command)) resolute_action( Arithmetic.eval(m[1], round_type: RoundType::FLOOR), m[3] && m[3].to_i, @@ -224,7 +225,7 @@ def translate_tables(locale) TABLES = translate_tables(:ja_jp) - register_prefix('\d+(\+\d+)*SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) + register_prefix('\d+([+\/]\d+)*SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) end end end diff --git a/test/data/StellarKnights.toml b/test/data/StellarKnights.toml index e9cd8f00f..a5b3c9429 100644 --- a/test/data/StellarKnights.toml +++ b/test/data/StellarKnights.toml @@ -28,6 +28,24 @@ rands = [ { sides = 6, value = 1 }, ] +[[ test ]] +game_system = "StellarKnights" +input = "4/2SK" +output = "(2SK) > 1,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "StellarKnights" +input = "5/2SK" +output = "(2SK) > 1,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, +] + [[ test ]] game_system = "StellarKnights" input = "5SK3" From 6152c29d8ec0852e63c5838c14ba98921763e0ef Mon Sep 17 00:00:00 2001 From: ViVi Date: Tue, 4 May 2021 03:00:49 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[StellarKnights]=20=E3=82=A2=E3=82=BF?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=88=A4=E5=AE=9A=E3=81=AE=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=82=B9=E6=95=B0=E3=81=AE=E8=A8=88=E7=AE=97=E3=81=AB=E6=8B=AC?= =?UTF-8?q?=E5=BC=A7=E3=82=92=E4=BD=BF=E3=81=88=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 『マルジナリア』p42《我らを害す力よ消失せよ》などを想定 --- lib/bcdice/game_system/StellarKnights.rb | 9 +++++---- test/data/StellarKnights.toml | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/bcdice/game_system/StellarKnights.rb b/lib/bcdice/game_system/StellarKnights.rb index 26f6736fc..2a0d831c6 100644 --- a/lib/bcdice/game_system/StellarKnights.rb +++ b/lib/bcdice/game_system/StellarKnights.rb @@ -25,6 +25,7 @@ class StellarKnights < Base 4SK: ダイスを4個振って、その結果を表示 4+2SK: ダイスを4+2 (=6) 個振って、その結果を表示 5/2SK: ダイスを5個の半分 (=2) 個振って、その結果を表示 + (5+3)/2SK: ダイスを(5+3)個の半分 (=4) 個振って、その結果を表示 5SK3: 【アタック判定:5ダイス】、対象の防御力を3として成功数を表示 3SK,1>6: ダイスを3個振り、出目が1のダイスを全て6に変更し、その結果を表示 6SK4,1>6,2>6: 【アタック判定:6ダイス】、出目が1と2のダイスを全て6に変更、対象の防御力を4として成功数を表示 @@ -77,11 +78,11 @@ def eval_game_system_specific_command(command) if (table = self.class::TABLES[command]) table.roll(@randomizer) - elsif (m = %r{(\d+([+/]\d+)*)SK(\d)?((,\d>\d)+)?}.match(command)) + elsif (m = %r{([()+/\d]+)SK(\d)?((,\d>\d)+)?}.match(command)) resolute_action( Arithmetic.eval(m[1], round_type: RoundType::FLOOR), - m[3] && m[3].to_i, - m[4] + m[2] && m[2].to_i, + m[3] ) elsif command == 'STB2' roll_all_situation_b2_tables @@ -225,7 +226,7 @@ def translate_tables(locale) TABLES = translate_tables(:ja_jp) - register_prefix('\d+([+\/]\d+)*SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) + register_prefix('[()+\/\d]+SK', 'STB2', 'ALLS', 'PET', 'FT', TABLES.keys) end end end diff --git a/test/data/StellarKnights.toml b/test/data/StellarKnights.toml index a5b3c9429..e0b58b4c2 100644 --- a/test/data/StellarKnights.toml +++ b/test/data/StellarKnights.toml @@ -28,6 +28,19 @@ rands = [ { sides = 6, value = 1 }, ] +[[ test ]] +game_system = "StellarKnights" +input = "(4+2)SK" +output = "(6SK) > 1,1,3,4,5,6" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, +] + [[ test ]] game_system = "StellarKnights" input = "4/2SK" @@ -46,6 +59,16 @@ rands = [ { sides = 6, value = 1 }, ] +[[ test ]] +game_system = "StellarKnights" +input = "(4+2)/2SK" +output = "(3SK) > 1,3,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, +] + [[ test ]] game_system = "StellarKnights" input = "5SK3" From 51ea427d5dc558cbaba1ae401fdbde9b0ce54f8d Mon Sep 17 00:00:00 2001 From: ViVi Date: Tue, 4 May 2021 03:03:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[StellarKnights]=20=E3=82=A2=E3=82=BF?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=88=A4=E5=AE=9A=E3=81=AE=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=82=B9=E6=95=B0=E3=81=AE=E8=A8=88=E7=AE=97=E5=BC=8F=E3=81=8C?= =?UTF-8?q?=E7=A0=B4=E7=B6=BB=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AF=E7=84=A1=E8=A6=96=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/StellarKnights.rb | 10 +++++----- test/data/StellarKnights.toml | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/bcdice/game_system/StellarKnights.rb b/lib/bcdice/game_system/StellarKnights.rb index 2a0d831c6..dded2982a 100644 --- a/lib/bcdice/game_system/StellarKnights.rb +++ b/lib/bcdice/game_system/StellarKnights.rb @@ -79,11 +79,11 @@ def eval_game_system_specific_command(command) if (table = self.class::TABLES[command]) table.roll(@randomizer) elsif (m = %r{([()+/\d]+)SK(\d)?((,\d>\d)+)?}.match(command)) - resolute_action( - Arithmetic.eval(m[1], round_type: RoundType::FLOOR), - m[2] && m[2].to_i, - m[3] - ) + num_dices = Arithmetic.eval(m[1], round_type: RoundType::FLOOR) + + unless num_dices.nil? + resolute_action(num_dices, m[2] && m[2].to_i, m[3]) + end elsif command == 'STB2' roll_all_situation_b2_tables elsif command == 'ALLS' diff --git a/test/data/StellarKnights.toml b/test/data/StellarKnights.toml index e0b58b4c2..36b3ddbcb 100644 --- a/test/data/StellarKnights.toml +++ b/test/data/StellarKnights.toml @@ -69,6 +69,12 @@ rands = [ { sides = 6, value = 3 }, ] +[[ test ]] +game_system = "StellarKnights" +input = "(4+2/2SK" +output = "" +rands = [] + [[ test ]] game_system = "StellarKnights" input = "5SK3" From 43180c2ef19c4e68209b41fdf1c919d44bae7905 Mon Sep 17 00:00:00 2001 From: ViVi Date: Wed, 19 May 2021 08:33:52 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[StellarKnights:Korean]=20=E6=97=A5?= =?UTF-8?q?=E6=9C=AC=E8=AA=9E=E7=89=88=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=83=98=E3=83=AB=E3=83=97=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E3=83=99=E3=82=BF=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/StellarKnights_Korean.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/bcdice/game_system/StellarKnights_Korean.rb b/lib/bcdice/game_system/StellarKnights_Korean.rb index 4de18aaa5..55d9fe609 100644 --- a/lib/bcdice/game_system/StellarKnights_Korean.rb +++ b/lib/bcdice/game_system/StellarKnights_Korean.rb @@ -22,6 +22,9 @@ class StellarKnights_Korean < StellarKnights d 생략 시 다이스를 굴린 결과만 표시. (nSK는 nB6과 동일) 4SK: 다이스 4개를 굴린 결과 표시. + 4+2SK: ダイスを4+2 (=6) 個振って、その結果を表示 + 5/2SK: ダイスを5個の半分 (=2) 個振って、その結果を表示 + (5+3)/2SK: ダイスを(5+3)個の半分 (=4) 個振って、その結果を表示 5SK3: 【공격 판정: 5다이스】, 대상의 방어력을 3으로 계산해 성공 수 표시. 3SK,1>6: 다이스 3개 굴림, 1이 나오면 전부 6으로 변경, 대상의 방어력을 4로 계산해 성공 수 표시. 6SK4,1>6,2>6: 【공격 판정: 6다이스】, 1과 2가 나오면 전부 6으로 변경, 대상의 방어력을 4로 계산해 성공 수 표시. From 0b2a84a37027b3e186806d38db5fd8d736f0e1a5 Mon Sep 17 00:00:00 2001 From: ViVi Date: Wed, 19 May 2021 08:39:18 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[StellarKnights:Korean]=20=E6=97=A5?= =?UTF-8?q?=E6=9C=AC=E8=AA=9E=E7=89=88=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=92=E3=83=99=E3=82=BF=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/data/StellarKnights_Korean.toml | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test/data/StellarKnights_Korean.toml b/test/data/StellarKnights_Korean.toml index 0692ce57f..efa156c4f 100644 --- a/test/data/StellarKnights_Korean.toml +++ b/test/data/StellarKnights_Korean.toml @@ -9,6 +9,66 @@ rands = [ { sides = 6, value = 4 }, ] +[[ test ]] +game_system = "StellarKnights:Korean" +input = "4+2SK" +output = "(6SK) > 1,1,3,4,5,6" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "StellarKnights:Korean" +input = "(4+2)SK" +output = "(6SK) > 1,1,3,4,5,6" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 4 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "StellarKnights:Korean" +input = "4/2SK" +output = "(2SK) > 1,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "StellarKnights:Korean" +input = "5/2SK" +output = "(2SK) > 1,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, +] + +[[ test ]] +game_system = "StellarKnights:Korean" +input = "(4+2)/2SK" +output = "(3SK) > 1,3,5" +rands = [ + { sides = 6, value = 5 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, +] + +[[ test ]] +game_system = "StellarKnights:Korean" +input = "(4+2/2SK" +output = "" +rands = [] + [[ test ]] game_system = "StellarKnights:Korean" input = "5SK3"