Skip to content

Commit

Permalink
Merge pull request #167 from bcdice/fix_ars_magica
Browse files Browse the repository at this point in the history
ArsMagicaで成功失敗判定ができない問題を修正
  • Loading branch information
ysakasin authored Apr 29, 2020
2 parents 47461ac + 32514f3 commit a161b6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 194 deletions.
44 changes: 11 additions & 33 deletions src/diceBot/ArsMagica.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# frozen_string_literal: true

require "utils/normalize"

class ArsMagica < DiceBot
# ゲームシステムの識別子
ID = 'ArsMagica'
Expand Down Expand Up @@ -44,47 +46,21 @@ def dice_command_xRn(string, nick_e)
arsmagica_stress(string, nick_e)
end

def check_nD10(total_n, _dice_n, signOfInequality, diff, _dice_cnt, _dice_max, _n1, _n_max) # ゲーム別成功度判定(nD10)
if signOfInequality != ">="
return ""
end

if total_n >= diff
return " > 成功"
end

return " > 失敗"
end

def check_1D10(total_n, _dice_n, signOfInequality, diff, _dice_cnt, _dice_max, _n1, _n_max) # ゲーム別成功度判定(1D10)
if signOfInequality != ">="
return ""
end

if total_n >= diff
return " > 成功"
end

return " > 失敗"
end

def arsmagica_stress(string, _nick_e)
output = "1"

return "1" unless (m = /(^|\s)S?(1[rR]10([\+\-\d]*)(\[(\d+)\])?(([>=]+)(\d+))?)(\s|$)/i.match(string))

diff = 0
botch = 1
bonus = 0
crit_mul = 1
total = 0
signOfInequality = ""
cmp_op = nil
bonusText = m[3]
botch = m[5].to_i if m[4]

if m[6]
signOfInequality = marshalSignOfInequality(m[7])
diff = m[8]
cmp_op = Normalize.comparison_operator(m[7])
diff = m[8].to_i
end

bonus = parren_killer("(0#{bonusText})").to_i unless bonusText.empty?
Expand Down Expand Up @@ -115,7 +91,8 @@ def arsmagica_stress(string, _nick_e)
output += " > Botch!"
end

signOfInequality = ""
# Botchの時には目標値を使った判定はしない
cmp_op = nil
else
if bonus > 0
output += "+#{bonus}#{bonus}"
Expand Down Expand Up @@ -150,13 +127,14 @@ def arsmagica_stress(string, _nick_e)
if bonus > 0
output += "#{die}+#{bonus}#{total}"
elsif bonus < 0
output += "#{die $bonus}#{total}"
output += "#{die}#{bonus}#{total}"
else
output += total.to_s
end
end
if signOfInequality != "" # 成功度判定処理
output += check_result(total, 0, signOfInequality, diff, 1, 10, 0, 0)

if cmp_op == :>=
output += (total >= diff ? " > 成功" : " > 失敗")
end

