Skip to content

Commit

Permalink
Merge pull request #126 from bcdice/NinjaSlayer-fix_secret_roll
Browse files Browse the repository at this point in the history
NinjaSlayer: NJコマンドでシークレットロールできないのを修正する
  • Loading branch information
ysakasin authored Feb 23, 2020
2 parents a287f23 + b50ebc6 commit 62ac44a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/diceBot/NinjaSlayer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def getHelpMessage
DIFFICULTY_RE = /\[(#{DIFFICULTY_VALUE_RE})\]|@(#{DIFFICULTY_VALUE_RE})/io.freeze

# 通常判定の正規表現
NJ_RE = /\ANJ(\d+)#{DIFFICULTY_RE}?\z/io.freeze
NJ_RE = /\A(S)?NJ(\d+)#{DIFFICULTY_RE}?\z/io.freeze
# 回避判定の正規表現
EV_RE = %r{\AEV(\d+)#{DIFFICULTY_RE}?(?:/(\d+))?\z}io.freeze
# 近接攻撃の正規表現
Expand Down Expand Up @@ -82,7 +82,8 @@ def changeText(str)
m = NJ_RE.match(str)
return str unless m

return bRollCommand(m[1], integerValueOfDifficulty(m[2] || m[3]))
b_roll = bRollCommand(m[2], integerValueOfDifficulty(m[3] || m[4]))
return "#{m[1]}#{b_roll}"
end

def rollDiceCommand(command)
Expand Down
6 changes: 6 additions & 0 deletions src/test/data/NinjaSlayer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ NinjaSlayer : (4B6>=4) > 2,3,6,4 > 成功数2
rand:2/6,3/6,6/6,4/6
============================
input:
SNJ4
output:
NinjaSlayer : (4B6>=4) > 2,3,6,4 > 成功数2###secret dice###
rand:2/6,3/6,6/6,4/6
============================
input:
NJ4@N
output:
NinjaSlayer : (4B6>=4) > 2,3,6,4 > 成功数2
Expand Down

0 comments on commit 62ac44a

Please sign in to comment.