class BCDice::GameSystem::DetatokoSaga
Constants
- ALIAS
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- SORT_KEY
ゲームシステム名の読みがな
- TABLES
Public Class Methods
new(command)
click to toggle source
Calls superclass method
BCDice::Base::new
# File lib/bcdice/game_system/DetatokoSaga.rb, line 31 def initialize(command) super(command) @sort_add_dice = true @d66_sort_type = D66SortType::ASC end
translate_tables(locale)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 213 def self.translate_tables(locale) { "SST" => DiceTable::Table.from_i18n("DetatokoSaga.table.SST", locale), "WST" => DiceTable::Table.from_i18n("DetatokoSaga.table.WST", locale), "SBET" => DiceTable::Table.from_i18n("DetatokoSaga.table.SBET", locale), "WBET" => DiceTable::Table.from_i18n("DetatokoSaga.table.WBET", locale), } end
Public Instance Methods
checkJudgeValue(string)
click to toggle source
スキル判定値 xJD or xJDy or xJDy+z or xJDy-z or xJDy/z
# File lib/bcdice/game_system/DetatokoSaga.rb, line 137 def checkJudgeValue(string) debug("checkJudgeValue begin string", string) m = %r{^(\d+)JD(\d+)?(([+-/])(\d+))?$}i.match(string) unless m return nil end skill = m[1].to_i flag = m[2].to_i operator = m[4] value = m[5].to_i result = translate("DetatokoSaga.JD.input_options", skill: skill, flag: flag) modifyText = getModifyText(operator, value) result += translate("DetatokoSaga.JD.modifier", modifier: modifyText) unless modifyText.empty? total, rollText = getRollResult(skill) result += " > #{total}[#{rollText}]#{modifyText}" totalResult = getTotalResultValue(total, value, operator) result += " > #{totalResult}" result += getCheckFlagResult(total, flag) return result end
checkRoll(string)
click to toggle source
通常判定 xDS or xDSy or xDS>=z or xDSy>=z
# File lib/bcdice/game_system/DetatokoSaga.rb, line 52 def checkRoll(string) debug("checkRoll begin string", string) m = %r{^(\d+)DS(\d+)?(([+-/])(\d+))?(?:>=(\d+))?$}i.match(string) unless m return nil end skill = m[1].to_i flag = m[2].to_i operator = m[4] value = m[5].to_i target = m[6]&.to_i || 8 result = translate("DetatokoSaga.DS.input_options", skill: skill, flag: flag, target: target) modifyText = getModifyText(operator, value) result += translate("DetatokoSaga.DS.modifier", modifier: modifyText) unless modifyText.empty? total, rollText = getRollResult(skill) result += " > #{total}[#{rollText}]#{modifyText}" totalResult = getTotalResultValue(total, value, operator) result += " > #{totalResult}" unless modifyText.empty? case operator when "+" total += value when "-" total -= value end end success = getSuccess(total, target) result += " > #{success}" result += getCheckFlagResult(total, flag) return result end
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 38 def eval_game_system_specific_command(command) debug("eval_game_system_specific_command begin string", command) result = checkRoll(command) return result if result result = checkJudgeValue(command) return result if result debug("各種表として処理") return roll_tables(ALIAS[command] || command, self.class::TABLES) end
getCheckFlagResult(total, flag)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 118 def getCheckFlagResult(total, flag) if total > flag return "" end will = getDownWill(flag) return translate("DetatokoSaga.less_than_flag", will: will) end
getDownWill(flag)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 127 def getDownWill(flag) if flag >= 10 return "6" end dice = @randomizer.roll_once(6) return "1D6->#{dice}" end
getModifyText(operator, value)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 166 def getModifyText(operator, value) return '' if value == 0 operatorText = case operator when "+" "+" when "-" "-" when "/" "÷" else return "" end return "#{operatorText}#{value}" end
getRollResult(skill)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 95 def getRollResult(skill) diceCount = skill + 1 diceCount = 3 if skill == 0 dice = @randomizer.roll_barabara(diceCount, 6) diceText = dice.join(',') dice = dice.sort dice = dice.reverse if skill != 0 total = dice[0] + dice[1] return total, diceText end
getSuccess(check, target)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 110 def getSuccess(check, target) if check >= target translate("DetatokoSaga.DS.success") else translate("DetatokoSaga.DS.failure") end end
getTotalResultValue(total, value, operator)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 184 def getTotalResultValue(total, value, operator) case operator when "+" return "#{total}+#{value} > " + translate("DetatokoSaga.total_value", total: total + value) when "-" return "#{total}-#{value} > " + translate("DetatokoSaga.total_value", total: total - value) when "/" return getTotalResultValueWhenSlash(total, value) else return translate("DetatokoSaga.total_value", total: total) end end
getTotalResultValueWhenSlash(total, value)
click to toggle source
# File lib/bcdice/game_system/DetatokoSaga.rb, line 197 def getTotalResultValueWhenSlash(total, value) return translate("DetatokoSaga.division_by_zero_error") if value == 0 quotient = ((1.0 * total) / value).ceil result = "#{total}÷#{value} > " + translate("DetatokoSaga.total_value", total: quotient) return result end