Skip to content

Commit

Permalink
[剣の街の異邦人]Issue 423 Result対応 (#541)
Browse files Browse the repository at this point in the history
* Issue#423 Result対応 (StrangerOfSwordCity)

* テストを追加、コード修正
  • Loading branch information
saronpasu authored Apr 13, 2022
1 parent 5940f6e commit f088201
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/bcdice/game_system/StrangerOfSwordCity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +47,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
Expand All @@ -57,21 +60,31 @@ 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)"
result.critical = true
result.success = true
result.text += " > クリティカル(+#{criticalResult}D6)"
return result
end

if isFumble(diceList, diceCount)
result += ' > ファンブル'
result.fumble = true
result.failure = true
result.text += ' > ファンブル'
return result
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
Expand Down
34 changes: 34 additions & 0 deletions test/data/StrangerOfSwordCity.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
game_system = "StrangerOfSwordCity"
input = "1SR>=3"
output = "(1SR>=3) > 2[2] > 2 > 失敗"
failure = true
rands = [
{ sides = 6, value = 2 },
]
Expand All @@ -10,6 +11,7 @@ rands = [
game_system = "StrangerOfSwordCity"
input = "1SR>=3"
output = "(1SR>=3) > 5[5] > 5 > 成功"
success = true
rands = [
{ sides = 6, value = 5 },
]
Expand All @@ -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 },
]
Expand All @@ -26,6 +30,7 @@ rands = [
game_system = "StrangerOfSwordCity"
input = "1SR>=3"
output = "(1SR>=3) > 6[6] > 6 > 成功"
success = true
rands = [
{ sides = 6, value = 6 },
]
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand Down

0 comments on commit f088201

Please sign in to comment.