Class: BCDice::GameSystem::EarthDawn4
- Defined in:
- lib/bcdice/game_system/EarthDawn4.rb
Constant Summary collapse
- ID =
ゲームシステムの識別子
'EarthDawn4'
- NAME =
ゲームシステム名
'アースドーン4版'
- SORT_KEY =
ゲームシステム名の読みがな
'ああすとおん4'
- HELP_MESSAGE =
ダイスボットの使い方
<<~INFO_MESSAGE_TEXT ステップダイス (xEnK) ステップx、目標値n(省略可能)でステップダイスをロール。 カルマダイス使用時は末尾にKを追加(省略可能) 例)ステップ10:10E ステップ10、目標値8:10E8 ステップ10、目標値8、カルマダイス:10E8K INFO_MESSAGE_TEXT
Instance Attribute Summary
Attributes inherited from Base
#d66_sort_type, #default_cmp_op, #default_target_number, #randomizer, #reroll_dice_reroll_threshold, #round_type, #sides_implicit_d, #upper_dice_reroll_threshold
Instance Method Summary collapse
- #addStepToResult(result, step) ⇒ Object
-
#ed_step(str) ⇒ Object
アースドーンステップ表.
- #eval_game_system_specific_command(command) ⇒ Object
- #getBaseStepTable ⇒ Object
- #getModifyText(modify) ⇒ Object
- #getStepInfo(step) ⇒ Object
- #getStepResult(str) ⇒ Object
- #getStepResultInfo(str) ⇒ Object
- #getStepResultInfos(str) ⇒ Object
- #getSuccess(targetNumber, stepTotal) ⇒ Object
-
#initialize(command) ⇒ EarthDawn4
constructor
A new instance of EarthDawn4.
- #rollStep(diceType, diceCount) ⇒ Object
Methods inherited from EarthDawn
Methods inherited from Base
#change_text, #check_result, command_pattern, #enable_debug, #enabled_d9?, #eval, eval, #grich_text, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?
Methods included from Translate
Constructor Details
#initialize(command) ⇒ EarthDawn4
Returns a new instance of EarthDawn4.
29 30 31 32 33 34 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 29 def initialize(command) super(command) @sort_add_dice = true @calcText = '' end |
Instance Method Details
#addStepToResult(result, step) ⇒ Object
210 211 212 213 214 215 216 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 210 def addStepToResult(result, step) result.size.times do |i| result[i] += step[i] end return result end |
#ed_step(str) ⇒ Object
アースドーンステップ表
41 42 43 44 45 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 41 def ed_step(str) output = getStepResult(str) return output end |
#eval_game_system_specific_command(command) ⇒ Object
36 37 38 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 36 def eval_game_system_specific_command(command) return ed_step(command) end |
#getBaseStepTable ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 145 def getBaseStepTable stepTable = [ # dice # D20 D12 D10 D8 D6 D4 mod [1, [0, 0, 0, 0, 0, 1, -2]], [2, [0, 0, 0, 0, 0, 1, -1]], [3, [0, 0, 0, 0, 0, 1, 0]], [4, [0, 0, 0, 0, 1, 0, 0]], [5, [0, 0, 0, 1, 0, 0, 0]], [6, [0, 0, 1, 0, 0, 0, 0]], [7, [0, 1, 0, 0, 0, 0, 0]], ] return stepTable end |
#getModifyText(modify) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 136 def getModifyText(modify) string = "" return string if modify == 0 string += "+" if modify > 0 string += modify.to_s return string end |
#getStepInfo(step) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 162 def getStepInfo(step) baseStepTable = getBaseStepTable baseMaxStep = baseStepTable.last.first if step <= baseMaxStep return get_table_by_number(step, baseStepTable) end # dice # D20 D12 D10 D8 D6 D4 mod overBounusStep = [1, 0, 0, 0, 0, 0, 0] overStep = step - baseMaxStep - 1 stepRythm = [ # dice # D20 D12 D10 D8 D6 D4 mod [0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 2, 0, 0], [0, 1, 0, 1, 1, 0, 0], [0, 1, 0, 2, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], ] # [ 1, 0, 0, 0, 2, 0, 0], result = [0, 0, 0, 0, 0, 0, 0] loopCount = (overStep / stepRythm.size) loopCount.times do addStepToResult(result, overBounusStep) end index = (overStep % stepRythm.size) restStepInfo = stepRythm[index] addStepToResult(result, restStepInfo) return result end |
#getStepResult(str) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 47 def getStepResult(str) stepText, calcText, stepTotal, targetNumber = getStepResultInfos(str) return nil if stepText.nil? if targetNumber == 0 output = "#{stepText} > #{calcText} > #{stepTotal}" return output end # 結果判定 successText = getSuccess(targetNumber, stepTotal) output = "#{stepText}>=#{targetNumber} > #{calcText} > #{stepTotal} > #{successText}" return output end |
#getStepResultInfo(str) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 101 def getStepResultInfo(str) return nil unless /^(\d+)E(\d+)?(K)?(\+\d+$)?(\+(.*))?/i =~ str stepTotal = 0 @isFailed = true step = Regexp.last_match(1).to_i # ステップ targetNumber = Regexp.last_match(2).to_i # 目標値 return nil if targetNumber < 0 hasKarmaDice = !Regexp.last_match(3).nil? # カルマダイスの有無 diceModify = Regexp.last_match(4).to_i nextText = Regexp.last_match(6) stepInfo = getStepInfo(step) debug('stepInfo', stepInfo) @calcText = "" diceTypes = [20, 12, 10, 8, 6, 4] diceTypes.each do |type| stepTotal += rollStep(type, stepInfo.shift) end modify = stepInfo.shift stepTotal += rollStep(6, 1) if hasKarmaDice @calcText += (getModifyText(modify) + getModifyText(diceModify)) stepTotal += (modify + diceModify) stepText = "ステップ#{step}" return stepText, @calcText, stepTotal, targetNumber, nextText end |
#getStepResultInfos(str) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 65 def getStepResultInfos(str) steps = [] calcs = [] totals = [] target = 0 while !str.nil? && !str.empty? debug("=====>!! str", str) step, calc, total, value, nextText = getStepResultInfo(str) debug("=====> step", step) return nil if step.nil? steps << step calcs << calc totals << total target = value unless value == 0 debug("=====> nextText", nextText) break if nextText == str str = nextText end stepText = steps.join("+") calcText = calcs.join(")+(") stepTotal = totals.inject { |sum, i| sum + i } calcText = "(" + calcText + ")" if calcs.size > 1 calcText += " > (#{totals.join('+')})" if totals.size > 1 return stepText, calcText, stepTotal, target end |
#getSuccess(targetNumber, stepTotal) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 218 def getSuccess(targetNumber, stepTotal) return '自動失敗' if @isFailed diff = stepTotal - targetNumber debug("diff", diff) if diff < 0 return "失敗" end level = (diff / 5) + 1 return "成功 レベル:#{level}" end |
#rollStep(diceType, diceCount) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/bcdice/game_system/EarthDawn4.rb', line 233 def rollStep(diceType, diceCount) debug('rollStep diceType, diceCount, @calcText', diceType, diceCount, @calcText) stepTotal = 0 return stepTotal unless diceCount > 0 # diceぶんのステップ判定 @calcText += "+" unless @calcText.empty? @calcText += "#{diceCount}d#{diceType}[" debug('rollStep string', @calcText) diceCount.times do |i| dice_now = @randomizer.roll_once(diceType) if dice_now != 1 @isFailed = false end dice_in = dice_now while dice_now == diceType dice_now = @randomizer.roll_once(diceType) dice_in += dice_now end stepTotal += dice_in @calcText += ',' if i != 0 @calcText += dice_in.to_s end @calcText += "]" return stepTotal end |