Skip to content

Instantly share code, notes, and snippets.

@raa0121
Created September 16, 2012 12:19
Show Gist options
  • Save raa0121/3732198 to your computer and use it in GitHub Desktop.
Save raa0121/3732198 to your computer and use it in GitHub Desktop.

Command:nSm@Crit

n:d6を振る個数

m:d6で目指す目標値(m以下)

Crit:Crit以下を出すと、d6を2個追加

特殊裁定 最初に振ったnd6の目がすべて1だった場合、スペシャルとし、n*3を成功数とする

Example: 2S2@1 RecordofSteam: (2S2@1) > 1,2,3,4 > 1回転 > 成功数2

4S3@2 RecordofSteam: (4S3@2) > 2,1,2,4,4,4,2,3,4,5,6 > 4回転 > 成功数5

使い方

git clone git://github.com/torgtaitai/BCDice
cd BCDice/src/diceBot
curl -O https://raw.github.com/gist/3335222/9dd1da99d39356ee01cc5bbd930e79daaee40af0/RecordofSteam.rb

cd ..
vim bcdiceCore.rb
vim bcdiceGui.rb

bcdiceCore.rbL1851

    when /(^|\s)RecordofSteam$/i
      require 'diceBot/RecordofSteam'
      diceBot = RecordofSteam.new
      message = 'Game設定をRecordofSteamに設定しました'

bcdiceGui.rbL323

RecordofSteam

を追加

#--*-coding:utf-8-*--
class RecordofSteam < DiceBot
def gameType
"RecordofSteam"
end
def getHelpMessage
return <<MESSAGETEXT
2S2@1
RecordofSteam: (2S2@1) > 1,2,3,4 > 1回転 > 成功数2
4S3@2
RecordofSteam: (4S3@2) > 2,1,2,4,4,4,2,3,4,5,6 > 4回転 > 成功数5
MESSAGETEXT
end
# rubyの定数の定め方をよく知らないのだけれども、何か方法があるならそちらで代替のこと。
def getErrorMessage
"(多分)無限個なので振れません! ヤメテクダサイ、(プロセスが)死んでしまいますっ"
end
# サンプルのダイスコマンドは「nSt@c」で n=ダイス個数, t=目標値, c=クリティカル値。@cのみ省略可
def rollDiceCommandResult(string)
# 分解
unless( /(\d+)[sS](\d+)(@(\d+))?/i =~ string )
return "1"
end
# 記述のエラー検出
return getErrorMessage if($1.to_i>=150)
return getErrorMessage if($4.to_i>=3)
# 値を取得
diceCount = $1.to_i # d6を振る個数
targetNumber = $2.to_i # それぞれのd6で目指す目標値(targetNumber"以下")
criticalValue = $4 # それぞれのd6で目指すクリティカル値(criticalValue"以下")
criticalValue ||= "1"
criticalValue = criticalValue.to_i
specialValue = [ diceCount, 0 ].max
rollResult, successCount, roundCount, specialCount = getDiceRollResult(diceCount, targetNumber, criticalValue, specialValue)
output = "(#{string}) > #{rollResult}"
if(output.length > $SEND_STR_MAX)
output = "(#{string}) > ..."
end
roundCountText = getRoundCountText(roundCount)
successText = getSuccessText(successCount)
specialText = getSpecialText(specialCount)
result = "#{output}#{roundCountText}#{specialText}#{successText}"
return result
end
def getDiceRollResult(diceCount, targetNumber, criticalValue, specialValue)
successCount = 0
roundCount = 0
rollResult = ""
specialCount = 0
while(diceCount > 0)
totalValue, diceListText, = roll(diceCount, 6)
debug("diceListText", diceListText)
rollResult += "," if(rollResult != "")
rollResult += diceListText
diceList = getDiceListFromDiceText(diceListText)
debug("diceList", diceList)
diceCount = 0
if( (totalValue == specialValue) && (roundCount == 0) )
specialCount = 1
successCount = specialValue * 3
return rollResult, successCount ,roundCount, specialCount
end
diceList.each do |diceValue|
debug("diceValue", diceValue)
debug("criticalValue", criticalValue)
debug("specialValue", specialValue)
if(diceValue <= criticalValue)
diceCount += 2
roundCount += 1
end
if(diceValue <= targetNumber)
successCount += 1
end
end
end
return rollResult, successCount ,roundCount, specialCount
end
def getRoundCountText(roundCount)
if( roundCount <= 0 )
return ""
end
return " > #{roundCount}回転"
end
def getSuccessText(successCount)
if(successCount > 0)
return " > 成功数#{successCount}"
end
return " > 失敗"
end
def getSpecialText(specialCount)
if(specialCount == 1)
return " > スペシャル"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment