Class: BCDice::GameSystem::TheUnofficialHollowKnightRPG
- Defined in:
- lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb
Constant Summary collapse
- ID =
ゲームシステムの識別子
'TheUnofficialHollowKnightRPG'
- NAME =
ゲームシステム名
'The Unofficial Hollow Knight RPG'
- SORT_KEY =
ゲームシステム名の読みがな
'しあんおふいしやるほろうないとRPG'
- HELP_MESSAGE =
ダイスボットの使い方
<<~INFO_MESSAGE_TEXT ・能力値判定 [n]AD[+b][#r][>=t] n: 能力値。小数可。省略不可。 b: ボーナス、ペナルティダイス。省略可。 r: 追加リロールダイス数。省略可。 t: 目標値。>=含めて省略可。 成功数を判定。 例)1AD, 2.5AD, 1.5AD+1, 2AD#1, 2.5AD+2#2>=4 ・イニシアチブ [n]INTI[+b][#r] n: イニシアチブに使う能力値。省略不可。 b: ボーナス、ペナルティダイス。省略可。 r: 追加リロールダイス数。省略可。 振り直しを行ったうえでイニシアチブ値を計算。 例)1INTI, 2.5INTI, 1.5INTI+1, 2INTI#1, 2.5INTI+2#2 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
-
#ability_roll(command) ⇒ Object
能力値ロール.
- #eval_game_system_specific_command(command) ⇒ Object
-
#initialize(command) ⇒ TheUnofficialHollowKnightRPG
constructor
A new instance of TheUnofficialHollowKnightRPG.
-
#initiative_roll(command) ⇒ Object
イニシアチブロール.
- #number_with_reroll_from_int(number) ⇒ Object
- #number_with_sign_from_int(number) ⇒ Object
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) ⇒ TheUnofficialHollowKnightRPG
Returns a new instance of TheUnofficialHollowKnightRPG.
35 36 37 38 39 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 35 def initialize(command) super(command) @sort_barabara_dice = false # バラバラロール(Bコマンド)でソート無 end |
Instance Method Details
#ability_roll(command) ⇒ Object
能力値ロール
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 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 68 def ability_roll(command) m = /^(\d+\.?\d*)?AD([+-](\d+))?(#(\d*))?(>=(\d+))?/.match(command) unless m return nil end num_of_die = m[1].to_f bonus = m[3].to_i reroll = m[5].to_i difficulty = m[7].to_i if /\.[1-9]+/ =~ num_of_die.to_s dice_command = "#{num_of_die}AD#{number_with_sign_from_int(bonus)}#{number_with_reroll_from_int(reroll)}" reroll += 1 else dice_command = "#{num_of_die.to_i}AD#{number_with_sign_from_int(bonus)}#{number_with_reroll_from_int(reroll)}" end if difficulty == 0 difficulty = 5 else dice_command += ">=#{difficulty}" end # 振られたダイスを入れる values = @randomizer.(num_of_die.to_i + bonus, 6) # 成功数 result = values.count { |num| num >= difficulty } failed_roll = num_of_die.to_i - result # ロールの結果の文字列 rolled_text = "[" + values.join(",") + "]" reroll_values = [] if reroll == 1 reroll_values.push(@randomizer.roll_once(6)) elsif reroll > 1 reroll_values += @randomizer.(reroll, 6) end reroll_result = reroll_values.count { |num| num >= difficulty } if failed_roll < reroll_result reroll_result = failed_roll end result += reroll_result # リロールの結果の文字列をロールの結果の文字列に追加する unless reroll_values.empty? rolled_text += " Reroll [" + reroll_values.join(",") + "]" end # 結果 return "(#{dice_command}) > #{rolled_text} > #{result}成功" end |
#eval_game_system_specific_command(command) ⇒ Object
41 42 43 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 41 def eval_game_system_specific_command(command) ability_roll(command) || initiative_roll(command) end |
#initiative_roll(command) ⇒ Object
イニシアチブロール
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 125 def initiative_roll(command) m = /^(\d+\.?\d*)?(INTI|inti)([+-](\d+))?(#(\d+))?/.match(command) unless m return nil end grace = m[1].to_f bonus = m[3].to_i reroll = m[6].to_i if /\.[1-9]+/ =~ grace.to_s dice_command = "(#{grace}INTI#{number_with_sign_from_int(bonus)}#{number_with_reroll_from_int(reroll)})" reroll += 1 else dice_command = "(#{grace.to_i}INTI#{number_with_sign_from_int(bonus)}#{number_with_reroll_from_int(reroll)})" end values = @randomizer.(grace + bonus, 6) revalue = [] unless reroll == 0 revalue = @randomizer.(reroll, 6) end revalue = revalue.sort result = 0 res_text = "[" values.each do |value| if revalue.empty? # リロールがなければ res_text += value.to_s result += value else # リロールがあったら is_min = false index = -1 revalue.each do |re| index += 1 next unless re > value # リロールしたダイス最小値か res_text += "#{value}<<#{re}" result += re revalue.delete_at(index) is_min = true break end unless is_min # 最小値でなかったら res_text += value.to_s result += value end end res_text += "," end res_text = res_text.chop res_text += "]" return "#{dice_command} > #{res_text} > #{result}" end |
#number_with_reroll_from_int(number) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 57 def number_with_reroll_from_int(number) if number == 0 return "" elsif number > 0 return "\##{number}" else return number.to_s end end |
#number_with_sign_from_int(number) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bcdice/game_system/TheUnofficialHollowKnightRPG.rb', line 45 def number_with_sign_from_int(number) if number == 0 return "" elsif number > 0 return "+#{number.abs}" elsif number < 0 return "-#{number.abs}" else return number.to_s end end |