class BCDice::GameSystem::DarkSouls

Constants

HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

NAME

ゲームシステム名

SORT_KEY

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

Public Instance Methods

checkRoll(diceCount, isActive, modify, target) click to toggle source
# File lib/bcdice/game_system/DarkSouls.rb, line 43
def checkRoll(diceCount, isActive, modify, target)
  dice_list = @randomizer.roll_barabara(diceCount, 6)
  dice = dice_list.sum()
  diceText = dice_list.join(",")

  successValue = dice + modify
  modifyText = getValueText(modify)
  targetText = (target == 0 ? '' : ">=#{target}")

  if isActive
    diceArray = diceText.split(/,/).map(&:to_i)
    focusDamage = diceArray.count { |i| i == 1 }

    if focusDamage > 0
      focusText = "■" * focusDamage
      focusText = "(FP#{focusText}消費)"
    end
  end

  result = "(#{diceCount}D6#{modifyText}#{targetText})"
  result += " > #{dice}(#{diceText})#{modifyText}"
  result += " > #{successValue}#{targetText}"

  if target > 0
    if  successValue >= target
      result += " > 【成功】"
    else
      result += " > 【失敗】"
    end
  end

  result += focusText.to_s
  return result
end
eval_game_system_specific_command(command) click to toggle source
# File lib/bcdice/game_system/DarkSouls.rb, line 30
def eval_game_system_specific_command(command)
  return nil unless (m = /(\d+)?(A)?DS([-+\d]*)(@(\d+))?$/i.match(command.upcase))

  diceCount = (m[1] || 2).to_i
  isActive = !m[2].nil?
  modify = getValue(m[3])
  target = (m[5] || 0).to_i

  output = checkRoll(diceCount, isActive, modify, target)

  return output
end
getValue(text) click to toggle source
# File lib/bcdice/game_system/DarkSouls.rb, line 78
def getValue(text)
  text ||= ""
  return ArithmeticEvaluator.eval(text)
end
getValueText(value) click to toggle source
# File lib/bcdice/game_system/DarkSouls.rb, line 83
def getValueText(value)
  return "" if value == 0
  return value.to_s if value < 0

  return "\+#{value}"
end