Class: BCDice::GameSystem::ZettaiReido

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'ZettaiReido'
NAME =

ゲームシステム名

'絶対隷奴'
SORT_KEY =

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

'せつたいれいと'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定
  m-2DR+n>=x
  m(基本能力),n(修正値),x(目標値)
  DPの取得の有無も表示されます。
INFO_MESSAGE_TEXT

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

#changeDiceToDarkDice(dice) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 75

def changeDiceToDarkDice(dice)
  darkPoint = 0
  darkDice = dice
  if dice == 6
    darkDice = 0
    darkPoint = 1
  end

  return darkDice, darkPoint
end

#eval_game_system_specific_command(command) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 25

def eval_game_system_specific_command(command)
  return nil unless command =~ /^(\d+)-2DR([+\-\d]*)(>=(\d+))?$/i

  baseAvility = Regexp.last_match(1).to_i
  modText = Regexp.last_match(2)
  diffValue = Regexp.last_match(4)

  return roll2DR(baseAvility, modText, diffValue)
end

#getDarkPointResult(_total, _diff, darkPoint) ⇒ Object



110
111
112
113
114
115
116
117
118
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 110

def getDarkPointResult(_total, _diff, darkPoint)
  text = ''

  if darkPoint > 0
    text = "#{darkPoint}DP"
  end

  return text
end

#getDiffInfo(diffValue) ⇒ Object



99
100
101
102
103
104
105
106
107
108
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 99

def getDiffInfo(diffValue)
  diffText = ""

  unless diffValue.nil?
    diffValue = diffValue.to_i
    diffText = ">=#{diffValue.to_i}"
  end

  return diffValue, diffText
end

#getModInfo(modText) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 86

def getModInfo(modText)
  value = ArithmeticEvaluator.eval(modText)

  text = ""
  if value < 0
    text = value.to_s
  elsif  value > 0
    text = "+" + value.to_s
  end

  return value, text
end

#getSuccessText(diceTotal, total, diff) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 120

def getSuccessText(diceTotal, total, diff)
  if diceTotal == 0
    return " > クリティカル"
  end

  if diceTotal == 10
    return " > ファンブル"
  end

  if diff.nil?
    diff = 0
  end

  successLevel = (total - diff)
  if successLevel >= 0
    return "#{successLevel} 成功"
  end

  return ' > 失敗'
end

#roll2DarkDiceObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 57

def roll2DarkDice()
  dice1 = @randomizer.roll_once(6)
  dice2 = @randomizer.roll_once(6)

  darkDice1, darkPoint1 = changeDiceToDarkDice(dice1)
  darkDice2, darkPoint2 = changeDiceToDarkDice(dice2)

  darkPoint = darkPoint1 + darkPoint2
  if darkPoint == 2
    darkPoint = 4
  end

  darkTotal = darkDice1 + darkDice2
  darkDiceText = "#{darkDice1},#{darkDice2}"

  return darkTotal, darkDiceText, darkPoint
end

#roll2DR(baseAvility, modText, diffValue) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 35

def roll2DR(baseAvility, modText, diffValue)
  diceTotal, diceText, darkPoint = roll2DarkDice()

  mod, modText = getModInfo(modText)
  diff, diffText = getDiffInfo(diffValue)

  output = ""
  output += "(#{baseAvility}-2DR#{modText}#{diffText})"
  output += "#{baseAvility}-#{diceTotal}[#{diceText}]#{modText}"

  total = baseAvility - diceTotal + mod
  output += "#{total}"

  successText = getSuccessText(diceTotal, total, diff)
  output += successText

  darkPointText = getDarkPointResult(total, diff, darkPoint)
  output += darkPointText

  return output
end