Class: BCDice::GameSystem::Amadeus

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

Direct Known Subclasses

Amadeus_Korean

Constant Summary collapse

ID =

ゲームシステムの識別子

'Amadeus'
NAME =

ゲームシステム名

'アマデウス'
SORT_KEY =

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

'あまてうす'
HELP_MESSAGE =

ダイスボットの使い方

"\u30FB\u5224\u5B9A(Rx\u00B1y@z>=t)\n\u3000\u80FD\u529B\u5024\u306E\u30C0\u30A4\u30B9\u3054\u3068\u306B\u6210\u529F\u30FB\u5931\u6557\u306E\u5224\u5B9A\u3092\u884C\u3044\u307E\u3059\u3002\n\u3000x\uFF1A\u80FD\u529B\u30E9\u30F3\u30AF(S,A\uFF5ED)\u3000y\uFF1A\u4FEE\u6B63\u5024\uFF08\u7701\u7565\u53EF\uFF09\n\u3000z\uFF1A\u30B9\u30DA\u30B7\u30E3\u30EB\u6700\u4F4E\u5024\uFF08\u7701\u7565\uFF1A6\uFF09\u3000t\uFF1A\u76EE\u6A19\u5024\uFF08\u7701\u7565\uFF1A4\uFF09\n\u3000\u3000\u4F8B\uFF09 RA\u3000RB-1\u3000RC>=5\u3000RD+2\u3000RS-1@5>=6\n\u3000\u51FA\u529B\u66F8\u5F0F\u306F\n\u3000\u3000(\u9054\u6210\u5024)_(\u5224\u5B9A\u7D50\u679C)[(\u51FA\u76EE)(\u5BFE\u5FDC\u3059\u308B\u30A4\u30F3\u30AC)]\n\u3000C,D\u30E9\u30F3\u30AF\u3067\u306F\u5BFE\u5FDC\u3059\u308B\u30A4\u30F3\u30AC\u306F\u51FA\u529B\u3055\u308C\u307E\u305B\u3093\u3002\n\u3000\u3000\u51FA\u529B\u4F8B)\u30002_\u30D5\u30A1\u30F3\u30D6\u30EB\uFF01[1\u9ED2] / 3_\u5931\u6557[3\u9752]\n\u30FB\u5404\u7A2E\u8868\n\u3000\u5883\u9047\u8868 ECT\uFF0F\u95A2\u4FC2\u8868 RT\uFF0F\u89AA\u5FC3\u8868 PRT\uFF0F\u6226\u5834\u8868 BST\uFF0F\u4F11\u61A9\u8868 BT\uFF0F\n\u3000\u30D5\u30A1\u30F3\u30D6\u30EB\u8868 FT\uFF0F\u81F4\u547D\u50B7\u8868 FWT\uFF0F\u6226\u679C\u8868 BRT\uFF0F\u30E9\u30F3\u30C0\u30E0\u30A2\u30A4\u30C6\u30E0\u8868 RIT\uFF0F\n\u3000\u640D\u50B7\u8868 WT\uFF0F\u60AA\u5922\u8868 NMT\uFF0F\u76EE\u6A19\u8868 TGT\uFF0F\u5236\u7D04\u8868 CST\uFF0F\n\u3000\u30E9\u30F3\u30C0\u30E0\u30AE\u30D5\u30C8\u8868 RGT\uFF0F\u6C7A\u6226\u6226\u679C\u8868 FBT\uFF0F\n\u3000\u5E97\u5185\u96F0\u56F2\u6C17\u8868 SAT\uFF0F\u7279\u6B8A\u30E1\u30CB\u30E5\u30FC\u8868 SMT\n\u30FB\u8A66\u7DF4\u8868\uFF08\uFF5EVT\uFF09\n\u3000\u30AE\u30EA\u30B7\u30E3\u795E\u7FA4 GCVT\uFF0F\u30E4\u30DE\u30C8\u795E\u7FA4 YCVT\uFF0F\u30A8\u30B8\u30D7\u30C8\u795E\u7FA4 ECVT\uFF0F\n\u3000\u30AF\u30C8\u30A5\u30EB\u30D5\u795E\u7FA4 CCVT\uFF0F\u5317\u6B27\u795E\u7FA4 NCVT\uFF0F\u4E2D\u83EF\u795E\u7FA4 CHVT\uFF0F\n  \u30E9\u30B9\u30C8\u30AF\u30ED\u30CB\u30AF\u30EB\u795E\u7FA4 LCVT\uFF0F\u30B1\u30EB\u30C8\u795E\u7FA4 KCVT\uFF0F\u30C0\u30F3\u30B8\u30E7\u30F3 DGVT\uFF0F\u65E5\u5E38 DAVT\n\u30FB\u6311\u6226\u30C6\u30FC\u30DE\u8868\uFF08\uFF5ECT\uFF09\n\u3000\u6B66\u52C7 PRCT\uFF0F\u6280\u8853 TCCT\uFF0F\u982D\u8133 INCT\uFF0F\u970A\u529B PSCT\uFF0F\u611B LVCT\uFF0F\u65E5\u5E38 DACT\n"
CHECK_DICE_COUNT =
{"S" => 4, "A" => 3, "B" => 2, "C" => 1, "D" => 2}.freeze
TABLES =
translate_tables(:ja_jp)

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

Class Method Summary collapse

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

