Class: BCDice::GameSystem::EarthDawn
- Defined in:
- lib/bcdice/game_system/EarthDawn.rb
Direct Known Subclasses
Constant Summary collapse
- ID =
ゲームシステムの識別子
'EarthDawn'
- NAME =
ゲームシステム名
'アースドーン'
- SORT_KEY =
ゲームシステム名の読みがな
'ああすとおん'
- HELP_MESSAGE =
ダイスボットの使い方
<<~INFO_MESSAGE_TEXT ステップダイス (xEn+k) ステップx、目標値n(省略可能)、カルマダイスk(D2-D20)でステップダイスをロールします。 振り足しも自動。 例)9E 10E8 10E+D12 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
-
#ed_step(str) ⇒ Object
アースドーンステップ表.
- #eval_game_system_specific_command(command) ⇒ Object
- #getStepResult(str) ⇒ Object
- #getStepTable ⇒ Object
-
#initialize(command) ⇒ EarthDawn
constructor
A new instance of EarthDawn.
-
#rollStep(diceType, diceCount) ⇒ Object
ステップ34xのダイス + [(xx-45)/11]d20 + ステップのダイス.
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) ⇒ EarthDawn
Returns a new instance of EarthDawn.
25 26 27 28 29 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 25 def initialize(command) super(command) @sort_add_dice = true end |
Instance Method Details
#ed_step(str) ⇒ Object
アースドーンステップ表
36 37 38 39 40 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 36 def ed_step(str) output = getStepResult(str) return output end |
#eval_game_system_specific_command(command) ⇒ Object
31 32 33 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 31 def eval_game_system_specific_command(command) return ed_step(command) end |
#getStepResult(str) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 100 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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 42 def getStepResult(str) return nil unless /(\d+)E(\d+)?(\+)?(\d+)?(d\d+)?/i =~ str stepTotal = 0 @isFailed = true step = Regexp.last_match(1).to_i # ステップ targetNumber = 0 # 目標値 hasKarmaDice = false # カルマダイスの有無 karmaDiceCount = 0 # カルマダイスの個数又は修正 karmaDiceType = 0 # カルマダイスの種類 # 空値があった時の為のばんぺいくんRX if step > 40 step = 40 end if Regexp.last_match(2) targetNumber = Regexp.last_match(2).to_i targetNumber = 42 if targetNumber > 43 end hasKarmaDice = Regexp.last_match(3).to_i if Regexp.last_match(3) karmaDiceCount = Regexp.last_match(4).to_i if Regexp.last_match(4) karmaDiceType = Regexp.last_match(5) if Regexp.last_match(5) return nil if targetNumber < 0 stable = getStepTable() nmod = stable[0][step - 1] d20step = stable[1][step - 1] d12step = stable[2][step - 1] d10step = stable[3][step - 1] d8step = stable[4][step - 1] d6step = stable[5][step - 1] d4step = stable[6][step - 1] if hasKarmaDice case karmaDiceType when /d20/i d20step += karmaDiceCount when /d12/i d12step += karmaDiceCount when /d10/i d10step += karmaDiceCount when /d8/i d8step += karmaDiceCount when /d6/i d6step += karmaDiceCount when /d4/i d4step += karmaDiceCount else nmod += karmaDiceCount end end @string = "" debug('d20step, d12step, d10step, d8step, d6step, d4step', d20step, d12step, d10step, d8step, d6step, d4step) stepTotal += rollStep(20, d20step) stepTotal += rollStep(12, d12step) stepTotal += rollStep(10, d10step) stepTotal += rollStep(8, d8step) stepTotal += rollStep(6, d6step) stepTotal += rollStep(4, d4step) if nmod > 0 # 修正分の適用 @string += "+" end if nmod != 0 @string += nmod.to_s stepTotal += nmod end # ステップ判定終了 @string += " > #{stepTotal}" output = "ステップ#{step} > #{@string}" return output if targetNumber == 0 # 結果判定 @string += ' > ' excelentSuccessNumber = stable[7][targetNumber - 1] superSuccessNumber = stable[8][targetNumber - 1] goodSuccessNumber = stable[9][targetNumber - 1] failedNumber = stable[11][targetNumber - 1] if @isFailed @string += '自動失敗' elsif stepTotal >= excelentSuccessNumber @string += '最良成功' elsif stepTotal >= superSuccessNumber @string += '優成功' elsif stepTotal >= goodSuccessNumber @string += '良成功' elsif stepTotal >= targetNumber @string += '成功' elsif stepTotal < failedNumber @string += '大失敗' else @string += '失敗' end output = "ステップ#{step}>=#{targetNumber} > #{@string}" return output end |
#getStepTable ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 154 def getStepTable # 表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 34x 3x 4x 5x 6x 7x 8x 9x10x11x12x13x mod = [-2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] d20 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] d12 = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1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7, 9, 10, 12, 13, 14, 15, 17, 18, 20, 21, 22, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 54,] nsuc = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,] fsuc = [0, 1, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, 18, 18, 20, 21, 22, 23, 23, 24, 25, 26, 26, 27, 28, 29, 30,] stable = [mod, d20, d12, d10, d8, d6, d4, exsuc, ssuc, gsuc, nsuc, fsuc] return stable end |
#rollStep(diceType, diceCount) ⇒ Object
ステップ34xのダイス+ [(xx-45)/11]d20 + ステップのダイス
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/bcdice/game_system/EarthDawn.rb', line 186 def rollStep(diceType, diceCount) debug('rollStep diceType, diceCount, @string', diceType, diceCount, @string) stepTotal = 0 return stepTotal unless diceCount > 0 # diceぶんのステップ判定 @string += "+" unless @string.empty? @string += "#{diceCount}d#{diceType}[" debug('rollStep @string', @string) 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 @string += ',' if i != 0 @string += dice_in.to_s end @string += "]" return stepTotal end |