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



80
81
82
83
84
85
86
87
88
89
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 80

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



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

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

#getDiffInfo(diffValue) ⇒ Object



104
105
106
107
108
109
110
111
112
113
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 104

def getDiffInfo(diffValue)
  diffText = ""

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

  return diffValue, diffText
end

#getModInfo(modText) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 91

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

#getResult(diceTotal, total, diff) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 115

def getResult(diceTotal, total, diff)
  if diceTotal == 0
    return Result.critical("クリティカル")
  end

  if diceTotal == 10
    return Result.fumble("ファンブル")
  end

  if diff.nil?
    diff = 0
  end

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

  return Result.failure("失敗")
end

#roll2DarkDiceObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/bcdice/game_system/ZettaiReido.rb', line 62

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



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

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

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

  baseCommandText = "(#{baseAvility}-2DR#{modText}#{diffText})"
  diceCommandText = "#{baseAvility}-#{diceTotal}[#{diceText}]#{modText}"
  total = baseAvility - diceTotal + mod

  result = getResult(diceTotal, total, diff)

  darkPointText = "#{darkPoint}DP" if darkPoint > 0

  result.text = [
    baseCommandText,
    diceCommandText,
    total.to_i,
    result.text,
    darkPointText,
  ].compact.join("")

  return result
end