return ": #{output}"
Expand Down
178 changes: 17 additions & 161 deletions src/test/data/ArsMagica.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ rand:8/10
input:
Ars1
output:
ArsMagica : (1R10[1]) > 9
rand:10/10
============================
input:
Ars1
output:
ArsMagica : (1R10[1]) > 5
rand:6/10
============================
Expand All @@ -55,22 +49,10 @@ rand:4/10
input:
Ars1
output:
ArsMagica : (1R10[1]) > 3
rand:4/10
============================
input:
Ars1
output:
ArsMagica : (1R10[1]) > 0[0,7] > 0
rand:1/10,8/10
============================
input:
Ars1
output:
ArsMagica : (1R10[1]) > 7
rand:8/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 4
Expand All @@ -85,12 +67,6 @@ rand:4/10
input:
Ars3
output:
ArsMagica : (1R10[3]) > 7
rand:8/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 9
rand:10/10
============================
Expand All @@ -103,30 +79,6 @@ rand:8/10
input:
Ars3
output:
ArsMagica : (1R10[3]) > 9
rand:10/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 7
rand:8/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 7
rand:8/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 4
rand:5/10
============================
input:
Ars3
output:
ArsMagica : (1R10[3]) > 6
rand:7/10
============================
Expand All @@ -145,24 +97,12 @@ rand:9/10
input:
Ars5
output:
ArsMagica : (1R10[5]) > 4
rand:5/10
============================
input:
Ars5
output:
ArsMagica : (1R10[5]) > 6
rand:7/10
============================
input:
Ars5
output:
ArsMagica : (1R10[5]) > 3
rand:4/10
============================
input:
Ars5
output:
ArsMagica : (1R10[5]) > 7
rand:8/10
============================
Expand All @@ -181,12 +121,6 @@ rand:5/10
input:
Ars5
output:
ArsMagica : (1R10[5]) > 4
rand:5/10
============================
input:
Ars5
output:
ArsMagica : (1R10[5]) > 5
rand:6/10
============================
Expand Down Expand Up @@ -217,30 +151,12 @@ rand:1/10,10/10,6/10,10/10,6/10,8/10,2/10,6/10
input:
Ars7
output:
ArsMagica : (1R10[7]) > 9
rand:10/10
============================
input:
Ars7
output:
ArsMagica : (1R10[7]) > 4
rand:5/10
============================
input:
Ars7
output:
ArsMagica : (1R10[7]) > 10[1,5]
rand:2/10,5/10
============================
input:
Ars7
output:
ArsMagica : (1R10[7]) > 3
rand:4/10
============================
input:
Ars7
output:
ArsMagica : (1R10[7]) > 5
rand:6/10
============================
Expand All @@ -253,64 +169,16 @@ rand:8/10
input:
Ars9
output:
ArsMagica : (1R10[9]) > 3
rand:4/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 9
rand:10/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 8
rand:9/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 2
rand:3/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 4
rand:5/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 20[1,1,5]
rand:2/10,1/10,5/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 4
rand:5/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 8[1,4]
rand:2/10,4/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 7
rand:8/10
============================
input:
Ars9
output:
ArsMagica : (1R10[9]) > 5
rand:6/10
============================
input:
Ars10
output:
ArsMagica : (1R10[10]) > 14[1,7]
Expand All @@ -319,53 +187,41 @@ rand:2/10,7/10
input:
Ars10
output:
ArsMagica : (1R10[10]) > 6
rand:7/10
============================
input:
Ars10
output:
ArsMagica : (1R10[10]) > 5
rand:6/10
ArsMagica : (1R10[10]) > 0[0,2,4,7,9,4,5,5,7,4,2] > 0
rand:1/10,3/10,5/10,8/10,10/10,5/10,6/10,6/10,8/10,5/10,3/10
============================
input:
Ars10
Ars-3
output:
ArsMagica : (1R10[10]) > 7
rand:8/10
ArsMagica : (1R10-3) > 8-3 > 5
rand:9/10
============================
input:
Ars10
Ars+3
output:
ArsMagica : (1R10[10]) > 5
rand:6/10
ArsMagica : (1R10+3) > 8+3 > 11
rand:9/10
============================
input:
Ars10
Ars10>=7
output:
ArsMagica : (1R10[10]) > 2
ArsMagica : (1R10[10]>=7) > 2 > 失敗
rand:3/10
============================
input:
Ars10
Ars10>=7
output:
ArsMagica : (1R10[10]) > 9
ArsMagica : (1R10[10]>=7) > 9 > 成功
rand:10/10
============================
input:
Ars10
Ars10>=7
output:
ArsMagica : (1R10[10]) > 7
ArsMagica : (1R10[10]>=7) > 7 > 成功
rand:8/10
============================
input:
Ars10
Ars2>=7 Botchの時には目標値を使った判定はされない
output:
ArsMagica : (1R10[10]) > 0[0,2,4,7,9,4,5,5,7,4,2] > 0
rand:1/10,3/10,5/10,8/10,10/10,5/10,6/10,6/10,8/10,5/10,3/10
============================
input:
Ars10
output:
ArsMagica : (1R10[10]) > 8
rand:9/10
ArsMagica : (1R10[2]>=7) > 0[0,0,0] > 2Botch!
rand:1/10,1/10,1/10

0 comments on commit a161b6d

Please sign in to comment.