Class: BCDice::GameSystem::HouraiGakuen

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'HouraiGakuen'
NAME =

ゲームシステム名

'蓬莱学園の冒険!!'
SORT_KEY =

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

'ほうらいかくえんのほうけん'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・基本ロール:ROL(x+n)
    ROLL(自分の能力値 + 簡単値 + 応石 or 蓬莱パワー)と記述します。3D6をロールし、成功したかどうかを表示します。
    例)ROL(4+6)
  ・対人判定:MED(x,y)
    自分の能力値 x と 相手の能力値 y でロールを行い、成功したかどうかを表示します。
    例)MED(5,2)
  ・対抗判定:RES(x,y)
    自分の能力値 x と 相手の能力値 y で相互にロールし、どちらが成功したかを表示します。両者とも成功 or 失敗の場合は引き分けとなります。
    例)RES(6,4)
  ・陰陽コマンド INY
    例)Hourai : 陽(奇数の方が多い)
  ・五行コマンド:GOG
    例)Hourai : 五行表(3) → 五行【土】
  ・八徳コマンド:HTK
    例)Hourai : 仁義八徳は、【義】(奇数、奇数、偶数)
INFO_MESSAGE_TEXT
CRITICAL =
"大成功"
SUCCESS =
"成功"
FAILURE =
"失敗"
FUMBLE =
"大失敗"

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

ゲームの名前 チャット欄表示名 判定用前置文字 説明文 コマンド分岐



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 41

def eval_game_system_specific_command(command)
  case command
  when /^ROL/i
    return getRollResult(command)
  when /^MED/i
    return getMedResult(command)
  when /^RES/i
    return getResResult(command)
  when /^INY/i
    return getInnyouResult(command)
  when /^HTK/i
    return getHattokuResult(command)
  when /^GOG$/i
    return getGogyouResult(command)
  end

  return nil
end

#getCheckResult(diceList, total, target) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 81

def getCheckResult(diceList, total, target)
  diceList = diceList.sort

  if isFamble(diceList)
    return FUMBLE
  end

  if isCritical(diceList)
    return CRITICAL
  end

  if total <= target
    return SUCCESS
  end

  return FAILURE
end

#getGogyouResult(_command) ⇒ Object



246
247
248
249
250
251
252
253
254
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 246

def getGogyouResult(_command)
  type = '五行表'

  table = getGogyouTable
  text, number = get_table_by_1d6(table)

  output = "#{type}(#{number}) > #{text}"
  return output
end

#getGogyouTableObject

五行コマンド



257
258
259
260
261
262
263
264
265
266
267
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 257

def getGogyouTable
  table = [
    '五行【木】',
    '五行【火】',
    '五行【土】',
    '五行【金】',
    '五行【水】',
    '五行は【任意選択】',
  ]
  return table
end

#getHattokuResult(_command) ⇒ Object

八徳コマンド



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
233
234
235
236
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 207

def getHattokuResult(_command)
  # 3回振って、奇数・偶数がどの順序で出たかを記録する
  oddEvenList = []
  3.times do
    oddEvenList << getOddEven
  end

  oddEvenText = oddEvenList.join("")

  case oddEvenText
  when "奇数、奇数、奇数"
    return "仁義八徳は、【仁】(#{oddEvenText})"
  when "奇数、奇数、偶数"
    return "仁義八徳は、【義】(#{oddEvenText})"
  when "奇数、偶数、奇数"
    return "仁義八徳は、【礼】(#{oddEvenText})"
  when "奇数、偶数、偶数"
    return "仁義八徳は、【智】(#{oddEvenText})"
  when "偶数、奇数、奇数"
    return "仁義八徳は、【忠】(#{oddEvenText})"
  when "偶数、奇数、偶数"
    return "仁義八徳は、【信】(#{oddEvenText})"
  when "偶数、偶数、奇数"
    return "仁義八徳は、【孝】(#{oddEvenText})"
  when "偶数、偶数、偶数"
    return "仁義八徳は、【悌】(#{oddEvenText})"
  else
    return "異常終了"
  end
end

#getInnyouResult(_command) ⇒ Object

陰陽コマンド



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 185

