From e8bac87c2fa8a5b206dd4b929ea80b4cdc0cf8e6 Mon Sep 17 00:00:00 2001 From: blhsrwznrghfzpr Date: Tue, 27 Apr 2021 21:34:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[TrinitySeven]=20=E3=83=98=E3=83=AB?= =?UTF-8?q?=E3=83=97=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE?= =?UTF-8?q?=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/TrinitySeven.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bcdice/game_system/TrinitySeven.rb b/lib/bcdice/game_system/TrinitySeven.rb index 62b9bdd35..ff054f6ca 100644 --- a/lib/bcdice/game_system/TrinitySeven.rb +++ b/lib/bcdice/game_system/TrinitySeven.rb @@ -17,15 +17,15 @@ class TrinitySeven < Base クリティカルが変動した命中及び、7の出目がある場合のダメージ計算が行なえます。 なお、通常の判定としても利用できます。 - ・発動/命中 [TR(±c*)<=(x)±(y*)又は TR<=(x)など]*は必須ではない項目です。 - "TR(クリティカルの修正値*)<=(発動/命中)±(発動/命中の修正値*)" + ・発動/命中 [TR(±c*)<=(x)±(y*) 又は TR<=(x) など]*は必須ではない項目です。 + "TR(クリティカルの修正値*)<=(発動/命中)±(発動/命中の修正値*)" 加算減算のみ修正値も付けられます。 [修正値]は必須ではありません。 - 例)TR<=50 TR<=60+20 TR7<=40 TR-7<=80 TR+10<=80+20 + 例)TR<=50 TR<=60+20 TR7<=40 TR-7<=80 TR+10<=80+20 - ・ダメージ計算 [(x)DM(c*)±(y*)又は(x)DM(c*)又は(x)DM±(y*)]*は必須ではない項目です。 - "(ダイス数)DM(7の出目の数*)+(修正*)" + ・ダメージ計算 [(x)DM(c*)±(y*) 又は (x)DM(c*) 又は (x)DM±(y*)]*は必須ではない項目です。 + "(ダイス数)DM(7の出目の数*)+(修正*)" 加算減算のみ修正値も付けられます。 [7の出目の数]および[修正値]は必須ではありません。 - 例)6DM2+1 5DM2 4DM 3DM+3 + 例)6DM2+1 5DM2 4DM 3DM+3 後から7の出目に変更する場合はC(7*6+5)のように入力して計算してください。 ・名前表 [TRNAME] From 637b369f6e37a5caa830f75432440280e2f27684 Mon Sep 17 00:00:00 2001 From: blhsrwznrghfzpr Date: Tue, 27 Apr 2021 21:35:38 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[TrinitySeven]=20Result=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/TrinitySeven.rb | 47 +++++---- test/data/TrinitySeven.toml | 126 +++++++++++++++++++++++-- 2 files changed, 144 insertions(+), 29 deletions(-) diff --git a/lib/bcdice/game_system/TrinitySeven.rb b/lib/bcdice/game_system/TrinitySeven.rb index ff054f6ca..48c3f2c54 100644 --- a/lib/bcdice/game_system/TrinitySeven.rb +++ b/lib/bcdice/game_system/TrinitySeven.rb @@ -44,12 +44,8 @@ def eval_game_system_specific_command(command) # スパゲッティなコード return "#{firstName} , #{secondName}" end - if /^TR([+\-\d]*)<=(\d*)([+\-\d]*)/ =~ command - critical = Regexp.last_match(1).to_i + 7 - target = Regexp.last_match(2).to_i - modify = Regexp.last_match(3).to_i - return rollHit(command, critical, target, modify) - end + result = roll_hit(command) + return result if result if /^(\d*)DM(\d*)([+\-\d]*)$/ =~ command diceCount = Regexp.last_match(1).to_i @@ -61,25 +57,38 @@ def eval_game_system_specific_command(command) # スパゲッティなコード return '' end - def rollHit(command, critical, target, modify) - target += modify + def roll_hit(command) + parser = Command::Parser.new(/TR\d*/, round_type: round_type) + .restrict_cmp_op_to(:<=) + cmd = parser.parse(command) + return nil unless cmd - total = @randomizer.roll_once(100) - result = getHitRollResult(total, target, critical) + modify = cmd.command[2..-1].to_i + cmd.modify_number + critical = 7 + modify + target = cmd.target_number - text = "(#{command}) > #{total}[#{total}] > #{result}" - debug("eval_game_system_specific_command result text", text) + total = @randomizer.roll_once(100) + result = get_hit_roll_result(total, target, critical) - return text - end + cmd.command = "TR" + cmd.modify_number = modify - def getHitRollResult(total, target, critical) - return "ファンブル" if total >= 96 - return "クリティカル" if total <= critical + result.text = "(#{cmd}) > #{total} > #{result.text}" + debug("eval_game_system_specific_command result text", result.text) - return "成功" if total <= target + result + end - return "失敗" + def get_hit_roll_result(total, target, critical) + if total >= 96 + Result.fumble("ファンブル") + elsif total <= critical + Result.critical("クリティカル") + elsif total <= target + Result.success("成功") + else + Result.failure("失敗") + end end def rollDamage(command, diceCount, critical, modify) diff --git a/test/data/TrinitySeven.toml b/test/data/TrinitySeven.toml index 6a1d94422..98af8293a 100644 --- a/test/data/TrinitySeven.toml +++ b/test/data/TrinitySeven.toml @@ -241,7 +241,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR-1<=50+20" -output = "(TR-1<=50+20) > 1[1] > クリティカル" +output = "(TR-1<=70) > 1 > クリティカル" +success = true +critical = true rands = [ { sides = 100, value = 1 }, ] @@ -249,7 +251,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR-1<=50+20" -output = "(TR-1<=50+20) > 100[100] > ファンブル" +output = "(TR-1<=70) > 100 > ファンブル" +failure = true +fumble = true rands = [ { sides = 100, value = 100 }, ] @@ -257,7 +261,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR+1<=50-20" -output = "(TR+1<=50-20) > 1[1] > クリティカル" +output = "(TR+1<=30) > 1 > クリティカル" +success = true +critical = true rands = [ { sides = 100, value = 1 }, ] @@ -265,7 +271,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR+1<=50-20" -output = "(TR+1<=50-20) > 100[100] > ファンブル" +output = "(TR+1<=30) > 100 > ファンブル" +failure = true +fumble = true rands = [ { sides = 100, value = 100 }, ] @@ -273,7 +281,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR+1<=50" -output = "(TR+1<=50) > 1[1] > クリティカル" +output = "(TR+1<=50) > 1 > クリティカル" +success = true +critical = true rands = [ { sides = 100, value = 1 }, ] @@ -281,7 +291,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR-1<=50" -output = "(TR-1<=50) > 100[100] > ファンブル" +output = "(TR-1<=50) > 100 > ファンブル" +failure = true +fumble = true rands = [ { sides = 100, value = 100 }, ] @@ -289,7 +301,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR<=50+20" -output = "(TR<=50+20) > 1[1] > クリティカル" +output = "(TR<=70) > 1 > クリティカル" +success = true +critical = true rands = [ { sides = 100, value = 1 }, ] @@ -297,7 +311,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR<=50+20" -output = "(TR<=50+20) > 100[100] > ファンブル" +output = "(TR<=70) > 100 > ファンブル" +failure = true +fumble = true rands = [ { sides = 100, value = 100 }, ] @@ -305,7 +321,9 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR<=50" -output = "(TR<=50) > 1[1] > クリティカル" +output = "(TR<=50) > 1 > クリティカル" +success = true +critical = true rands = [ { sides = 100, value = 1 }, ] @@ -313,11 +331,99 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TR<=50" -output = "(TR<=50) > 100[100] > ファンブル" +output = "(TR<=50) > 7 > クリティカル" +success = true +critical = true +rands = [ + { sides = 100, value = 7 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 8 > 成功" +success = true +rands = [ + { sides = 100, value = 8 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 50 > 成功" +success = true +rands = [ + { sides = 100, value = 50 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 51 > 失敗" +failure = true +rands = [ + { sides = 100, value = 51 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 95 > 失敗" +failure = true +rands = [ + { sides = 100, value = 95 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 96 > ファンブル" +failure = true +fumble = true +rands = [ + { sides = 100, value = 96 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=50" +output = "(TR<=50) > 100 > ファンブル" +failure = true +fumble = true rands = [ { sides = 100, value = 100 }, ] +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=0 目標値に関わらずクリティカル" +output = "(TR<=0) > 7 > クリティカル" +success = true +critical = true +rands = [ + { sides = 100, value = 7 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR<=100 目標値に関わらずファンブル" +output = "(TR<=100) > 96 > ファンブル" +failure = true +fumble = true +rands = [ + { sides = 100, value = 96 }, +] + +[[ test ]] +game_system = "TrinitySeven" +input = "TR7<=40 クリティカル値変動" +output = "(TR+7<=40) > 14 > クリティカル" +success = true +critical = true +rands = [ + { sides = 100, value = 14 }, +] + [[ test ]] game_system = "TrinitySeven" input = "TRNAME" From dc44a5943dd94cef1373e9e05d3d653e19eda324 Mon Sep 17 00:00:00 2001 From: blhsrwznrghfzpr Date: Tue, 27 Apr 2021 22:24:40 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[TrinitySeven]=20=E3=83=80=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/TrinitySeven.rb | 55 ++++++++++---------------- test/data/TrinitySeven.toml | 50 +++++++++++------------ 2 files changed, 46 insertions(+), 59 deletions(-) diff --git a/lib/bcdice/game_system/TrinitySeven.rb b/lib/bcdice/game_system/TrinitySeven.rb index 48c3f2c54..01e3140f9 100644 --- a/lib/bcdice/game_system/TrinitySeven.rb +++ b/lib/bcdice/game_system/TrinitySeven.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "bcdice/format" + module BCDice module GameSystem class TrinitySeven < Base @@ -44,17 +46,8 @@ def eval_game_system_specific_command(command) # スパゲッティなコード return "#{firstName} , #{secondName}" end - result = roll_hit(command) - return result if result - - if /^(\d*)DM(\d*)([+\-\d]*)$/ =~ command - diceCount = Regexp.last_match(1).to_i - critical = Regexp.last_match(2).to_i - modify = Regexp.last_match(3).to_i - return rollDamage(command, diceCount, critical, modify) - end - - return '' + roll_hit(command) || + roll_damage(command) end def roll_hit(command) @@ -91,38 +84,33 @@ def get_hit_roll_result(total, target, critical) end end - def rollDamage(command, diceCount, critical, modify) - return "" if diceCount < critical + def roll_damage(command) + parser = Command::Parser.new(/\d+DM\d*/, round_type: round_type) + .restrict_cmp_op_to(nil) + cmd = parser.parse(command) + return nil unless cmd - dice_list = @randomizer.roll_barabara(diceCount, 6) - total = dice_list.sum() - diceText = dice_list.join(",") + dice_count, critical = cmd.command.split("DM", 2).map(&:to_i) + modify = cmd.modify_number - additionalListText = "" - total, additionalList = getRollDamageCritialText(diceCount, critical, total, diceText, modify) + dice_list = @randomizer.roll_barabara(dice_count, 6).sort + dice_text = dice_list.join(",") - additionalListText = "→[#{additionalList.join(',')}]" unless additionalList.empty? + total, additionalList = get_roll_damage_result(dice_count, critical, dice_list, modify) - modifyText = "" - modifyText = "+#{modify}" if modify > 0 - modifyText = modify.to_s if modify < 0 + additionalListText = additionalList.nil? ? "" : "→[#{additionalList.join(',')}]" - text = "(#{command}) [#{diceText}]#{additionalListText}#{modifyText} > #{total}" + text = "(#{cmd}) > [#{dice_text}]#{additionalListText}#{Format.modifier(modify)} > #{total}" return text end - def getRollDamageCritialText(diceCount, critical, total, diceText, modify) - diceList = [] - - if critical == 0 - total += modify - return total, diceList + def get_roll_damage_result(diceCount, critical, diceList, modify) + if critical <= 0 + total = diceList.sum() + modify + return total, nil end - diceList = diceText.split(/,/).map(&:to_i) - - diceList.sort! restDice = diceList.clone critical = diceCount if critical > diceCount @@ -136,8 +124,7 @@ def getRollDamageCritialText(diceCount, critical, total, diceText, modify) max = restDice.pop max = 1 if max.nil? - total = max * (7**critical) + modify - restDice.each { |i| total += i } + total = max * (7**critical) + restDice.sum() + modify return total, diceList end diff --git a/test/data/TrinitySeven.toml b/test/data/TrinitySeven.toml index 98af8293a..10d44652e 100644 --- a/test/data/TrinitySeven.toml +++ b/test/data/TrinitySeven.toml @@ -1,7 +1,7 @@ [[ test ]] game_system = "TrinitySeven" input = "1DM1+1" -output = "(1DM1+1) [1]→[7]+1 > 8" +output = "(1DM1+1) > [1]→[7]+1 > 8" rands = [ { sides = 6, value = 1 }, ] @@ -9,7 +9,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "1DM1-1" -output = "(1DM1-1) [1]→[7]-1 > 6" +output = "(1DM1-1) > [1]→[7]-1 > 6" rands = [ { sides = 6, value = 1 }, ] @@ -17,7 +17,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "1DM1" -output = "(1DM1) [1]→[7] > 7" +output = "(1DM1) > [1]→[7] > 7" rands = [ { sides = 6, value = 1 }, ] @@ -25,7 +25,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "1DM" -output = "(1DM) [1] > 1" +output = "(1DM) > [1] > 1" rands = [ { sides = 6, value = 1 }, ] @@ -39,7 +39,7 @@ rands = [] [[ test ]] game_system = "TrinitySeven" input = "1DM-1" -output = "(1DM-1) [1]-1 > 0" +output = "(1DM-1) > [1]-1 > 0" rands = [ { sides = 6, value = 1 }, ] @@ -47,7 +47,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM1+1" -output = "(2DM1+1) [1,6]→[6,7]+1 > 43" +output = "(2DM1+1) > [1,6]→[6,7]+1 > 43" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -56,7 +56,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM1" -output = "(2DM1) [1,6]→[6,7] > 42" +output = "(2DM1) > [1,6]→[6,7] > 42" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -65,7 +65,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM2" -output = "(2DM2) [1,6]→[7,7] > 49" +output = "(2DM2) > [1,6]→[7,7] > 49" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -74,7 +74,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM1-1" -output = "(2DM1-1) [1,6]→[6,7]-1 > 41" +output = "(2DM1-1) > [1,6]→[6,7]-1 > 41" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -83,7 +83,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM1+1" -output = "(2DM1+1) [1,6]→[6,7]+1 > 43" +output = "(2DM1+1) > [1,6]→[6,7]+1 > 43" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -92,7 +92,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM" -output = "(2DM) [1,6] > 7" +output = "(2DM) > [1,6] > 7" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -101,7 +101,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM+1" -output = "(2DM+1) [1,6]+1 > 8" +output = "(2DM+1) > [1,6]+1 > 8" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -110,7 +110,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "2DM-1" -output = "(2DM-1) [1,6]-1 > 6" +output = "(2DM-1) > [1,6]-1 > 6" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -119,7 +119,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM1-1" -output = "(3DM1-1) [1,6,3]→[3,6,7]-1 > 44" +output = "(3DM1-1) > [1,3,6]→[3,6,7]-1 > 44" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -129,7 +129,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM1+1" -output = "(3DM1+1) [1,6,3]→[3,6,7]+1 > 46" +output = "(3DM1+1) > [1,3,6]→[3,6,7]+1 > 46" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -139,7 +139,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM1" -output = "(3DM1) [1,6,3]→[3,6,7] > 45" +output = "(3DM1) > [1,3,6]→[3,6,7] > 45" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -149,7 +149,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM2" -output = "(3DM2) [1,6,3]→[6,7,7] > 294" +output = "(3DM2) > [1,3,6]→[6,7,7] > 294" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -159,7 +159,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM3" -output = "(3DM3) [1,6,3]→[7,7,7] > 343" +output = "(3DM3) > [1,3,6]→[7,7,7] > 343" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -169,7 +169,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "4DM2" -output = "(4DM2) [1,2,3,4]→[3,4,7,7] > 199" +output = "(4DM2) > [1,2,3,4]→[3,4,7,7] > 199" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 2 }, @@ -180,7 +180,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "4DM4" -output = "(4DM4) [1,2,3,4]→[7,7,7,7] > 2401" +output = "(4DM4) > [1,2,3,4]→[7,7,7,7] > 2401" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 2 }, @@ -191,7 +191,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM1-1" -output = "(3DM1-1) [1,6,3]→[3,6,7]-1 > 44" +output = "(3DM1-1) > [1,3,6]→[3,6,7]-1 > 44" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -201,7 +201,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM1+1" -output = "(3DM1+1) [1,6,3]→[3,6,7]+1 > 46" +output = "(3DM1+1) > [1,3,6]→[3,6,7]+1 > 46" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -211,7 +211,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM" -output = "(3DM) [1,6,3] > 10" +output = "(3DM) > [1,3,6] > 10" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -221,7 +221,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM+1" -output = "(3DM+1) [1,6,3]+1 > 11" +output = "(3DM+1) > [1,3,6]+1 > 11" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -231,7 +231,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "3DM-1" -output = "(3DM-1) [1,6,3]-1 > 9" +output = "(3DM-1) > [1,3,6]-1 > 9" rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, From 130836e5ba2cc0c813bfe8d453656c76f0006b61 Mon Sep 17 00:00:00 2001 From: blhsrwznrghfzpr Date: Tue, 27 Apr 2021 23:02:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[TrinitySeven]=20=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E8=A1=A8=E3=81=AE=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/TrinitySeven.rb | 443 +++++++++++++------------ test/data/TrinitySeven.toml | 11 +- 2 files changed, 233 insertions(+), 221 deletions(-) diff --git a/lib/bcdice/game_system/TrinitySeven.rb b/lib/bcdice/game_system/TrinitySeven.rb index 01e3140f9..00082f67f 100644 --- a/lib/bcdice/game_system/TrinitySeven.rb +++ b/lib/bcdice/game_system/TrinitySeven.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "bcdice/dice_table/table" require "bcdice/format" module BCDice @@ -40,14 +41,9 @@ class TrinitySeven < Base def eval_game_system_specific_command(command) # スパゲッティなコードだけど許して!!! → 絶対に許さない。全力でリファクタリングした。 debug("eval_game_system_specific_command command", command) - if /TRNAME/ =~ command - firstName, = get_NAME_table - secondName, = get_NAMEtwo_table - return "#{firstName} , #{secondName}" - end - roll_hit(command) || - roll_damage(command) + roll_damage(command) || + roll_name(command) end def roll_hit(command) @@ -137,224 +133,231 @@ def result_1d100(_total, dice_total, _cmp_op, _target) end end - # 名前表 - def get_NAME_table - table = [ - [1, '春日'], - [2, '浅見'], - [3, '風間'], - [4, '神無月'], - [5, '倉田'], - [6, '不動'], - [7, '山奈'], - [8, 'シャルロック'], - [9, '霧隠'], - [10, '果心'], - [11, '今井'], - [12, '長瀬'], - [13, '明智'], - [14, '風祭'], - [15, '志貫'], - [16, '一文字'], - [17, '月夜野'], - [18, '桜田門'], - [19, '果瀬'], - [20, '九十九'], - [21, '速水'], - [22, '片桐'], - [23, '葉月'], - [24, 'ウィンザー'], - [25, '時雨里'], - [26, '神城'], - [27, '水際'], - [28, '一ノ江'], - [29, '仁藤'], - [30, '北千住'], - [31, '西村'], - [32, '諏訪'], - [33, '藤宮'], - [34, '御代'], - [35, '橘'], - [36, '霧生'], - [37, '白石'], - [38, '椎名'], - [39, '綾小路'], - [40, '二条'], - [41, '光明寺'], - [42, '春秋'], - [43, '雪見'], - [44, '刀条院'], - [45, 'ランカスター'], - [46, 'ハクア'], - [47, 'エルタニア'], - [48, 'ハーネス'], - [49, 'アウグストゥス'], - [50, '椎名町'], - [51, '鍵守'], - [52, '茜ヶ崎'], - [53, '鎮宮'], - [54, '美柳'], - [55, '鎖々塚'], - [56, '櫻ノ杜'], - [57, '鏡ヶ守'], - [58, '輝井'], - [59, '南陽'], - [60, '雪乃城'], - [61, '六角屋'], - [62, '鈴々'], - [63, '東三条'], - [64, '朱雀院'], - [65, '青龍院'], - [66, '白虎院'], - [67, '玄武院'], - [68, '麒麟院'], - [69, 'リーシュタット'], - [70, 'サンクチュアリ'], - [71, '六実'], - [72, '須藤'], - [73, 'ミレニアム'], - [74, '七里'], - [75, '三枝'], - [76, '八殿'], - [77, '藤里'], - [78, '久宝'], - [79, '東'], - [80, '赤西'], - [81, '神ヶ崎'], - [82, 'グランシア'], - [83, 'ダークブーレード'], - [84, '天光寺'], - [85, '月見里'], - [86, '璃宮'], - [87, '藤見澤'], - [88, '赤聖'], - [89, '姫宮'], - [90, '華ノ宮'], - [91, '天才'], - [92, '達人'], - [93, '賢者'], - [94, '疾風'], - [95, '海の'], - [96, '最強'], - [97, '凶器'], - [98, '灼熱'], - [99, '人間兵器'], - [100, '魔王'], - ] + def roll_name(command) + unless command == "TRNAME" + return nil + end - dice_now = @randomizer.roll_once(100) + first_name = NAME1.roll(@randomizer).last_body + second_name = NAME2.roll(@randomizer).last_body - return get_table_by_number(dice_now, table) + text = "#{first_name} , #{second_name}" + return text end - def get_NAMEtwo_table - table = [ - [1, 'アラタ/聖'], - [2, 'アビィス/リリス'], - [3, 'ルーグ/レヴィ'], - [4, 'ラスト/アリン'], - [5, 'ソラ/ユイ'], - [6, 'イーリアス/アキオ'], - [7, 'アカーシャ/ミラ'], - [8, 'アリエス/リーゼロッテ'], - [9, 'ムラサメ/シャルム'], - [10, '龍貴/竜姫'], - [11, '英樹/春菜'], - [12, '準一/湊'], - [13, '急司郎/光理'], - [14, '夕也/愛奈'], - [15, '晴彦/アキ'], - [16, '疾風/ヤシロ'], - [17, 'カガリ/灯花'], - [18, '次郎/優都'], - [19, '春太郎/静理'], - [20, 'ジン/時雨'], - [21, 'イオリ/伊織'], - [22, 'ユウヒ/優姫'], - [23, 'サツキ/翠名'], - [24, 'シュライ/サクラ'], - [25, 'ミナヅキ/姫乃'], - [26, 'カエデ/優樹菜'], - [27, 'ハル/フユ'], - [28, 'オdール/瑞江'], - [29, 'ニトゥレスト/キリカ'], - [30, 'スカー/綾瀬'], - [31, '真夏/小夏'], - [32, '光一/ののか'], - [33, '彩/翠'], - [34, 'トウカ/柊花'], - [35, '命/ミコト'], - [36, '司/つかさ'], - [37, 'ゆとり/なごみ'], - [38, '冬彦/観月'], - [39, 'カレン/華恋'], - [40, '清次郎/亜矢'], - [41, 'サード/夢子'], - [42, 'ボックス/詩子'], - [43, 'ヘリオス/カエデ'], - [44, 'ゲート/京香'], - [45, 'オンリー/パトリシア'], - [46, 'ザッハーク/アーリ'], - [47, 'ラスタバン/ラスティ'], - [48, '桜花/燁澄'], - [49, '計都/リヴィア'], - [50, 'カルヴァリオ/香夜'], - [51, '悠人/夜々子'], - [52, '太子/羽菜'], - [53, '夕立/夕凪'], - [54, 'アルフ/愛美'], - [55, 'ファロス/灯利'], - [56, 'スプートニク/詩姫'], - [57, 'アーネスト/累'], - [58, 'ナイン/カグヤ'], - [59, 'クリア/ヒマワリ'], - [60, 'ウォーカー/オリビア'], - [61, 'ダーク/クオン'], - [62, 'ウェイヴ/凛'], - [63, 'ルーン/マリエ'], - [64, 'エンギ/セイギ'], - [65, 'シラヌイ/ミライ'], - [66, 'ブライン/キズナ'], - [67, 'クロウ/カナタ'], - [68, 'スレイヤー/ヒカル'], - [69, 'レス/ミリアリア'], - [70, 'ミフユ/サリエル'], - [71, '鳴央/音央'], - [72, 'モンジ/理亜'], - [73, 'パルデモントゥム/スナオ'], - [74, 'ミシェル/詩穂'], - [75, 'フレンズ/サン'], - [76, 'サトリ/識'], - [77, 'ロード/唯花'], - [78, 'クロノス/久宝'], - [79, 'フィラデルフィア/冬海'], - [80, 'ティンダロス/美星'], - [81, '勇弥/ユーリス'], - [82, 'エイト/アンジェラ'], - [83, 'サタン/ルシエル'], - [84, 'エース/小波'], - [85, 'セージ/胡蝶'], - [86, '忍/千之'], - [87, '重吾/キリコ'], - [88, 'マイケル/ミホシ'], - [89, 'カズマ/鶴香'], - [90, 'ヤマト/エリシエル'], - [91, '歴史上の人物の名前(信長、ジャンヌなど)'], - [92, 'スポーツ選手の名前(ベッカム、沙保里など)'], - [93, '学者の名前(ソクラテス、エレナなど)'], - [94, 'アイドルの名前(タクヤ、聖子など)'], - [95, '土地、国、町の名前(イングランド、ワシントンなど)'], - [96, 'モンスターの名前(ドラゴン、ラミアなど)'], - [97, '武器防具の名前(ソード、メイルなど)'], - [98, '自然現象の名前(カザンハリケーンなど)'], - [99, '機械の名前(洗濯機、テレビなど)'], - [100, '目についた物の名前(シャーペン、メガネなど)'], + NAME1 = DiceTable::Table.new( + "名字表", + "1D100", + [ + '春日', # 1 + '浅見', + '風間', + '神無月', + '倉田', + '不動', + '山奈', + 'シャルロック', + '霧隠', + '果心', # 10 + '今井', + '長瀬', + '明智', + '風祭', + '志貫', + '一文字', + '月夜野', + '桜田門', + '果瀬', + '九十九', # 20 + '速水', + '片桐', + '葉月', + 'ウィンザー', + '時雨里', + '神城', + '水際', + '一ノ江', + '仁藤', + '北千住', # 30 + '西村', + '諏訪', + '藤宮', + '御代', + '橘', + '霧生', + '白石', + '椎名', + '綾小路', + '二条', # 40 + '光明寺', + '春秋', + '雪見', + '刀条院', + 'ランカスター', + 'ハクア', + 'エルタニア', + 'ハーネス', + 'アウグストゥス', + '椎名町', # 50 + '鍵守', + '茜ヶ崎', + '鎮宮', + '美柳', + '鎖々塚', + '櫻ノ杜', + '鏡ヶ守', + '輝井', + '南陽', + '雪乃城', # 60 + '六角屋', + '鈴々', + '東三条', + '朱雀院', + '青龍院', + '白虎院', + '玄武院', + '麒麟院', + 'リーシュタット', + 'サンクチュアリ', # 70 + '六実', + '須藤', + 'ミレニアム', + '七里', + '三枝', + '八殿', + '藤里', + '久宝', + '東', + '赤西', # 80 + '神ヶ崎', + 'グランシア', + 'ダークブーレード', + '天光寺', + '月見里', + '璃宮', + '藤見澤', + '赤聖', + '姫宮', + '華ノ宮', # 90 + '"天才"', + '"達人"', + '"賢者"', + '"疾風"', + '"海の"', + '"最強"', + '"凶器"', + '"灼熱"', + '"人間兵器"', + '"魔王"', # 100 ] - - dice_now = @randomizer.roll_once(100) - - return get_table_by_number(dice_now, table) - end + ) + + NAME2 = DiceTable::Table.new( + "名字表", + "1D100", + [ + 'アラタ/聖', # 1 + 'アビィス/リリス', + 'ルーグ/レヴィ', + 'ラスト/アリン', + 'ソラ/ユイ', + 'イーリアス/アキオ', + 'アカーシャ/ミラ', + 'アリエス/リーゼロッテ', + 'ムラサメ/シャルム', + '龍貴/竜姫', # 10 + '英樹/春菜', + '準一/湊', + '急司郎/光理', + '夕也/愛奈', + '晴彦/アキ', + '疾風/ヤシロ', + 'カガリ/灯花', + '次郎/優都', + '春太郎/静理', + 'ジン/時雨', # 20 + 'イオリ/伊織', + 'ユウヒ/優姫', + 'サツキ/翠名', + 'シュライ/サクラ', + 'ミナヅキ/姫乃', + 'カエデ/優樹菜', + 'ハル/フユ', + 'ドール/瑞江', + 'ニトゥレスト/キリカ', + 'スカー/綾瀬', # 30 + '真夏/小夏', + '光一/ののか', + '彩/翠', + 'トウカ/柊花', + '命/ミコト', + '司/つかさ', + 'ゆとり/なごみ', + '冬彦/観月', + 'カレン/華恋', + '清次郎/亜矢', # 40 + 'サード/夢子', + 'ボックス/詩子', + 'ヘリオス/カエデ', + 'ゲート/京香', + 'オンリー/パトリシア', + 'ザッハーク/アーリ', + 'ラスタバン/ラスティ', + '桜花/燁澄', + '計都/リヴィア', + 'カルヴァリオ/香夜', # 50 + '悠人/夜々子', + '太子/羽菜', + '夕立/夕凪', + 'アルフ/愛美', + 'ファロス/灯利', + 'スプートニク/詩姫', + 'アーネスト/累', + 'ナイン/カグヤ', + 'クリア/ヒマワリ', + 'ウォーカー/オリビア', # 60 + 'ダーク/クオン', + 'ウェイヴ/凛', + 'ルーン/マリエ', + 'エンギ/セイギ', + 'シラヌイ/ミライ', + 'ブライン/キズナ', + 'クロウ/カナタ', + 'スレイヤー/ヒカル', + 'レス/ミリアリア', + 'ミフユ/サリエル', # 70 + '鳴央/音央', + 'モンジ/理亜', + 'パルデモントゥム/スナオ', + 'ミシェル/詩穂', + 'フレンズ/サン', + 'サトリ/識', + 'ロード/唯花', + 'クロノス/久宝', + 'フィラデルフィア/冬海', + 'ティンダロス/美星', # 80 + '勇弥/ユーリス', + 'エイト/アンジェラ', + 'サタン/ルシエル', + 'エース/小波', + 'セージ/胡蝶', + '忍/千之', + '重吾/キリコ', + 'マイケル/ミホシ', + 'カズマ/鶴香', + 'ヤマト/エリシエル', # 90 + '歴史上の人物の名前(信長、ジャンヌなど)', + 'スポーツ選手の名前(ベッカム、沙保里など)', + '学者の名前(ソクラテス、エレナなど)', + 'アイドルの名前(タクヤ、聖子など)', + '土地、国、町の名前(イングランド、ワシントンなど)', + 'モンスターの名前(ドラゴン、ラミアなど)', + '武器防具の名前(ソード、メイルなど)', + '自然現象の名前(カザンハリケーンなど)', + '機械の名前(洗濯機、テレビなど)', + '目についた物の名前(シャーペン、メガネなど)', # 100 + ] + ) end end end diff --git a/test/data/TrinitySeven.toml b/test/data/TrinitySeven.toml index 10d44652e..038d33682 100644 --- a/test/data/TrinitySeven.toml +++ b/test/data/TrinitySeven.toml @@ -436,7 +436,7 @@ rands = [ [[ test ]] game_system = "TrinitySeven" input = "TRNAME" -output = "魔王 , 目についた物の名前(シャーペン、メガネなど)" +output = "\"魔王\" , 目についた物の名前(シャーペン、メガネなど)" rands = [ { sides = 100, value = 100 }, { sides = 100, value = 100 }, @@ -460,6 +460,15 @@ rands = [ { sides = 100, value = 30 }, ] +[[ test ]] +game_system = "TrinitySeven" +input = "TRNAME" +output = "サンクチュアリ , スカー/綾瀬" +rands = [ + { sides = 100, value = 70 }, + { sides = 100, value = 30 }, +] + [[ test ]] game_system = "TrinitySeven" input = "1D100<=50"