Returns a new instance of Amadeus.



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

def initialize(command)
  super(command)

  @sort_add_dice = true
  @enabled_d66 = true
  @d66_sort_type = D66SortType::ASC
end

Class Method Details

.translate_tables(locale) ⇒ Object



118
119
120
121
122
123
124
125
126
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
# File 'lib/bcdice/game_system/Amadeus.rb', line 118

def self.translate_tables(locale)
  {
    "ECT" => DiceTable::Table.from_i18n("Amadeus.table.ECT", locale),
    "BST" => DiceTable::Table.from_i18n("Amadeus.table.BST", locale),
    "RT" => DiceTable::Table.from_i18n("Amadeus.table.RT", locale),
    "PRT" => DiceTable::Table.from_i18n("Amadeus.table.PRT", locale),
    "FT" => DiceTable::Table.from_i18n("Amadeus.table.FT", locale),
    "BT" => DiceTable::D66Table.from_i18n("Amadeus.table.BT", locale),
    "FWT" => DiceTable::Table.from_i18n("Amadeus.table.FWT", locale),
    "BRT" => DiceTable::Table.from_i18n("Amadeus.table.BRT", locale),
    "RIT" => DiceTable::Table.from_i18n("Amadeus.table.RIT", locale),
    "WT" => DiceTable::Table.from_i18n("Amadeus.table.WT", locale),
    "NMT" => DiceTable::Table.from_i18n("Amadeus.table.NMT", locale),
    "TGT" => DiceTable::Table.from_i18n("Amadeus.table.TGT", locale),
    "CST" => DiceTable::Table.from_i18n("Amadeus.table.CST", locale),
    "GCVT" => DiceTable::Table.from_i18n("Amadeus.table.GCVT", locale),
    "YCVT" => DiceTable::Table.from_i18n("Amadeus.table.YCVT", locale),
    "ECVT" => DiceTable::Table.from_i18n("Amadeus.table.ECVT", locale),
    "CCVT" => DiceTable::Table.from_i18n("Amadeus.table.CCVT", locale),
    "NCVT" => DiceTable::Table.from_i18n("Amadeus.table.NCVT", locale),
    "DGVT" => DiceTable::Table.from_i18n("Amadeus.table.DGVT", locale),
    "DAVT" => DiceTable::Table.from_i18n("Amadeus.table.DAVT", locale),
    "PRCT" => DiceTable::Table.from_i18n("Amadeus.table.PRCT", locale),
    "TCCT" => DiceTable::Table.from_i18n("Amadeus.table.TCCT", locale),
    "INCT" => DiceTable::Table.from_i18n("Amadeus.table.INCT", locale),
    "PSCT" => DiceTable::Table.from_i18n("Amadeus.table.PSCT", locale),
    "LVCT" => DiceTable::Table.from_i18n("Amadeus.table.LVCT", locale),
    "DACT" => DiceTable::Table.from_i18n("Amadeus.table.DACT", locale),
    "RGT" => DiceTable::Table.from_i18n("Amadeus.table.RGT", locale),
    "FBT" => DiceTable::Table.from_i18n("Amadeus.table.FBT", locale),
    "CHVT" => DiceTable::Table.from_i18n("Amadeus.table.CHVT", locale),
    "LCVT" => DiceTable::Table.from_i18n("Amadeus.table.LCVT", locale),
    "KCVT" => DiceTable::Table.from_i18n("Amadeus.table.KCVT", locale),
    "SAT" => DiceTable::D66Table.from_i18n("Amadeus.table.SAT", locale),
    "SMT" => DiceTable::D66Table.from_i18n("Amadeus.table.SMT", locale),
  }
end

Instance Method Details

#amadeusDice(command) ⇒ Object



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

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

  commandText = Regexp.last_match(1)
  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))
  if nil | Regexp.last_match(5)
    specialNum = Regexp.last_match(5).to_i
  elsif nil | Regexp.last_match(11)
    specialNum = Regexp.last_match(11).to_i
  else
    specialNum = 6
  end

  diceCount = CHECK_DICE_COUNT[skillRank]
  modify = ArithmeticEvaluator.eval(modifyText)
  target = ArithmeticEvaluator.eval(targetText)

  diceList = @randomizer.roll_barabara(diceCount, 6)
  diceText = diceList.join(",")
  specialText = (specialNum == 6 ? "" : "@#{specialNum}")

  message = "(#{commandText}#{specialText}#{signOfInequality}#{targetText}) > [#{diceText}]#{modifyText} > "
  diceList = [diceList.min] if skillRank == "D"
  is_loop = false
  diceList.each do |dice|
    if  is_loop
      message += " / "
    elsif diceList.length > 1
      is_loop = true
    end
    achieve = dice + modify
    result = check_success(achieve, dice, signOfInequality, target, specialNum)
    if is_loop
      inga_table = translate("Amadeus.inga_table")
      inga = inga_table[dice - 1]
      message += "#{achieve}_#{result}[#{dice}#{inga}]"
    else
      message += "#{achieve}_#{result}[#{dice}]"
    end
  end

  return message
end

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



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

def check_success(total_n, dice_n, signOfInequality, diff, special_n)
  return translate("Amadeus.fumble") if dice_n == 1
  return translate("Amadeus.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



48
49
50
51
52
53
# File 'lib/bcdice/game_system/Amadeus.rb', line 48

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

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