Class: BCDice::GameSystem::Raisondetre

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'Raisondetre'
NAME =

ゲームシステム名

'叛逆レゾンデートル'
SORT_KEY =

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

'はんきやくれそんてとおる'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  判定:[判定値]RD[技能][@目標値]
  ダメージロール:[ダイス数]DD[装甲]

  []内のコマンドは省略可能。
  「判定値」で判定に使用するダイス数を指定。省略時は「1」。0以下も指定可。
  「技能」で有効なダイス数を指定。省略時は「1」。
  達成値はクリティカルを含めて、「最も高くなる」ように計算します。
  「@目標値」指定で、判定の成否を追加表示します。

  ダメージロールは[装甲]指定で、有効なダイス数と0の出目の数を表示します。
  [装甲]省略時は、ダイス結果のみ表示します。(複数の対象への攻撃時用)

  【書式例】
  ・RD → 1Dで達成値を表示。
  ・2RD1@8 → 2D(1個選択)で目標値8の判定。
  ・-3RD → 1Dでダイスペナルティ-4の判定。
  ・4DD2 → 4Dで装甲2のダメージロール。
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, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

#initialize(command) ⇒ Raisondetre

Returns a new instance of Raisondetre.



36
37
38
39
# File 'lib/bcdice/game_system/Raisondetre.rb', line 36

def initialize(command)
  super(command)
  @sort_add_dice = true # ダイスのソート有
end

Instance Method Details

#checkDamage(diceCount, armor) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/bcdice/game_system/Raisondetre.rb', line 127

def checkDamage(diceCount, armor)
  if diceCount <= 0
    correction = 1 + diceCount * -1
    rollCount = 1
  else
    correction = 0
    rollCount = diceCount
  end

  dice_list = @randomizer.roll_barabara(rollCount, 10).sort
  diceText = dice_list.join(",")

  diceArray = dice_list.map { |x| x == 10 ? 0 : x }.sort
  criticalCount = diceArray.count(0)
  diceArray.map! { |i| i - correction }
  diceText2 = diceArray.join(",")

  result = "#{rollCount}D10"
  result += "-#{correction}" if correction > 0
  result += " > [#{diceText}] > [#{diceText2}]"

  if armor > 0
    resultArray = []
    success = 0

    diceArray.each do |i|
      if i >= armor
        resultArray.push(i)
        success += 1
      else
        resultArray.push("×")
      end
    end
    resultText = resultArray.join(',')

    result += " > [#{resultText}]>=#{armor} 有効数:#{success}"
  end

  result += " 0=#{criticalCount}"

  return result
end

#checkRoll(diceCount, choiceCount, target) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/bcdice/game_system/Raisondetre.rb', line 72

def checkRoll(diceCount, choiceCount, target)
  if diceCount <= 0
    correction = 1 + diceCount * -1
    rollCount = 1
  else
    correction = 0
    rollCount = diceCount
  end

  diceArray = @randomizer.roll_barabara(rollCount, 10).sort
  diceText = diceArray.join(',')

  diceArray.map! { |x| x == 10 ? 0 : x }
  diceArray.map! { |i| i - correction }
  diceText2 = diceArray.sort.join(',')

  funbleArray = diceArray.select { |i| i <= 1 }
  isFunble = (funbleArray.size >= rollCount)

  dice = 0
  success = 0
  unless isFunble
    criticalCount = diceArray.count(0)
    critical = criticalCount * 10

    choiceArray = diceArray.reverse
    choiceArray.delete(0)
    choiceArray = choiceArray.slice(0..(choiceCount - 1))
    choiceText = choiceArray.join(',')
    dice = choiceArray.inject(:+)
    success = dice + critical
  end

  result = "#{rollCount}D10"
  result += "-#{correction}" if correction > 0
  result += " > [#{diceText}] > [#{diceText2}] > "

  if isFunble
    result += "達成値:0 (Funble)"
  else
    result += "#{dice}[#{choiceText}]"
    result += "+#{critical}" if critical > 0
    result += "=達成値:#{success}"
    result += " (#{criticalCount}Critical)" if critical > 0
  end

  if target > 0
    result += ">=#{target} "
    result += "【成功】" if  success >= target
    result += "【失敗】" if  success < target
  end

  return result
end

#eval_game_system_specific_command(command) ⇒ Object



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
# File 'lib/bcdice/game_system/Raisondetre.rb', line 46

def eval_game_system_specific_command(command)
  if command =~ /(-)?(\d+)?RD(\d+)?(@(\d+))?$/i
    diceCount = (Regexp.last_match(2) || 1).to_i
    diceCount *= -1 unless Regexp.last_match(1).nil?
    choiceCount = (Regexp.last_match(3) || 1).to_i
    target = (Regexp.last_match(5) || 0).to_i

    return checkRoll(diceCount, choiceCount, target)

  elsif command =~ /(-)?(\d+)?DD([1-9])?([+-]\d+)?$/i
    diceCount = (Regexp.last_match(2) || 1).to_i
    diceCount *= -1 unless Regexp.last_match(1).nil?
    armor = (Regexp.last_match(3) || 0).to_i
    if armor > 0
      armor += (Regexp.last_match(4) || 0).to_i
      armor = 1 if  armor < 1
      armor = 9 if  armor > 9
    end

    return checkDamage(diceCount, armor)

  end

  return nil
end