Class: BCDice::GameSystem::Torg

Inherits:
Base
  • Object
show all
Defined in:
lib/bcdice/game_system/Torg.rb

Direct Known Subclasses

Torg1_5

Constant Summary collapse

ID =

ゲームシステムの識別子

'Torg'
NAME =

ゲームシステム名

'トーグ'
SORT_KEY =

ゲームシステム名の読みがな

'とおく'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定 (TGm)
   TORG専用の判定コマンドです。
   "TG(技能基本値)"でロールします。Rコマンドに読替されます。
   振り足しを自動で行い、20の出目が出たときには技能無し値も並記します。
  ・各種表 "(表コマンド)(数値)"で振ります。
   ・一般結果表 成功度出力「RTx or RESULTx」
   ・威圧/威嚇 対人行為結果表「ITx or INTIMIDATEx or TESTx」
   ・挑発/トリック 対人行為結果表「TTx or TAUNTx or TRICKx or CTx」
   ・間合い 対人行為結果表「MTx or MANEUVERx」
   ・オーズ(一般人)ダメージ 「ODTx or ORDSx or ODAMAGEx」
   ・ポシビリティー能力者ダメージ「DTx or DAMAGEx」
   ・ボーナス表「BTx+y or BONUSx+y or TOTALx+y」 xは数値, yは技能基本値
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

Methods inherited from Base

#change_text, #check_result, command_pattern, #enable_debug, #enabled_d9?, #eval, eval, #grich_text, #initialize, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

This class inherits a constructor from BCDice::Base

Instance Method Details

#eval_game_system_specific_command(command) ⇒ Object



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
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/bcdice/game_system/Torg.rb', line 111

def eval_game_system_specific_command(command)
  string = command.upcase
  string = replace_text(string)

  if (result = torg_check(string))
    return result
  end

  output = '1'
  ttype = ""
  value = 0

  return nil unless /([RITMDB]T)(\d+([+-]\d+)*)/i =~ string

  type = Regexp.last_match(1)
  num = Regexp.last_match(2)

  case type
  when 'RT'
    value = ArithmeticEvaluator.eval(num)
    output = get_torg_success_level(value)
    ttype = '一般結果'
  when 'IT'
    value = ArithmeticEvaluator.eval(num)
    output = get_torg_interaction_result_intimidate_test(value)
    ttype = '威圧/威嚇'
  when 'TT'
    value = ArithmeticEvaluator.eval(num)
    output = get_torg_interaction_result_taunt_trick(value)
    ttype = '挑発/トリック'
  when 'MT'
    value = ArithmeticEvaluator.eval(num)
    output = get_torg_interaction_result_maneuver(value)
    ttype = '間合い'
  when 'DT'
    value = ArithmeticEvaluator.eval(num)
    if string =~ /ODT/i
      output = get_torg_damage_ords(value)
      ttype = 'オーズダメージ'
    else
      output = get_torg_damage_posibility(value)
      ttype = 'ポシビリティ能力者ダメージ'
    end
  when 'BT'
    output, value = get_torg_bonus_text(num)
    ttype = 'ボーナス'
  end

  if ttype != ''
    output = "#{ttype}表[#{value}] > #{output}"
  end

  return output
end

#get_torg_bonus(value) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/bcdice/game_system/Torg.rb', line 335

def get_torg_bonus(value)
  bonus_table = [
    [1, -12],
    [2, -10],
    [3, -8],
    [5, -5],
    [7, -2],
    [9, -1],
    [11, 0],
    [13, 1],
    [15, 2],
    [16, 3],
    [17, 4],
    [18, 5],
    [19, 6],
    [20, 7]
  ]

  bonus = get_torg_table_result(value, bonus_table)

  if value > 20
    over_value_bonus = ((value - 21) / 5).to_i + 1
    bonus += over_value_bonus
  end

  return bonus
end

#get_torg_bonus_text(num) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/bcdice/game_system/Torg.rb', line 304

