class BCDice::GameSystem::HouraiGakuen

Constants

CRITICAL
FAILURE
FUMBLE
HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

NAME

ゲームシステム名

SORT_KEY

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

SUCCESS

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source

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

# 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) click to toggle source
# 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) click to toggle source
# 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
getGogyouTable() click to toggle source

五行コマンド

# File lib/bcdice/game_system/HouraiGakuen.rb, line 257
def getGogyouTable
  table = [
    '五行【木】',
    '五行【火】',
    '五行【土】',
    '五行【金】',
    '五行【水】',
    '五行は【任意選択】',
  ]
  return table
end
getHattokuResult(_command) click to toggle source

八徳コマンド

# 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) click to toggle source

陰陽コマンド

# 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) click to toggle source

対人ロール

# 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
getOddEven() click to toggle source
# File lib/bcdice/game_system/HouraiGakuen.rb, line 238
def getOddEven
  dice = @randomizer.roll_once(6)

  return "偶数" if dice.even?

  return "奇数"
end
getResResult(command) click to toggle source

対抗ロール

# 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
getResistCheckResult(yourResult, enemyResult) click to toggle source
# 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
getResultRank(result) click to toggle source
# File lib/bcdice/game_system/HouraiGakuen.rb, line 173
def getResultRank(result)
  ranks = [
    FUMBLE,
    FAILURE,
    SUCCESS,
    CRITICAL,
  ]

  return ranks.index(result)
end
getRollResult(command) click to toggle source

基本ロール

# 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) click to toggle source
# File lib/bcdice/game_system/HouraiGakuen.rb, line 124
def getTargetFromValue(yourValue, enemyValue)
  yourValue + (10 - enemyValue) # 値から目標値を作出
end
isCritical(diceList) click to toggle source
# File lib/bcdice/game_system/HouraiGakuen.rb, line 103
def isCritical(diceList)
  return diceList == [1, 2, 3]
end
isFamble(diceList) click to toggle source
# File lib/bcdice/game_system/HouraiGakuen.rb, line 99
def isFamble(diceList)
  return diceList == [6, 6, 6]
end