Class: BCDice::GameSystem::Utakaze

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'Utakaze'
NAME =

ゲームシステム名

'ウタカゼ'
SORT_KEY =

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

'うたかせ'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  ・行為判定ロール(nUK)
    n個のサイコロで行為判定ロール。ゾロ目の最大個数を成功レベルとして表示。nを省略すると2UK扱い。
    例)3UK :サイコロ3個で行為判定
    例)UK  :サイコロ2個で行為判定
    不等号用いた成否判定は現時点では実装してません。
  ・クリティカルコール付き行為判定ロール(nUK@c or nUKc)
   cに「龍のダイス目」を指定した行為判定ロール。
    ゾロ目ではなく、cと同じ値の出目数x2が成功レベルとなります。
    例)3UK@5 :龍のダイス「月」でクリティカルコール宣言したサイコロ3個の行為判定
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) ⇒ Utakaze

Returns a new instance of Utakaze.



30
31
32
33
34
# File 'lib/bcdice/game_system/Utakaze.rb', line 30

def initialize(command)
  super(command)
  @arrayDragonDiceName = ['', '', '', '', '', '', '']
  @enabled_upcase_input = false
end

Instance Method Details

#checkRoll(base, crit, diff = 0) ⇒ Object



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

def checkRoll(base, crit, diff = 0)
  result = ""

  base = getValue(base)
  crit = getValue(crit)

  return result if base < 1

  crit = 6 if crit > 6

  result += "(#{base}d6)"

  diceList = @randomizer.roll_barabara(base, 6).sort

  result += " > [#{diceList.join(',')}] > "
  result += getRollResultString(diceList, crit, diff)

  return result
end

#eval_game_system_specific_command(command) ⇒ Object



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

def eval_game_system_specific_command(command)
  debug('eval_game_system_specific_command command', command)

  result = ''

  case command
  when /(\d+)?UK(@?(\d))?(>=(\d+))?/i
    base = (Regexp.last_match(1) || 2).to_i
    crit = Regexp.last_match(3).to_i
    diff = Regexp.last_match(5).to_i
    result = checkRoll(base, crit, diff)
  end

  return nil if result.empty?

  return "#{command}#{result}"
end

#getDiceCountHash(dice_list, critical) ⇒ Object

各ダイスの個数を数えてHashにする



131
132
133
134
135
136
# File 'lib/bcdice/game_system/Utakaze.rb', line 131

def getDiceCountHash(dice_list, critical)
  dice_list
    .select { |dice| isNomalDice(critical) || dice == critical }
    .group_by(&:itself)
    .transform_values(&:size)
end

#getRollResultString(diceList, crit, diff) ⇒ Object



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

def getRollResultString(diceList, crit, diff)
  success, maxnum, setCount = getSuccessInfo(diceList, crit, diff)

  result = ""

  if isDragonDice(crit)
    result += "龍のダイス「#{@arrayDragonDiceName[crit]}」(#{crit})を使用 > "
  end

  if  success
    result += "成功レベル:#{maxnum} (#{setCount}セット)"
    if diff != 0
      diffSuccess = (maxnum >= diff)
      if diffSuccess
        result += " > 成功"
      else
        result += " > 失敗"
      end
    end

  else
    result += "失敗"
  end

  return result
end

#getSuccessInfo(diceList, crit, _diff) ⇒ Object



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
126
127
128
# File 'lib/bcdice/game_system/Utakaze.rb', line 101

def getSuccessInfo(diceList, crit, _diff)
  debug("checkSuccess diceList, crit", diceList, crit)

  diceCountHash = getDiceCountHash(diceList, crit)
  debug("diceCountHash", diceCountHash)

  maxnum = 0
  successDiceList = []
  countThreshold = (isDragonDice(crit) ? 1 : 2)

  diceCountHash.each do |dice, count|
    maxnum = count if  count > maxnum
    successDiceList << dice if count >= countThreshold
  end

  debug("successDiceList", successDiceList)

  if successDiceList.size <= 0
    # 失敗:ゾロ目無し(全部違う)
    return false, 0, 0
  end

  # 竜のダイスの場合
  maxnum *= 2 if isDragonDice(crit)

  # 成功:ゾロ目あり
  return true, maxnum, successDiceList.size
end

#getValue(number) ⇒ Object



146
147
148
149
150
# File 'lib/bcdice/game_system/Utakaze.rb', line 146

def getValue(number)
  return 0 if number > 100

  return number
end

#isDragonDice(crit) ⇒ Object



142
143
144
# File 'lib/bcdice/game_system/Utakaze.rb', line 142

def isDragonDice(crit)
  (crit != 0)
end

#isNomalDice(crit) ⇒ Object



138
139
140
# File 'lib/bcdice/game_system/Utakaze.rb', line 138

def isNomalDice(crit)
  !isDragonDice(crit)
end