Class: BCDice::GameSystem::Chill

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'Chill'
NAME =

ゲームシステム名

'Chill'
SORT_KEY =

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

'ちる'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・ストライク・ランク (SRx)
   "SRストライク・ランク"の形で記入します。
   ストライク・ランク・チャートに従って自動でダイスロールを行い、
   負傷とスタミナロスを計算します。
   ダイスロールと同様に、他のプレイヤーに隠れてロールすることも可能です。
   例)SR7   sr13   SR(7+4)   Ssr10
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

#check_strike_rank(strikeRank) ⇒ Object



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
153
154
155
156
157
158
159
160
# File 'lib/bcdice/game_system/Chill.rb', line 106

def check_strike_rank(strikeRank)
  strikeRank = strikeRank.to_i

  dice = ''
  dice_add = ''
  dice_str = ''
  damage = 0

  if strikeRank < 1
    damage = 0
    dice_str = '-'
    dice_add = '-'
    dice = '-'

  elsif strikeRank < 2
    dice = '0or1'
    damage = @randomizer.roll_once(2)
    dice_str = damage.to_s

    damage -= 1
    dice_add = damage.to_s
  elsif strikeRank < 3
    dice = '1or2'
    damage = @randomizer.roll_once(2)
    dice_str = damage.to_s
    dice_add = damage.to_s
  elsif strikeRank < 4
    dice = '1d5'
    damage = @randomizer.roll_once(5)
    dice_str = damage.to_s
    dice_add = damage.to_s
  elsif strikeRank < 10
    dice = (strikeRank - 3).to_s + 'd10'
    dice_list = @randomizer.roll_barabara(strikeRank - 3, 10)
    damage = dice_list.sum()
    dice_add = damage.to_s
    dice_str = dice_list.join(",")
  elsif strikeRank < 13
    dice = (strikeRank - 6).to_s + 'd10*2'
    dice_list = @randomizer.roll_barabara(strikeRank - 6, 10)
    total = dice_list.sum()
    dice_add = "#{total}*2"
    damage = total * 2
    dice_str = "(#{dice_list.join(',')})*2"
  else
    dice = '5d10*3'
    dice_list = @randomizer.roll_barabara(5, 10)
    total = dice_list.sum()
    dice_add = "#{total}*3"
    damage = total * 3
    dice_str = "(#{dice_list.join(',')})*3"
  end

  return damage, dice, dice_add, dice_str
end

#eval_game_system_specific_command(command) ⇒ Object



46
47
48
# File 'lib/bcdice/game_system/Chill.rb', line 46

def eval_game_system_specific_command(command)
  roll_strike_rank_result(command)
end

#result_1d100(total, _dice_total, cmp_op, target) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bcdice/game_system/Chill.rb', line 27

def result_1d100(total, _dice_total, cmp_op, target)
  return nil if target == '?'
  return nil if cmp_op != :<=

  if total >= 100
    Result.fumble("ファンブル")
  elsif total > target
    Result.failure("失敗")
  elsif total >= (target * 0.9)
    Result.success("L成功")
  elsif total >= (target / 2)
    Result.success("M成功")
  elsif total >= (target / 10)
    Result.success("H成功")
  else
    Result.critical("C成功")
  end
end

#roll_strike_rank_result(string) ⇒ Object



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

def roll_strike_rank_result(string)
  debug('strike_rank begin string', string)

  wounds = 0
  sta_loss = 0
  dice = ''
  dice_add = ""
  dice_str = ""

  unless /(^|\s)[sS]?(SR|sr)(\d+)($|\s)/ =~ string
    debug('invalid string', string)
    return "1"
  end

  strikeRank = Regexp.last_match(3).to_i

  if strikeRank < 14
    sta_loss, dice, dice_add, dice_str = check_strike_rank(strikeRank)
    wounds, dice_w, dice_wa, dice_ws = check_strike_rank(strikeRank - 3)
    dice = dice + ', ' + dice_w
    dice_add += ', ' + dice_wa
    dice_str = dice_str + ', ' + dice_ws
  else
    sta_loss, _dice, dice_add, dice_str = check_strike_rank(13)

    dice_list = @randomizer.roll_barabara(4, 10)
    wounds = dice_list.sum()
    dice_ws = dice_list.join(",")

    dice = '5d10*3, 4d10+' + ((strikeRank - 13) * 2).to_s + 'd10'
    dice_add += ', ' + wounds.to_s
    dice_str = "#{dice_str}, #{dice_ws}"

    dice_list = @randomizer.roll_barabara((strikeRank - 13) * 2, 10)
    wounds_wk = dice_list.sum()
    dice_ws = dice_list.join(",")

    dice_str += "+#{dice_ws}"
    dice_add += "+#{wounds_wk}"
    wounds += wounds_wk
  end

  output = "#{dice_str}#{dice_add} > スタミナ損失#{sta_loss}, 負傷#{wounds}"

  string += ':' + dice

  if output.empty?
    return "1"
  end

  output = "(#{string}) > #{output}"
  debug('strike_rank end output', output)

  return output
end