def get_torg_bonus_text(num)
  val_arr = num.split(/\+/)
  value = val_arr.shift.to_i

  mod = ArithmeticEvaluator.eval(val_arr.join('+'))
  resultValue = get_torg_bonus(value)

  debug('TORG BT resultValue', resultValue)
  debug('TORG BT mod', mod)

  if mod == 0
    output = resultValue.to_s
  else
    output = getTorgBonusOutputTextWhenModDefined(value, resultValue, mod)
    value = "#{value}+#{mod}"
  end

  return output, value
end

#get_torg_damage(value, maxDamage, maxDamageString, damage_table) ⇒ Object



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/bcdice/game_system/Torg.rb', line 289

def get_torg_damage(value, maxDamage, maxDamageString, damage_table)
  if value < 0
    return '1'
  end

  table_max_value = damage_table.length - 1

  if value <= table_max_value
    return get_torg_table_result(value, damage_table)
  end

  over_kill_damage = ((value - table_max_value) / 2).to_i
  return "" + (over_kill_damage + maxDamage).to_s + maxDamageString
end

#get_torg_damage_ords(value) ⇒ Object

オーズダメージチャート



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
# File 'lib/bcdice/game_system/Torg.rb', line 236

def get_torg_damage_ords(value)
  damage_table_ords = [
    [0, "1"],
    [1, "O1"],
    [2, "K1"],
    [3, "O2"],
    [4, "O3"],
    [5, "K3"],
    [6, "転倒 K/O4"],
    [7, "転倒 K/O5"],
    [8, "1レベル負傷  K/O7"],
    [9, "1レベル負傷  K/O9"],
    [10, "1レベル負傷  K/O10"],
    [11, "2レベル負傷  K/O11"],
    [12, "2レベル負傷  KO12"],
    [13, "3レベル負傷  KO13"],
    [14, "3レベル負傷  KO14"],
    [15, "4レベル負傷  KO15"]
  ]

  return get_torg_damage(value,
                         4,
                         "レベル負傷  KO15",
                         damage_table_ords)
end

#get_torg_damage_posibility(value) ⇒ Object

ポシビリティー能力者ダメージチャート



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/bcdice/game_system/Torg.rb', line 263

def get_torg_damage_posibility(value)
  damage_table_posibility = [
    [0, "1"],
    [1, "1"],
    [2, "O1"],
    [3, "K2"],
    [4, "2"],
    [5, "O2"],
    [6, "転倒 O2"],
    [7, "転倒 K2"],
    [8, "転倒 K2"],
    [9, "1レベル負傷  K3"],
    [10, "1レベル負傷  K4"],
    [11, "1レベル負傷  O4"],
    [12, "1レベル負傷  K5"],
    [13, "2レベル負傷  O4"],
    [14, "2レベル負傷  KO5"],
    [15, "3レベル負傷  KO5"]
  ]

  return get_torg_damage(value,
                         3,
                         "レベル負傷  KO5",
                         damage_table_posibility)
end

#get_torg_interaction_result_intimidate_test(value) ⇒ Object

対人行為結果表威圧/威嚇(intimidate/Test)



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/bcdice/game_system/Torg.rb', line 181

def get_torg_interaction_result_intimidate_test(value)
  interaction_results_table = [
    [0, "技能なし"],
    [5, "萎縮"],
    [10, "逆転負け"],
    [15, "モラル崩壊"],
    [17, "プレイヤーズコール"]
  ]

  return get_torg_table_result(value, interaction_results_table)
end

#get_torg_interaction_result_maneuver(value) ⇒ Object

間合い(maneuver)



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/bcdice/game_system/Torg.rb', line 207

def get_torg_interaction_result_maneuver(value)
  interaction_results_table = [
    [0, "技能なし"],
    [5, "疲労"],
    [10, "萎縮/疲労"],
    [15, "逆転負け/疲労"],
    [17, "プレイヤーズコール"]
  ]

  return get_torg_table_result(value, interaction_results_table)
end

#get_torg_interaction_result_taunt_trick(value) ⇒ Object

挑発/トリック(Taunt/Trick)



194
195
196
197
198
199
200
201
202
203
204
# File 'lib/bcdice/game_system/Torg.rb', line 194

