lib/bcdice/game_system/DiceOfTheDead.rb
# frozen_string_literal: true
module BCDice
module GameSystem
class DiceOfTheDead < Base
# ゲームシステムの識別子
ID = 'DiceOfTheDead'
# ゲームシステム名
NAME = 'ダイス・オブ・ザ・デッド'
# ゲームシステム名の読みがな
SORT_KEY = 'たいすおふさてつと'
# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
・ゾンビ化表 ZMB+x
(x=オープン中の感染度マスの数。+xは省略可能、省略時は0)
・感染度表 BIOx
(xは被弾回数。xは省略可能、省略時は1)
(上記二つは最初からシークレットダイスで行われます)
INFO_MESSAGE_TEXT
register_prefix('ZMB', 'BIO')
def initialize(command)
super(command)
@sort_add_dice = true
@d66_sort_type = D66SortType::ASC
end
def eval_game_system_specific_command(command)
case command
when /^BIO(\d+)?$/
roll_times = (Regexp.last_match(1) || 1).to_i
Result.new.tap do |r|
r.secret = true
r.text = checkInfection(roll_times)
end
when /^ZMB(\+(\d+))?$/
value = Regexp.last_match(2).to_i
Result.new.tap do |r|
r.secret = true
r.text = rollZombie(value)
end
end
end
def checkInfection(roll_times)
result = "感染度表"
roll_times.times do
d1 = @randomizer.roll_once(6)
d2 = @randomizer.roll_once(6)
result += " > 出目:#{d1}、#{d2} "
index1 = (d1 / 2.0).ceil - 1
index2 = (d2 / 2.0).ceil - 1
table =
[["「右下(【足】+1)」", "「右中(【足】+1)」", "「右上(【足】+1)」"],
["「中下(【腕】+1)」", "「真中(【腕】+1)」", "「中上(【腕】+1)」"],
["「左下(【頭】+1)」", "「左中(【頭】+1)」", "「左上(【頭】+1)」"],]
result += table[index1][index2]
end
return result
end
####################
# 各種表
def rollZombie(value)
d1 = @randomizer.roll_once(6)
d2 = @randomizer.roll_once(6)
diceTotal = d1 + d2 + value
table = [
[5, "5以下:影響なし"],
[6, "6:任意の部位を1点回復"],
[7, "7:〈アイテム〉武器を1つその場に落とす"],
[8, "8:〈アイテム〉便利道具1つをその場に落とす"],
[9, "9:〈アイテム〉消耗品1つをその場に落とす"],
[10, "10:腕の傷が広がる。「部位:【腕】」1点ダメージ"],
[11, "11:足の傷が広がる。「部位:【足】」1点ダメージ"],
[12, "12:頭の傷が広がる。「部位:【頭】」1点ダメージ"],
[13, "13:【ゾンビ化表】が新たに適用されるまで「【感染度】+1マス」の効果を受ける"],
[14, "14:即座に自分以外の味方1人のスロット内の〈アイテム〉1つをランダムに捨てさせる"],
[15, "15:味方1人に素手で攻撃を行う"],
[16, "16:即座に感染度が1上昇する"],
[17, "17:次のターンのみ、すべての【能力値】を2倍にする"],
[18, "18以上:自分以外の味方1人にできる限り全力で攻撃を行う。〈アイテム〉も可能な限り使用する"]
]
minDice = table.first.first
maxDice = table.last.first
index = diceTotal
index = [minDice, index].max
index = [index, maxDice].min
_number, text = table.assoc(index)
result = "ゾンビ化表 > 出目:#{d1}+#{d2} 感染度:#{value} 合計値:#{diceTotal} > #{text}"
return result
end
end
end
end