Skip to content

Commit

Permalink
[ZettaiReido] Result対応 (#441)
Browse files Browse the repository at this point in the history
* 絶対隷奴のResult対応

* レビュー反映
  • Loading branch information
h-mikisato authored Apr 30, 2021
1 parent 1f6ffd8 commit d5dffa9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
45 changes: 20 additions & 25 deletions lib/bcdice/game_system/ZettaiReido.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'bcdice/base'

module BCDice
module GameSystem
class ZettaiReido < Base
Expand Down Expand Up @@ -38,20 +40,23 @@ def roll2DR(baseAvility, modText, diffValue)
mod, modText = getModInfo(modText)
diff, diffText = getDiffInfo(diffValue)

output = ""
output += "(#{baseAvility}-2DR#{modText}#{diffText})"
output += " > #{baseAvility}-#{diceTotal}[#{diceText}]#{modText}"

baseCommandText = "(#{baseAvility}-2DR#{modText}#{diffText})"
diceCommandText = "#{baseAvility}-#{diceTotal}[#{diceText}]#{modText}"
total = baseAvility - diceTotal + mod
output += " > #{total}"

successText = getSuccessText(diceTotal, total, diff)
output += successText
result = getResult(diceTotal, total, diff)

darkPointText = getDarkPointResult(total, diff, darkPoint)
output += darkPointText
darkPointText = "#{darkPoint}DP" if darkPoint > 0

return output
result.text = [
baseCommandText,
diceCommandText,
total.to_i,
result.text,
darkPointText,
].compact.join(" > ")

return result
end

def roll2DarkDice()
Expand Down Expand Up @@ -107,23 +112,13 @@ def getDiffInfo(diffValue)
return diffValue, diffText
end

def getDarkPointResult(_total, _diff, darkPoint)
text = ''

if darkPoint > 0
text = " > #{darkPoint}DP"
end

return text
end

def getSuccessText(diceTotal, total, diff)
def getResult(diceTotal, total, diff)
if diceTotal == 0
return " > クリティカル"
return Result.critical("クリティカル")
end

if diceTotal == 10
return " > ファンブル"
return Result.fumble("ファンブル")
end

if diff.nil?
Expand All @@ -132,10 +127,10 @@ def getSuccessText(diceTotal, total, diff)

successLevel = (total - diff)
if successLevel >= 0
return " > #{successLevel} 成功"
return Result.success("#{successLevel} 成功")
end

return ' > 失敗'
return Result.failure("失敗")
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions test/data/ZettaiReido.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
game_system = "ZettaiReido"
input = "12-2DR-1>=10"
output = "(12-2DR-1>=10) > 12-0[0,0]-1 > 11 > クリティカル > 4DP"
success = true
critical = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 6 },
Expand All @@ -11,6 +13,8 @@ rands = [
game_system = "ZettaiReido"
input = "10-2DR+1>=99"
output = "(10-2DR+1>=99) > 10-0[0,0]+1 > 11 > クリティカル > 4DP"
success = true
critical = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 6 },
Expand All @@ -20,6 +24,7 @@ rands = [
game_system = "ZettaiReido"
input = "10-2DR+1>=10"
output = "(10-2DR+1>=10) > 10-1[1,0]+1 > 10 > 0 成功 > 1DP"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 6 },
Expand All @@ -29,6 +34,7 @@ rands = [
game_system = "ZettaiReido"
input = "8-2DR>=6"
output = "(8-2DR>=6) > 8-2[1,1] > 6 > 0 成功"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
Expand All @@ -38,6 +44,7 @@ rands = [
game_system = "ZettaiReido"
input = "8-2DR-1>=4"
output = "(8-2DR-1>=4) > 8-2[1,1]-1 > 5 > 1 成功"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
Expand All @@ -47,6 +54,7 @@ rands = [
game_system = "ZettaiReido"
input = "30-2DR-10>=19"
output = "(30-2DR-10>=19) > 30-1[0,1]-10 > 19 > 0 成功 > 1DP"
success = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 1 },
Expand All @@ -56,6 +64,7 @@ rands = [
game_system = "ZettaiReido"
input = "8-2DR>=7"
output = "(8-2DR>=7) > 8-2[1,1] > 6 > 失敗"
failure = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
Expand All @@ -65,6 +74,7 @@ rands = [
game_system = "ZettaiReido"
input = "30-2DR-10>=20"
output = "(30-2DR-10>=20) > 30-1[0,1]-10 > 19 > 失敗 > 1DP"
failure = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 1 },
Expand All @@ -74,6 +84,8 @@ rands = [
game_system = "ZettaiReido"
input = "9-2DR>=7"
output = "(9-2DR>=7) > 9-10[5,5] > -1 > ファンブル"
failure = true
fumble = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
Expand All @@ -83,6 +95,8 @@ rands = [
game_system = "ZettaiReido"
input = "20-2DR>=7"
output = "(20-2DR>=7) > 20-10[5,5] > 10 > ファンブル"
failure = true
fumble = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
Expand All @@ -92,6 +106,7 @@ rands = [
game_system = "ZettaiReido"
input = "6-2DR"
output = "(6-2DR) > 6-5[2,3] > 1 > 1 成功"
success = true
rands = [
{ sides = 6, value = 2 },
{ sides = 6, value = 3 },
Expand All @@ -101,6 +116,7 @@ rands = [
game_system = "ZettaiReido"
input = "6-2DR"
output = "(6-2DR) > 6-6[3,3] > 0 > 0 成功"
success = true
rands = [
{ sides = 6, value = 3 },
{ sides = 6, value = 3 },
Expand All @@ -110,6 +126,8 @@ rands = [
game_system = "ZettaiReido"
input = "6-2DR"
output = "(6-2DR) > 6-0[0,0] > 6 > クリティカル > 4DP"
success = true
critical = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 6 },
Expand All @@ -119,6 +137,7 @@ rands = [
game_system = "ZettaiReido"
input = "6-2DR"
output = "(6-2DR) > 6-7[4,3] > -1 > 失敗"
failure = true
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 3 },
Expand All @@ -128,6 +147,8 @@ rands = [
game_system = "ZettaiReido"
input = "6-2DR"
output = "(6-2DR) > 6-10[5,5] > -4 > ファンブル"
failure = true
fumble = true
rands = [
{ sides = 6, value = 5 },
{ sides = 6, value = 5 },
Expand Down

0 comments on commit d5dffa9

Please sign in to comment.