Skip to content

Commit

Permalink
[Warhammer] result_1d100を使う
Browse files Browse the repository at this point in the history
  • Loading branch information
ysakasin committed Apr 17, 2021
1 parent bd97422 commit 9ad4f44
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/bcdice/game_system/Warhammer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@ def eval_game_system_specific_command(command)
return output_msg
end

def check_1D100(total, _dice_total, cmp_op, target)
return '' if target == '?'
return '' unless cmp_op == :<=
def result_1d100(total, _dice_total, cmp_op, target)
return Result.nothing if target == '?'
return nil unless cmp_op == :<=

if total <= target
" > 成功(成功度#{(target - total) / 10})"
Result.success("成功(成功度#{(target - total) / 10})")
else
" > 失敗(失敗度#{(total - target) / 10})"
Result.failure("失敗(失敗度#{(total - target) / 10})")
end
end

def result_1d100_text(total, dice_total, cmp_op, target)
result = result_1d100(total, dice_total, cmp_op, target)&.text
if result.nil?
""
else
" > #{result}"
end
end

Expand Down Expand Up @@ -322,7 +331,7 @@ def getAttackResult(string)
total_n = @randomizer.roll_once(100)

output = "(#{string}) > #{total_n}"
output += check_1D100(total_n, total_n, :<=, diff)
output += result_1d100_text(total_n, total_n, :<=, diff)

pos_num = (total_n % 10) * 10 + (total_n / 10).to_i
pos_num = 100 if total_n >= 100
Expand Down
30 changes: 30 additions & 0 deletions test/data/Warhammer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 74 > 失敗(失敗度6)"
failure = true
rands = [
{ sides = 100, value = 74 },
]
Expand All @@ -10,6 +11,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 59 > 失敗(失敗度4)"
failure = true
rands = [
{ sides = 100, value = 59 },
]
Expand All @@ -18,6 +20,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 22 > 失敗(失敗度1)"
failure = true
rands = [
{ sides = 100, value = 22 },
]
Expand All @@ -26,6 +29,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 13 > 失敗(失敗度0)"
failure = true
rands = [
{ sides = 100, value = 13 },
]
Expand All @@ -34,6 +38,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 56 > 失敗(失敗度4)"
failure = true
rands = [
{ sides = 100, value = 56 },
]
Expand All @@ -42,6 +47,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 68 > 失敗(失敗度5)"
failure = true
rands = [
{ sides = 100, value = 68 },
]
Expand All @@ -50,6 +56,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 89 > 失敗(失敗度7)"
failure = true
rands = [
{ sides = 100, value = 89 },
]
Expand All @@ -58,6 +65,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 67 > 失敗(失敗度5)"
failure = true
rands = [
{ sides = 100, value = 67 },
]
Expand All @@ -66,6 +74,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 36 > 失敗(失敗度2)"
failure = true
rands = [
{ sides = 100, value = 36 },
]
Expand All @@ -74,6 +83,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=10"
output = "(1D100<=10) > 76 > 失敗(失敗度6)"
failure = true
rands = [
{ sides = 100, value = 76 },
]
Expand All @@ -82,6 +92,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 97 > 失敗(失敗度0)"
failure = true
rands = [
{ sides = 100, value = 97 },
]
Expand All @@ -90,6 +101,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 31 > 成功(成功度5)"
success = true
rands = [
{ sides = 100, value = 31 },
]
Expand All @@ -98,6 +110,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 28 > 成功(成功度6)"
success = true
rands = [
{ sides = 100, value = 28 },
]
Expand All @@ -106,6 +119,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 99 > 失敗(失敗度0)"
failure = true
rands = [
{ sides = 100, value = 99 },
]
Expand All @@ -114,6 +128,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 66 > 成功(成功度2)"
success = true
rands = [
{ sides = 100, value = 66 },
]
Expand All @@ -122,6 +137,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 98 > 失敗(失敗度0)"
failure = true
rands = [
{ sides = 100, value = 98 },
]
Expand All @@ -130,6 +146,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 47 > 成功(成功度4)"
success = true
rands = [
{ sides = 100, value = 47 },
]
Expand All @@ -138,6 +155,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 67 > 成功(成功度2)"
success = true
rands = [
{ sides = 100, value = 67 },
]
Expand All @@ -146,6 +164,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 40 > 成功(成功度5)"
success = true
rands = [
{ sides = 100, value = 40 },
]
Expand All @@ -154,6 +173,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=90"
output = "(1D100<=90) > 77 > 成功(成功度1)"
success = true
rands = [
{ sides = 100, value = 77 },
]
Expand All @@ -162,6 +182,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 83 > 失敗(失敗度3)"
failure = true
rands = [
{ sides = 100, value = 83 },
]
Expand All @@ -170,6 +191,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 4 > 成功(成功度4)"
success = true
rands = [
{ sides = 100, value = 4 },
]
Expand All @@ -178,6 +200,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 17 > 成功(成功度3)"
success = true
rands = [
{ sides = 100, value = 17 },
]
Expand All @@ -186,6 +209,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 27 > 成功(成功度2)"
success = true
rands = [
{ sides = 100, value = 27 },
]
Expand All @@ -194,6 +218,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 65 > 失敗(失敗度1)"
failure = true
rands = [
{ sides = 100, value = 65 },
]
Expand All @@ -202,6 +227,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 50 > 成功(成功度0)"
success = true
rands = [
{ sides = 100, value = 50 },
]
Expand All @@ -210,6 +236,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 37 > 成功(成功度1)"
success = true
rands = [
{ sides = 100, value = 37 },
]
Expand All @@ -218,6 +245,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 85 > 失敗(失敗度3)"
failure = true
rands = [
{ sides = 100, value = 85 },
]
Expand All @@ -226,6 +254,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 39 > 成功(成功度1)"
success = true
rands = [
{ sides = 100, value = 39 },
]
Expand All @@ -234,6 +263,7 @@ rands = [
game_system = "Warhammer"
input = "1D100<=50"
output = "(1D100<=50) > 43 > 成功(成功度0)"
success = true
rands = [
{ sides = 100, value = 43 },
]
Expand Down

0 comments on commit 9ad4f44

Please sign in to comment.