def get_torg_interaction_result_taunt_trick(value)
  interaction_results_table = [
    [0, "技能なし"],
    [5, "萎縮"],
    [10, "逆転負け"],
    [15, "高揚/逆転負け"],
    [17, "プレイヤーズコール"]
  ]

  return get_torg_table_result(value, interaction_results_table)
end

#get_torg_success_level(value) ⇒ Object

一般結果表 成功度



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/bcdice/game_system/Torg.rb', line 167

def get_torg_success_level(value)
  success_table = [
    [0, "ぎりぎり"],
    [1, "ふつう"],
    [3, "まあよい"],
    [7, "かなりよい"],
    [12, "すごい"]
  ]

  return get_torg_table_result(value, success_table)
end

#get_torg_table_result(value, table) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/bcdice/game_system/Torg.rb', line 219

def get_torg_table_result(value, table)
  output = '1'

  table.each do |item|
    item_index = item[0]

    if item_index > value
      break
    end

    output = item[1]
  end

  return output
end

#getTorgBonusOutputTextWhenModDefined(value, resultValue, mod) ⇒ Object



324
325
326
327
328
329
330
331
332
333
# File 'lib/bcdice/game_system/Torg.rb', line 324

def getTorgBonusOutputTextWhenModDefined(value, resultValue, mod)
  debug('getTorgBonusOutputTextWhenModDefined value, mod', value, mod)
  if mod > 0
    return "#{resultValue}[#{value}]+#{mod}#{resultValue + mod}"
  else
    debug('resultValue', resultValue)
    debug('mod', mod)
    return "#{resultValue}[#{value}]#{mod}#{resultValue + mod}"
  end
end

#replace_text(string) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bcdice/game_system/Torg.rb', line 33

def replace_text(string)
  string = string.gsub(/Result/i, 'RT')
  string = string.gsub(/(Intimidate|Test)/i, 'IT')
  string = string.gsub(/(Taunt|Trick|CT)/i, 'TT')
  string = string.gsub(/Maneuver/i, 'MT')
  string = string.gsub(/(ords|odamage)/i, 'ODT')
  string = string.gsub(/damage/i, 'DT')
  string = string.gsub(/(bonus|total)/i, 'BT')
  string = string.gsub(/TG(\d+)/i) { "1R20+#{Regexp.last_match(1)}" }
  string = string.gsub(/TG/i, '1R20')

  return string
end

#torg_check(string) ⇒ Object

TORG ########################



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
# File 'lib/bcdice/game_system/Torg.rb', line 48

def torg_check(string)
  unless /(^|\s)S?(1R20([+-]\d+)*)(\s|$)/i =~ string
    return nil
  end

  string = Regexp.last_match(2)
  mod = Regexp.last_match(3)

  debug(mod)
  mod = ArithmeticEvaluator.eval(mod) if mod
  debug(mod)
  mod = mod.to_i

  skilled, unskilled, dice_str = torg_dice
  sk_bonus = get_torg_bonus(skilled)

  if mod
    if mod > 0
      output = "#{sk_bonus}[#{dice_str}]+#{mod}"
    else
      output = "#{sk_bonus}[#{dice_str}]#{mod}"
    end
  else
    output = "#{sk_bonus}[#{dice_str}]"
  end

  output += "" + (sk_bonus + mod).to_s

  if skilled != unskilled
    output += "(技能無" + (get_torg_bonus(unskilled) + mod).to_s + ")"
  end

  output = "(#{string}) > #{output}"

  return output
end

#torg_diceObject



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
# File 'lib/bcdice/game_system/Torg.rb', line 85

def torg_dice
  isSkilledCritical = true
  isCritical = true
  skilled = 0
  unskilled = 0
  dice_str = ""

  while isSkilledCritical
    dice_n = @randomizer.roll_once(20)
    skilled += dice_n
    unskilled += dice_n if isCritical

    dice_str += "," unless dice_str.empty?
    dice_str += dice_n.to_s

    if dice_n == 20
      isCritical = false
    elsif dice_n != 10
      isSkilledCritical = false
      isCritical = false
    end
  end

  return skilled, unskilled, dice_str
end