Class: BCDice::GameSystem::DarkSouls

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'DarkSouls'
NAME =

ゲームシステム名

'ダークソウルTRPG'
SORT_KEY =

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

'たあくそうるTRPG'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  ・行為判定:[n]DS[a±b][@t]  []内のコマンドは省略可
  ・能動判定:[n]ADS[a±b][@t]  FP消費を判定
   n:ダイス数。省略時は「2」
   a±b:修正値。「1+2-1」のように、複数定可
   @t:目標値。省略時は達成値を、指定時は判定の正否を表示
  例)DS → 2D6の達成値を表示
    1DS → 1D6の達成値を表示
    ADS+2-2 → 2D6+2の達成値を表示(能動判定)
    DS+2@10 → 2D6+2で目標値10の判定
MESSAGETEXT

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

#checkRoll(diceCount, isActive, modify, target) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# 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) ⇒ Object



78
79
80
81
# File 'lib/bcdice/game_system/DarkSouls.rb', line 78

def getValue(text)
  text ||= ""
  return ArithmeticEvaluator.eval(text)
end

#getValueText(value) ⇒ Object



83
84
85
86
87
88
# 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