class BCDice::Result
ダイスロールの結果を表すクラス
コマンドの結果の文字列や、成功/失敗/クリティカル/ファンブルの情報を保持する。 成功/失敗は同時に発生しないこととする。 成功/失敗のペアとクリティカル、ファンブルの三者は独立した要素とし、 「クリティカルだが失敗」や「ファンブルだが成功でも失敗でもない」を許容する。
Attributes
critical[W]
detailed_rands[RW]
failure[W]
fumble[W]
rands[RW]
secret[W]
success[W]
text[RW]
Public Class Methods
critical(text)
click to toggle source
success
と critical
が設定された Result
を作成する
@param text [String] @return [Result]
# File lib/bcdice/result.rb, line 38 def critical(text) new.tap do |r| r.text = text r.critical = true r.success = true end end
failure(text)
click to toggle source
failure
が設定された Result
を作成する
@param text [String] @return [Result]
# File lib/bcdice/result.rb, line 27 def failure(text) new.tap do |r| r.text = text r.failure = true end end
fumble(text)
click to toggle source
failure
と fumble
が設定された Result
を作成する
@param text [String] @return [Result]
# File lib/bcdice/result.rb, line 50 def fumble(text) new.tap do |r| r.text = text r.fumble = true r.failure = true end end
new(text = nil)
click to toggle source
@param text [String | nil]
# File lib/bcdice/result.rb, line 67 def initialize(text = nil) @text = text @rands = nil @detailed_rands = nil @secret = false @success = false @failure = false @critical = false @fumble = false end
nothing()
click to toggle source
その後の判定で何もすることがないことを示すために利用する
@return [:nothing]
# File lib/bcdice/result.rb, line 61 def nothing :nothing end
success(text)
click to toggle source
success
が設定された Result
を作成する
@param text [String] @return [Result]
# File lib/bcdice/result.rb, line 16 def success(text) new.tap do |r| r.text = text r.success = true end end
Public Instance Methods
condition=(condition)
click to toggle source
@param condition [Boolean] @return [void]
# File lib/bcdice/result.rb, line 108 def condition=(condition) @success = condition @failure = !condition end
critical?()
click to toggle source
@return [Boolean]
# File lib/bcdice/result.rb, line 97 def critical? @critical end
failure?()
click to toggle source
@return [Boolean]
# File lib/bcdice/result.rb, line 92 def failure? @failure end
fumble?()
click to toggle source
@return [Boolean]
# File lib/bcdice/result.rb, line 102 def fumble? @fumble end
secret?()
click to toggle source
@return [Boolean]
# File lib/bcdice/result.rb, line 82 def secret? @secret end
success?()
click to toggle source
@return [Boolean]
# File lib/bcdice/result.rb, line 87 def success? @success end