From e588849ac73272032d2ee4092ae229966105b8b7 Mon Sep 17 00:00:00 2001 From: saronpasu Date: Thu, 7 Apr 2022 21:11:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Issue#423=20Result=E5=AF=BE=E5=BF=9C=20(Str?= =?UTF-8?q?angerOfSwordCity)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/StrangerOfSwordCity.rb | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/bcdice/game_system/StrangerOfSwordCity.rb b/lib/bcdice/game_system/StrangerOfSwordCity.rb index 32c6f2239..b70b56b11 100644 --- a/lib/bcdice/game_system/StrangerOfSwordCity.rb +++ b/lib/bcdice/game_system/StrangerOfSwordCity.rb @@ -45,7 +45,8 @@ def eval_game_system_specific_command(command) def checkRoll(command) debug("checkRoll begin command", command) - result = '' + result = Result.new + result.text = '' return result unless command =~ /^(\d+)SR([+\-]?\d+)?(>=(\d+))?$/i diceCount = Regexp.last_match(1).to_i @@ -57,24 +58,34 @@ def checkRoll(command) totalValue = (dice + modify) modifyText = getModifyText(modify) - result += "(#{command}) > #{dice}[#{diceList.join(',')}]#{modifyText} > #{totalValue}" + result.text += "(#{command}) > #{dice}[#{diceList.join(',')}]#{modifyText} > #{totalValue}" criticalResult = getCriticalResult(diceList) unless criticalResult.nil? - result += " > クリティカル(+#{criticalResult}D6)" - return result + result.critical = true + result.success = true + result.text += " > クリティカル(+#{criticalResult}D6)" + return result.text end if isFumble(diceList, diceCount) - result += ' > ファンブル' - return result + result.fumble = true + result.failure = true + result.text += ' > ファンブル' + return result.text end unless difficulty.nil? - result += totalValue >= difficulty ? ' > 成功' : ' > 失敗' + if totalValue >= difficulty + result.success = true + result.text += ' > 成功' + else + result.failure = true + result.text += ' > 失敗' + end end - return result + return result.text end def getModifyText(modify) From 6a60eccc7a7e8a7cf2737fef04db9a429ba5ed82 Mon Sep 17 00:00:00 2001 From: saronpasu Date: Thu, 7 Apr 2022 23:19:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=80=81=E3=82=B3=E3=83=BC=E3=83=89=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bcdice/game_system/StrangerOfSwordCity.rb | 8 +++-- test/data/StrangerOfSwordCity.toml | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/bcdice/game_system/StrangerOfSwordCity.rb b/lib/bcdice/game_system/StrangerOfSwordCity.rb index b70b56b11..454cbe81f 100644 --- a/lib/bcdice/game_system/StrangerOfSwordCity.rb +++ b/lib/bcdice/game_system/StrangerOfSwordCity.rb @@ -37,6 +37,8 @@ def eval_game_system_specific_command(command) command = command.upcase result = checkRoll(command) + + return result if result.instance_of?(Result) return result unless result.empty? return result @@ -65,14 +67,14 @@ def checkRoll(command) result.critical = true result.success = true result.text += " > クリティカル(+#{criticalResult}D6)" - return result.text + return result end if isFumble(diceList, diceCount) result.fumble = true result.failure = true result.text += ' > ファンブル' - return result.text + return result end unless difficulty.nil? @@ -85,7 +87,7 @@ def checkRoll(command) end end - return result.text + return result end def getModifyText(modify) diff --git a/test/data/StrangerOfSwordCity.toml b/test/data/StrangerOfSwordCity.toml index 16a34981a..36de15973 100644 --- a/test/data/StrangerOfSwordCity.toml +++ b/test/data/StrangerOfSwordCity.toml @@ -2,6 +2,7 @@ game_system = "StrangerOfSwordCity" input = "1SR>=3" output = "(1SR>=3) > 2[2] > 2 > 失敗" +failure = true rands = [ { sides = 6, value = 2 }, ] @@ -10,6 +11,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "1SR>=3" output = "(1SR>=3) > 5[5] > 5 > 成功" +success = true rands = [ { sides = 6, value = 5 }, ] @@ -18,6 +20,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "1SR>=3" output = "(1SR>=3) > 1[1] > 1 > ファンブル" +fumble = true +failure = true rands = [ { sides = 6, value = 1 }, ] @@ -26,6 +30,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "1SR>=3" output = "(1SR>=3) > 6[6] > 6 > 成功" +success = true rands = [ { sides = 6, value = 6 }, ] @@ -34,6 +39,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR>=7" output = "(2SR>=7) > 5[2,3] > 5 > 失敗" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 3 }, @@ -43,6 +49,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR>=7" output = "(2SR>=7) > 7[3,4] > 7 > 成功" +success = true rands = [ { sides = 6, value = 3 }, { sides = 6, value = 4 }, @@ -52,6 +59,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR>=7" output = "(2SR>=7) > 2[1,1] > 2 > ファンブル" +fumble = true +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 1 }, @@ -61,6 +70,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR>=7" output = "(2SR>=7) > 12[6,6] > 12 > クリティカル(+2D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -70,6 +81,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR>=10" output = "(3SR>=10) > 4[1,1,2] > 4 > 失敗" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 1 }, @@ -80,6 +92,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR>=10" output = "(3SR>=10) > 12[3,3,6] > 12 > 成功" +success = true rands = [ { sides = 6, value = 3 }, { sides = 6, value = 3 }, @@ -90,6 +103,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR>=10" output = "(3SR>=10) > 3[1,1,1] > 3 > ファンブル" +fumble = true +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 1 }, @@ -100,6 +115,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR>=10" output = "(3SR>=10) > 15[3,6,6] > 15 > クリティカル(+2D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 3 }, @@ -110,6 +127,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR>=10" output = "(3SR>=10) > 18[6,6,6] > 18 > クリティカル(+3D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -120,6 +139,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "10SR>=35" output = "(10SR>=35) > 44[2,2,3,5,5,5,5,5,6,6] > 44 > クリティカル(+2D6)" +critical = true +success = true rands = [ { sides = 6, value = 5 }, { sides = 6, value = 5 }, @@ -137,6 +158,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "10SR>=35" output = "(10SR>=35) > 46[2,2,3,5,5,5,6,6,6,6] > 46 > クリティカル(+4D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -154,6 +177,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "10SR>=35" output = "(10SR>=35) > 10[1,1,1,1,1,1,1,1,1,1] > 10 > ファンブル" +fumble = true +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 1 }, @@ -171,6 +196,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "10SR>=35" output = "(10SR>=35) > 11[1,1,1,1,1,1,1,1,1,2] > 11 > 失敗" +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 2 }, @@ -188,6 +214,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR" output = "(2SR) > 12[6,6] > 12 > クリティカル(+2D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -197,6 +225,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR" output = "(2SR) > 2[1,1] > 2 > ファンブル" +fumble = true +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 1 }, @@ -225,6 +255,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "3SR3>=9" output = "(3SR3>=9) > 9[2,3,4]+3 > 12 > 成功" +success = true rands = [ { sides = 6, value = 3 }, { sides = 6, value = 4 }, @@ -235,6 +266,7 @@ rands = [ game_system = "StrangerOfSwordCity" input = "2SR-2>=10" output = "(2SR-2>=10) > 8[4,4]-2 > 6 > 失敗" +failure = true rands = [ { sides = 6, value = 4 }, { sides = 6, value = 4 }, @@ -244,6 +276,8 @@ rands = [ game_system = "StrangerOfSwordCity" input = "4SR-3" output = "(4SR-3) > 18[2,4,6,6]-3 > 15 > クリティカル(+2D6)" +critical = true +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 4 },