Skip to content

Commit

Permalink
[AngelGear]Result対応 (#474)
Browse files Browse the repository at this point in the history
* リザルトを使用

* Refactor

Co-authored-by: SAKATA Sinji <[email protected]>
  • Loading branch information
sakura40 and ysakasin authored Jun 15, 2021
1 parent a3e2827 commit 4299b0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/bcdice/game_system/AngelGear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,22 @@ def resolute_action(num_dice, skill_value, modify, command)
dice_text = dice.join(",")
modify_n = 0
success = 0

if skill_value
success = dice.count { |val| val <= skill_value }
modify_n = Arithmetic.eval(modify, RoundType::FLOOR) unless modify.empty?
end

output = "(#{command}) > #{success}[#{dice_text}]#{format('%+d', modify_n)} > 成功数: #{success + modify_n}"
gospel = '(福音発生)' if success + modify_n >= 100

output = "(#{command}) > #{success}[#{dice_text}]#{format('%+d', modify_n)} > 成功数: #{success + modify_n}#{gospel}"

if success + modify_n >= 100
output += "(福音発生)"
Result.critical(output)
elsif 0 < success + modify_n
Result.success(output)
else
Result.failure(output)
end
return output
end

TABLES = {
Expand Down
11 changes: 11 additions & 0 deletions test/data/AngelGear.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
game_system = "AngelGear"
input = "10AG"
output = "(10AG) > 0[1,1,1,4,4,4,6,6,6,6]+0 > 成功数: 0"
failure = true
rands = [
{ sides = 6, value = 6 },
{ sides = 6, value = 1 },
Expand All @@ -19,6 +20,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3"
output = "(10AG3) > 6[1,1,1,2,3,3,4,4,5,6]+0 > 成功数: 6"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand All @@ -36,6 +38,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3"
output = "(10AG3) > 0[4,4,4,4,5,5,6,6,6,6]+0 > 成功数: 0"
failure = true
rands = [
{ sides = 6, value = 4 },
{ sides = 6, value = 6 },
Expand All @@ -53,6 +56,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3"
output = "(10AG3) > 10[1,1,1,1,1,2,2,2,2,3]+0 > 成功数: 10"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 1 },
Expand All @@ -70,6 +74,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3+5"
output = "(10AG3+5) > 4[1,2,2,3,4,4,5,6,6,6]+5 > 成功数: 9"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand All @@ -87,6 +92,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3+2+3"
output = "(10AG3+2+3) > 4[1,2,2,3,4,4,5,6,6,6]+5 > 成功数: 9"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand All @@ -104,6 +110,7 @@ rands = [
game_system = "AngelGear"
input = "10AG3+95 福音発生でない"
output = "(10AG3+95) > 4[1,2,2,3,4,4,5,6,6,6]+95 > 成功数: 99"
success = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand All @@ -121,6 +128,8 @@ rands = [
game_system = "AngelGear"
input = "10AG3+96 福音発生"
output = "(10AG3+96) > 4[1,2,2,3,4,4,5,6,6,6]+96 > 成功数: 100(福音発生)"
success = true
critical = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand All @@ -139,6 +148,8 @@ rands = [
game_system = "AngelGear"
input = "10AG3+100"
output = "(10AG3+100) > 4[1,2,2,3,4,4,5,6,6,6]+100 > 成功数: 104(福音発生)"
success = true
critical = true
rands = [
{ sides = 6, value = 1 },
{ sides = 6, value = 2 },
Expand Down

0 comments on commit 4299b0f

Please sign in to comment.