Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コード:レイヤードのバグ修正と機能追加 #270

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/diceBot/CodeLayerd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ class CodeLayerd < DiceBot

@m,[c],+xは省略可能。(@6[1]として処理)
n個のD10でmを判定値、cをクリティカル値とした行為判定を行う。
nが0以下のときはクリティカルしない1CL判定を行う。(1CL[0]と同一)
例)
7CL>=5 :サイコロ7個で判定値6のロールを行い、目標値5に対して判定
4CL@7 :サイコロ4個で判定値7のロールを行い達成値を出す
4CL+2@7 または 4CL@7+2 :サイコロ4個で判定値7のロールを行い達成値を出し、修正値2を足す。
4CL[2] :サイコロ4個でクリティカル値2のロールを行う。
0CL : 1CL[0]と同じ判定
MESSAGETEXT

setPrefixes(['\d*CL([+-]\d+)?[@\d]*.*'])
setPrefixes(['[+-]?\d*CL([+-]\d+)?[@\d]*.*'])

def isGetOriginalMessage
true
Expand All @@ -40,7 +42,7 @@ def rollDiceCommand(command)
result = ''

case command
when /(\d+)?CL([+-]\d+)?(\@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
when /([+-]?\d+)?CL([+-]\d+)?(\@(\d))?(\[(\d+)\])?([+-]\d+)?(>=(\d+))?/i
m = Regexp.last_match
base = (m[1] || 1).to_i
modifier1 = m[2].to_i
Expand All @@ -62,8 +64,10 @@ def checkRoll(base, target, criticalTarget, diff, modifier)
base = getValue(base)
target = getValue(target)
criticalTarget = getValue(criticalTarget)

return result if base < 1
if base <= 0
criticalTarget = 0
base = 1
end

target = 10 if target > 10

Expand All @@ -85,9 +89,16 @@ def getRollResultString(diceList, target, criticalTarget, diff, modifier)
successTotal = successCount + criticalCount + modifier
result = ""

result += "判定値[#{target}] "
result += "判定値[#{target}] " unless target == 6
result += "クリティカル値[#{criticalTarget}] " unless criticalTarget == 1
result += "達成値[#{successCount}]"

# 出目がすべて判定値より大きければ固定値に関わらずファンブル
if successCount <= 0
result += " > ファンブル!"
return result
end

result += "+クリティカル[#{criticalCount}]" if criticalCount > 0
result += format_modifier(modifier)
result += "=[#{successTotal}]" if criticalCount > 0 || modifier != 0
Expand All @@ -99,7 +110,6 @@ def getRollResultString(diceList, target, criticalTarget, diff, modifier)
end

def getSuccessResultText(successTotal, diff)
return "ファンブル!" if successTotal <= 0
return successTotal.to_s if diff == 0
return "成功" if successTotal >= diff

Expand Down
52 changes: 35 additions & 17 deletions src/test/data/CodeLayerd.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
input:
7CL>=6 CodeLayerd
output:
CodeLayerd : 7CL>=6 > (7d10) > [2,2,3,4,5,6,7] > 判定値[6] 達成値[6] > 成功
CodeLayerd : 7CL>=6 > (7d10) > [2,2,3,4,5,6,7] > 達成値[6] > 成功
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
7CL CodeLayerd
output:
CodeLayerd : 7CL > (7d10) > [2,2,3,4,5,6,7] > 判定値[6] 達成値[6] > 6
CodeLayerd : 7CL > (7d10) > [2,2,3,4,5,6,7] > 達成値[6] > 6
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
Expand All @@ -19,37 +19,37 @@ rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
input:
(3+4)CL>=(3+3) CodeLayerd
output:
CodeLayerd : 7CL>=6 > (7d10) > [2,2,3,4,5,6,7] > 判定値[6] 達成値[6] > 成功
CodeLayerd : 7CL>=6 > (7d10) > [2,2,3,4,5,6,7] > 達成値[6] > 成功
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
4CL>=5 クリティカル CodeLayerd
output:
CodeLayerd : 4CL>=5 > (4d10) > [1,2,3,4] > 判定値[6] 達成値[4]+クリティカル[1]=[5] > 成功
CodeLayerd : 4CL>=5 > (4d10) > [1,2,3,4] > 達成値[4]+クリティカル[1]=[5] > 成功
rand:1/10,2/10,3/10,4/10
============================
input:
4CL>=5 ファンブル CodeLayerd
output:
CodeLayerd : 4CL>=5 > (4d10) > [7,8,9,10] > 判定値[6] 達成値[0] > ファンブル!
CodeLayerd : 4CL>=5 > (4d10) > [7,8,9,10] > 達成値[0] > ファンブル!
rand:7/10,8/10,9/10,10/10
============================
input:
4CL>=5 CodeLayerd
output:
CodeLayerd : 4CL>=5 > (4d10) > [7,8,9,10] > 判定値[6] 達成値[0] > ファンブル!
CodeLayerd : 4CL>=5 > (4d10) > [7,8,9,10] > 達成値[0] > ファンブル!
rand:7/10,8/10,9/10,10/10
============================
input:
7CL+5>=6 CodeLayerd
output:
CodeLayerd : 7CL+5>=6 > (7d10+5) > [2,2,3,4,5,6,7]+5 > 判定値[6] 達成値[6]+5=[11] > 成功
CodeLayerd : 7CL+5>=6 > (7d10+5) > [2,2,3,4,5,6,7]+5 > 達成値[6]+5=[11] > 成功
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
7CL-2 CodeLayerd
output:
CodeLayerd : 7CL-2 > (7d10-2) > [2,2,3,4,5,6,7]-2 > 判定値[6] 達成値[6]-2=[4] > 4
CodeLayerd : 7CL-2 > (7d10-2) > [2,2,3,4,5,6,7]-2 > 達成値[6]-2=[4] > 4
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
Expand All @@ -73,35 +73,53 @@ rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
input:
4CL+5>=5 クリティカル CodeLayerd
output:
CodeLayerd : 4CL+5>=5 > (4d10+5) > [1,2,3,4]+5 > 判定値[6] 達成値[4]+クリティカル[1]+5=[10] > 成功
CodeLayerd : 4CL+5>=5 > (4d10+5) > [1,2,3,4]+5 > 達成値[4]+クリティカル[1]+5=[10] > 成功
rand:1/10,2/10,3/10,4/10
============================
input:
4CL-5@6+5>=5 CodeLayerd
4CL-5@6+5>=5 CodeLayerd ファンブル
output:
CodeLayerd : 4CL-5@6+5>=5 > (4d10) > [7,8,9,10] > 判定値[6] 達成値[0] > ファンブル!
CodeLayerd : 4CL-5@6+5>=5 > (4d10) > [7,8,9,10] > 達成値[0] > ファンブル!
rand:7/10,8/10,9/10,10/10
============================
input:
7CL+2@6-8 CodeLayerd
7CL+2@6-8 CodeLayerd 達成値が0でもファンブルではない
output:
CodeLayerd : 7CL+2@6-8 > (7d10-6) > [2,2,3,4,5,6,7]-6 > 判定値[6] 達成値[6]-6=[0] > ファンブル!
CodeLayerd : 7CL+2@6-8 > (7d10-6) > [2,2,3,4,5,6,7]-6 > 達成値[6]-6=[0] > 0
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
7CL-(6+1) CodeLayerd
7CL-(6+1) CodeLayerd 達成値がマイナスでもファンブルではない
output:
CodeLayerd : 7CL-7 > (7d10-7) > [2,2,3,4,5,6,7]-7 > 判定値[6] 達成値[6]-7=[-1] > ファンブル!
CodeLayerd : 7CL-7 > (7d10-7) > [2,2,3,4,5,6,7]-7 > 達成値[6]-7=[-1] > -1
rand:2/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
4CL+10 CodeLayerd 固定値があっても成功ダイスが無いならファンブル
output:
CodeLayerd : 4CL+10 > (4d10+10) > [7,8,9,10]+10 > 達成値[0] > ファンブル!
rand:7/10,8/10,9/10,10/10
============================
input:
4CL[3]>=5 クリティカル CodeLayerd
output:
CodeLayerd : 4CL[3]>=5 > (4d10) > [1,2,3,4] > 判定値[6] クリティカル値[3] 達成値[4]+クリティカル[3]=[7] > 成功
CodeLayerd : 4CL[3]>=5 > (4d10) > [1,2,3,4] > クリティカル値[3] 達成値[4]+クリティカル[3]=[7] > 成功
rand:1/10,2/10,3/10,4/10
============================
input:
7CL+2@6[2]-8 CodeLayerd
output:
CodeLayerd : 7CL+2@6[2]-8 > (7d10-6) > [1,2,3,4,5,6,7]-6 > 判定値[6] クリティカル値[2] 達成値[6]+クリティカル[2]-6=[2] > 2
CodeLayerd : 7CL+2@6[2]-8 > (7d10-6) > [1,2,3,4,5,6,7]-6 > クリティカル値[2] 達成値[6]+クリティカル[2]-6=[2] > 2
rand:1/10,2/10,3/10,4/10,5/10,6/10,7/10
============================
input:
0CL ダイス数が0以下になると1CL[0]相当
output:
CodeLayerd : 0CL > (1d10) > [1] > クリティカル値[0] 達成値[1] > 1
rand:1/10
============================
input:
(10-15)CL+5 ダイス数が0以下になると1CL[0]相当
output:
CodeLayerd : -5CL+5 > (1d10+5) > [8]+5 > クリティカル値[0] 達成値[0] > ファンブル!
rand:8/10