Class: BCDice::GameSystem::RecordOfSteam

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'RecordOfSteam'
NAME =

ゲームシステム名

'Record of Steam'
SORT_KEY =

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

'れこおとおふすちいむ'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  2S2@1
  RecordOfSteam : (2S2@1) > 1,2,3,4 > 1回転 > 成功数2

  4S3@2
  RecordOfSteam : (4S3@2) > 2,1,2,4,4,4,2,3,4,5,6,6 > 4回転 > 成功数5
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

#eval_game_system_specific_command(command) ⇒ Object

サンプルのダイスコマンドは「nSt@c」で n=ダイス個数, t=目標値, c=クリティカル値。@cのみ省略可



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 28

def eval_game_system_specific_command(command)
  unless /(\d+)[sS](\d+)(@(\d+))?/i =~ command
    return "1"
  end

  # $x の結果は正規表現マッチングすると新しい値に書き換わってしまうので、
  # マッチングした直後に変数に格納してしまうのが大事なポイント!
  diceCount = Regexp.last_match(1).to_i
  targetNumber = Regexp.last_match(2).to_i
  criticalValue = Regexp.last_match(4)
  criticalValue ||= 1
  criticalValue = criticalValue.to_i

  if diceCount >= 150
    return "(多分)無限個なので振れません! ヤメテクダサイ、(プロセスが)死んでしまいますっ"
  end

  if criticalValue >= 3
    return "(多分)無限個なので振れません! ヤメテクダサイ、(プロセスが)死んでしまいますっ"
  end

  specialValue = criticalValue

  rollResult, successCount, roundCount, specialCount, fumbleCount = getDiceRollResult(diceCount, targetNumber, criticalValue, specialValue)

  output = "(#{command}) > #{rollResult}"

  roundCountText = getRoundCountText(roundCount)
  successText = getSuccessText(successCount)
  specialText = getSpecialText(specialCount)
  fumbleText = getFumbleText(fumbleCount)

  result = "#{output}#{roundCountText}#{specialText}#{successText}#{fumbleText}"

  return result
end

#getDiceRollResult(diceCount, targetNumber, criticalValue, specialValue) ⇒ Object



65
66
67
68
69
70
71
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
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 65

def getDiceRollResult(diceCount, targetNumber, criticalValue, specialValue)
  successCount = 0
  roundCount = 0
  rollResult = ""
  specialCount = 0
  specialFlag = false
  fumbleCount = 0
  fumbleFlag = false

  while diceCount > 0
    diceList = @randomizer.roll_barabara(diceCount, 6)
    diceListText = diceList.join(",")

    rollResult += "," if rollResult != ""
    rollResult += diceListText

    if diceList.uniq.length == 1 && roundCount == 0
      if diceList.uniq.first <= specialValue
        specialFlag = true
      elsif diceList.uniq.first == 6
        fumbleFlag = true
      end
    end
    debug("diceList", diceList)

    if specialFlag
      specialCount = 1
      successCount = diceCount * 3

      return rollResult, successCount, roundCount, specialCount, fumbleCount
    elsif fumbleFlag
      fumbleCount = 1

      return rollResult, successCount, roundCount, specialCount, fumbleCount
    end

    diceCount = 0

    diceList.map do |diceValue|
      debug("diceValue", diceValue)
      debug("criticalValue", criticalValue)
      debug("specialValue", specialValue)

      if diceValue <= criticalValue
        diceCount += 2
        roundCount += 1
      end

      successCount += 1 if diceValue <= targetNumber
    end
  end

  return rollResult, successCount, roundCount, specialCount, fumbleCount
end

#getFumbleText(fumbleCount) ⇒ Object



142
143
144
145
146
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 142

def getFumbleText(fumbleCount)
  if fumbleCount == 1
    return " > ファンブル"
  end
end

#getRoundCountText(roundCount) ⇒ Object



120
121
122
123
124
125
126
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 120

def getRoundCountText(roundCount)
  if roundCount <= 0
    return ""
  end

  return "#{roundCount}回転"
end

#getSpecialText(specialCount) ⇒ Object



136
137
138
139
140
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 136

def getSpecialText(specialCount)
  if specialCount == 1
    return " > スペシャル"
  end
end

#getSuccessText(successCount) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/bcdice/game_system/RecordOfSteam.rb', line 128

def getSuccessText(successCount)
  if successCount > 0
    return " > 成功数#{successCount}"
  end

  return " > 失敗"
end