def getInnyouResult(_command)
  oddCount = 0
  evenCount = 0

  3.times do
    dice = @randomizer.roll_once(6)

    if dice.even?
      evenCount += 1 # 偶数カウント
    else
      oddCount += 1 # 奇数カウント
    end
  end

  if evenCount < oddCount
    return "陽(奇数の方が多い)"
  else
    return "陰(偶数の方が多い)"
  end
end

#getMedResult(command) ⇒ Object

対人ロール



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 108

def getMedResult(command)
  return nil unless /med\((\d+),(\d+)\)/i =~ command

  yourValue = Regexp.last_match(1).to_i # あなたの値
  enemyValue = Regexp.last_match(2).to_i # 相手の値
  target = getTargetFromValue(yourValue, enemyValue) # 値から目標値を作出

  dice_list = @randomizer.roll_barabara(3, 6)
  total = dice_list.sum()
  diceText = dice_list.join(",")

  result = getCheckResult(dice_list, total, target)

  return "(あなたの値#{yourValue}、相手の値#{enemyValue}、3d6<=#{target}) > 出目#{diceText}=合計#{total}#{result}"
end

#getOddEvenObject



238
239
240
241
242
243
244
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 238

def getOddEven
  dice = @randomizer.roll_once(6)

  return "偶数" if dice.even?

  return "奇数"
end

#getResistCheckResult(yourResult, enemyResult) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 158

def getResistCheckResult(yourResult, enemyResult)
  yourRank = getResultRank(yourResult)
  enemyRank = getResultRank(enemyResult)

  if yourRank > enemyRank
    return "あなたが勝利"
  end

  if yourRank < enemyRank
    return "相手が勝利"
  end

  return "引き分け"
end

#getResResult(command) ⇒ Object

対抗ロール



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

def getResResult(command)
  return nil unless /res\((\d+),(\d+)\)/i =~ command

  yourValue = Regexp.last_match(1).to_i # あなたの値
  enemyValue = Regexp.last_match(2).to_i # 相手の値

  # 値から目標値を作出
  yourTarget = getTargetFromValue(yourValue, enemyValue)
  enemyTarget = getTargetFromValue(enemyValue, yourValue)

  your_dice_list = @randomizer.roll_barabara(3, 6)
  yourTotal = your_dice_list.sum()
  yourDiceText = your_dice_list.join(",")

  enemy_dice_list = @randomizer.roll_barabara(3, 6)
  enemyTotal = enemy_dice_list.sum()
  enemyDiceText = enemy_dice_list.join(",")

  yourResult = getCheckResult(your_dice_list, yourTotal, yourTarget)
  enemyResult = getCheckResult(enemy_dice_list, enemyTotal, enemyTarget)

  result = getResistCheckResult(yourResult, enemyResult)

  return "あなたの値#{yourValue}、相手の値#{enemyValue}
(あなたのロール 3d6<=#{yourTarget}) > #{yourDiceText}=#{yourTotal}#{yourResult}
(相手のロール 3d6<=#{enemyTarget}) > #{enemyDiceText}=#{enemyTotal}#{enemyResult}#{result}"
end

#getResultRank(result) ⇒ Object



173
174
175
176
177
178
179
180
181
182
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 173

def getResultRank(result)
  ranks = [
    FUMBLE,
    FAILURE,
    SUCCESS,
    CRITICAL,
  ]

  return ranks.index(result)
end

#getRollResult(command) ⇒ Object

基本ロール



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 66

def getRollResult(command)
  return nil unless /rol([-\d]+)/i =~ command

  # 目標値セット
  target = Regexp.last_match(1).to_i

  dice_list = @randomizer.roll_barabara(3, 6)
  total = dice_list.sum()
  diceText = dice_list.join(",")

  result = getCheckResult(dice_list, total, target)

  return "(3d6<=#{target}) > 出目#{diceText}=合計#{total}#{result}"
end

#getTargetFromValue(yourValue, enemyValue) ⇒ Object



124
125
126
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 124

def getTargetFromValue(yourValue, enemyValue)
  yourValue + (10 - enemyValue) # 値から目標値を作出
end

#isCritical(diceList) ⇒ Object



103
104
105
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 103

def isCritical(diceList)
  return diceList == [1, 2, 3]
end

#isFamble(diceList) ⇒ Object



99
100
101
# File 'lib/bcdice/game_system/HouraiGakuen.rb', line 99

def isFamble(diceList)
  return diceList == [6, 6, 6]
end