Class: BCDice::GameSystem::LostRoyal

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'LostRoyal'
NAME =

ゲームシステム名

'ロストロイヤル'
SORT_KEY =

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

'ろすとろいやる'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・D66ダイスあり

  行為判定
   LR[x,x,x,x,x,x]
    x の並びには【判定表】の数値を順番に入力する。
    (例: LR[1,3,0,1,2,3] )

  ファンブル表
   FC

  風力決定表
   WPC

  感情決定表
   EC

  希望点の決定
   HRx
    x にはダイスの数( 1 - 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

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

#translate

Constructor Details

#initialize(command) ⇒ LostRoyal

Returns a new instance of LostRoyal.



40
41
42
43
44
45
# File 'lib/bcdice/game_system/LostRoyal.rb', line 40

def initialize(command)
  super(command)

  @sort_add_dice = true
  @d66_sort_type = D66SortType::NO_SORT
end

Instance Method Details

#check_lostroyal(checking_table) ⇒ Object



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

def check_lostroyal(checking_table)
  keys = []

  3.times do |_i|
    key = @randomizer.roll_once(6)
    keys << key
  end

  scores = (keys.map { |k| checking_table[k - 1] }).to_a
  total_score = scores.inject(:+)

  chained_sequence = find_sequence(keys)

  text = "3D6 => [#{keys.join(',')}] => (#{scores.join('+')}) => #{total_score}"

  unless chained_sequence.nil? || chained_sequence.empty?
    bonus = fumble_?(keys, chained_sequence) ? 3 : chained_sequence.size
    text += " | #{chained_sequence.size} chain! (#{chained_sequence.join(',')}) => #{total_score + bonus}"

    if chained_sequence.size >= 3
      text += " [スペシャル]"
    end

    if fumble_?(keys, chained_sequence)
      text += " [ファンブル]"
    end
  end

  return text
end

#eval_game_system_specific_command(command) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bcdice/game_system/LostRoyal.rb', line 47

def eval_game_system_specific_command(command)
  case command
  when /LR\[([0-5]),([0-5]),([0-5]),([0-5]),([0-5]),([0-5])\]/i
    return check_lostroyal([Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i, Regexp.last_match(4).to_i, Regexp.last_match(5).to_i, Regexp.last_match(6).to_i,])
  when /FC/
    return roll_fumble_chart
  when /WPC/
    return roll_wind_power_chart
  when /EC/
    return roll_emotion_chart
  when /HR([1-2])/
    return roll_hope(Regexp.last_match(1).to_i)
  end

  return nil
end

#find_sequence(keys) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/bcdice/game_system/LostRoyal.rb', line 95

def find_sequence(keys)
  keys = keys.sort

  sequences = (1...6).map do |start_key|
    find_sequence_from_start_key(keys, start_key)
  end
  sequences.select { |x| x.size > 1 }.max { |a, b| a.size <=> b.size }
end

#find_sequence_from_start_key(keys, start_key) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/bcdice/game_system/LostRoyal.rb', line 104

def find_sequence_from_start_key(keys, start_key)
  chained_keys = []

  key = start_key

  while keys.include? key
    chained_keys << key
    key += 1
  end

  if !chained_keys.empty? && chained_keys[0] == 1
    key = 6
    while keys.include? key
      chained_keys.unshift key
      key -= 1
    end
  end

  return chained_keys
end

#fumble_?(keys, chained_sequence) ⇒ Boolean

Returns:

  • (Boolean)


125
126
127
128
129
130
131
132
133
# File 'lib/bcdice/game_system/LostRoyal.rb', line 125

def fumble_?(keys, chained_sequence)
  chained_sequence.each do |k|
    if keys.count(k) >= 2
      return true
    end
  end

  false
end

#is_1or2(n) ⇒ Object



234
235
236
# File 'lib/bcdice/game_system/LostRoyal.rb', line 234

def is_1or2(n)
  [1, 2].include?(n)
end

#roll_emotion_chartObject



190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/bcdice/game_system/LostRoyal.rb', line 190

def roll_emotion_chart
  key = @randomizer.roll_once(6)

  text = [
    "愛情/殺意",
    "友情/負目",
    "崇拝/嫌悪",
    "興味/侮蔑",
    "信頼/嫉妬",
    "守護/欲情",
  ][key - 1]

  return "1D6 => [#{key}] #{text}"
end

#roll_fumble_chartObject



135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/bcdice/game_system/LostRoyal.rb', line 135

def roll_fumble_chart
  key = @randomizer.roll_once(6)

  text = [
    "何かの問題で言い争い、主君に無礼を働いてしまう。あなたは主君の名誉点を1点失うか、【時間】を1点消費して和解の話し合いを持つか選べる。",
    "見過ごせば人々を不幸にする危険に遭遇する。あなたは逃げ出して冒険の名誉点を1点失うか、これに立ち向かい【命数】を2点減らすかを選べる。",
    "あなたが惹かれたのは好意に付け込む人だった。あなたはその場を去って恋慕の名誉点を1点失うか【正義】を1点減らして礼を尽くすかを選べる。",
    "金銭的な問題で、生命と魂の苦しみを背負う人に出会う。あなたは庇護の名誉点を1点失うか出費を3点増やすかを選べる。",
    "襲撃を受ける。苦もなく叩き伏せると、卑屈な態度で命乞いをしてきた。容赦なく命を奪い寛容の名誉点を1点失うか、密告によって【血路】が1D6点増えるかを選ぶことができる。",
    "風聞により、友が悪に身を貶めたと知る。共に並んだ戦場が色褪せる想いだ。戦友の名誉点を1点減らすか、【酒と歌】すべてを失うかを選べる。",
  ][key - 1]

  return "1D6 => [#{key}] #{text}"
end

#roll_hope(number_of_dice) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/bcdice/game_system/LostRoyal.rb', line 205

def roll_hope(number_of_dice)
  total = 0
  text = ""

  loop do
    d1 = @randomizer.roll_once(6)
    d2 = 0

    if number_of_dice >= 2
      d2 = @randomizer.roll_once(6)
    end

    total += d1 + d2

    if number_of_dice == 2
      text += "2D6[#{d1},#{d2}]"
    else
      text += "1D6[#{d1}]"
    end

    if is_1or2(d1) || is_1or2(d2)
      text += " (振り足し) => "
    else
      text += " => 合計 #{total}"
      return text
    end
  end
end

#roll_wind_power_chartObject



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
183
184
185
186
187
188
# File 'lib/bcdice/game_system/LostRoyal.rb', line 150

def roll_wind_power_chart
  key = 0
  total_bonus = 0
  text = ""

  loop do
    dice = @randomizer.roll_once(6)
    key += dice

    add, bonus, current_text, = [
      [true, 0, "ほぼ凪(振り足し)"],
      [true, 0, "弱い風(振り足し)"],
      [false, 0, "ゆるやかな風"],
      [false, 0, "ゆるやかな風"],
      [false, 1, "やや強い風(儀式点プラス1)"],
      [false, 2, "強い風(龍を幻視、儀式点プラス2)"],
      [false, 3, "体が揺らぐほどの風(龍を幻視、儀式点プラス3)"],
    ][[key, 7].min - 1]

    total_bonus += bonus

    if key != dice
      current_text = "1D6[#{dice}]+#{key - dice} #{current_text}"
    else
      current_text = "1D6[#{dice}] #{current_text}"
    end

    if text.empty?
      text = current_text
    else
      text = "#{text} => #{current_text}"
    end

    unless add
      text += " [合計:儀式点 +#{total_bonus} ]"
      return text
    end
  end
end