Class: BCDice::GameSystem::HatsuneMiku

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

Direct Known Subclasses

HatsuneMiku_Korean

Constant Summary collapse

ID =

ゲームシステムの識別子

'HatsuneMiku'
NAME =

ゲームシステム名

'初音ミクTRPG ココロダンジョン'
SORT_KEY =

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

'はつねみくTRPGこころたんしよん'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定(Rx±y@z>=t)
   能力値のダイスごとに成功・失敗の判定を行います。
   x:能力ランク(S,A~D)。数字指定で直接その個数のダイスが振れます
   y:修正値。A+2 あるいは A++ のように表記。混在時は A++,+1 のように記述も可能
   z:スペシャル最低値(省略:6) t:目標値(省略:4)
    例) RA R2 RB+1 RC++ RD+,+2 RA>=5 RS-1@5>=6
   結果はネイロを取得した残りで最大値を表示
  例) RB
   HatsuneMiku : (RB>=4) > [3,5] >
    ネイロに3(青)を取得した場合 5:成功
    ネイロに5(白)を取得した場合 3:失敗
  ・各種表
   ファンブル表 FT/致命傷表 CWT/休憩表 BT/目標表 TT/関係表 RT
   障害表 OT/リクエスト表 RQT/クロウル表 CLT/報酬表 RWT/悪夢表 NMT/情景表 ST
  ・キーワード表
   ダーク DKT/ホット HKT/ラブ LKT/エキセントリック EKT/メランコリー MKT
  ・名前表 NT
   コア別 ダーク DNT/ホット HNT/ラブ LNT/エキセントリック ENT/メランコリー MNT
  ・オトダマ各種表
   性格表A OPA/性格表B OPB/趣味表 OHT/外見表 OLT/一人称表 OIT/呼び名表 OYT
   リアクション表 ORT/出会い表 OMT
INFO_MESSAGE_TEXT
TABLES =
translate_tables(:ja_jp).freeze

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) ⇒ HatsuneMiku

Returns a new instance of HatsuneMiku.



40
41
42
43
44
# File 'lib/bcdice/game_system/HatsuneMiku.rb', line 40

def initialize(command)
  super(command)

  @d66_sort_type = D66SortType::ASC
end

Instance Method Details

#check_success(total_n, dice_n, signOfInequality, diff, special_n) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/bcdice/game_system/HatsuneMiku.rb', line 135

def check_success(total_n, dice_n, signOfInequality, diff, special_n)
  return translate('fumble') if dice_n == 1
  return translate('HatsuneMiku.special') if dice_n >= special_n

  cmp_op = Normalize.comparison_operator(signOfInequality)
  target_num = diff.to_i

  if total_n.send(cmp_op, target_num)
    translate('success')
  else
    translate('failure')
  end
end

#eval_game_system_specific_command(command) ⇒ Object



46
47
48
49
50
51
# File 'lib/bcdice/game_system/HatsuneMiku.rb', line 46

def eval_game_system_specific_command(command)
  text = judgeRoll(command)
  return text unless text.nil?

  return roll_tables(command, self.class::TABLES)
end

#getChangedModifyText(text) ⇒ Object



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

def getChangedModifyText(text)
  modifyText = ""
  values = text.split(/,/)

  values.each do |value|
    case value
    when "++"
      modifyText += "+2"
    when "+"
      modifyText += "+1"
    else
      modifyText += value
    end
  end

  return modifyText
end

#judgeRoll(command) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
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
# File 'lib/bcdice/game_system/HatsuneMiku.rb', line 53

def judgeRoll(command)
  return nil unless /^(R([A-DS]|\d+)([+\-\d,]*))(@(\d))?((>(=)?)([+\-\d]*))?(@(\d))?$/i =~ command

  skillRank = Regexp.last_match(2)
  modifyText = Regexp.last_match(3)
  signOfInequality = (Regexp.last_match(7).nil? ? ">=" : Regexp.last_match(7))
  targetText = (Regexp.last_match(9).nil? ? "4" : Regexp.last_match(9))

  specialNum = Regexp.last_match(5)
  specialNum ||= Regexp.last_match(11)
  specialNum ||= 6
  specialNum = specialNum.to_i
  specialText = (specialNum == 6 ? "" : "@#{specialNum}")

  modifyText = getChangedModifyText(modifyText)

  commandText = "R#{skillRank}#{modifyText}"

  rankDiceList = {"S" => 4, "A" => 3, "B" => 2, "C" => 1, "D" => 2}
  diceCount = rankDiceList[skillRank]
  diceCount = skillRank.to_i if skillRank =~ /^\d+$/

  modify = ArithmeticEvaluator.eval(modifyText)
  target = ArithmeticEvaluator.eval(targetText)

  diceList = @randomizer.roll_barabara(diceCount, 6).sort
  diceText = diceList.join(",")

  diceList = [diceList.min] if skillRank == "D"

  message = "(#{commandText}#{specialText}#{signOfInequality}#{targetText}) > [#{diceText}]#{modifyText}"

  if diceList.length <= 1
    dice = diceList.first
    total = dice + modify
    result = check_success(total, dice, signOfInequality, target, specialNum)
    message += "#{total}:#{result}"
  else
    texts = []
    diceList.each_with_index do |pickup_dice, index|
      rests = diceList.clone
      rests.delete_at(index)
      dice = rests.max
      total = dice + modify
      result = check_success(total, dice, signOfInequality, target, specialNum)

      colorList = [
        translate('HatsuneMiku.color_black'),
        translate('HatsuneMiku.color_red'),
        translate('HatsuneMiku.color_blue'),
        translate('HatsuneMiku.color_green'),
        translate('HatsuneMiku.color_white'),
        translate('HatsuneMiku.color_any'),
      ]
      color = colorList[pickup_dice - 1]
      texts << translate('HatsuneMiku.neiro_acquire', pickup_dice: pickup_dice, color: color, total: total, result: result)
    end
    texts.uniq!
    message += "\n" + texts.join("\n")
  end

  return message
end