Class: BCDice::GameSystem::Kamigakari

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

Direct Known Subclasses

Kamigakari_Korean

Constant Summary collapse

ID =

ゲームシステムの識別子

'Kamigakari'
NAME =

ゲームシステム名

'神我狩'
SORT_KEY =

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

'かみかかり'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・各種表
   ・感情表(ET)
   ・霊紋消費の代償表(RT)
   ・伝奇名字・名前決定表(NT)
   ・魔境臨界表(KT)
   ・獲得素材チャート(MTx xは[法則障害]の[強度]。省略時は1)
    例) MT MT3 MT9
  ・D66ダイスあり
INFO_MESSAGE_TEXT
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

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

Returns a new instance of Kamigakari.



27
28
29
30
31
32
# File 'lib/bcdice/game_system/Kamigakari.rb', line 27

def initialize(command)
  super(command)

  @sort_add_dice = true
  @d66_sort_type = D66SortType::NO_SORT
end

Instance Method Details

#eval_game_system_specific_command(command) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bcdice/game_system/Kamigakari.rb', line 34

def eval_game_system_specific_command(command)
  tableName = ""
  result = ""

  debug("eval_game_system_specific_command command", command)

  case command.upcase
  when /^MT(\d*)$/
    rank = Regexp.last_match(1)
    rank ||= 1
    rank = rank.to_i
    tableName, result, number = getGetMaterialTableResult(rank)
  else
    return roll_tables(command, self.class::TABLES)
  end

  if result.empty?
    return ""
  end

  text = "#{tableName}(#{number}) > #{result}"
  return text
end

#getAttributeObject



146
147
148
149
150
151
152
153
154
# File 'lib/bcdice/game_system/Kamigakari.rb', line 146

def getAttribute()
  table = translate("Kamigakari.MT.attribute")

  number = @randomizer.roll_d66(D66SortType::NO_SORT)

  result = get_table_by_number(number, table)

  return result, number
end

#getGetMaterialTableResult(rank) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bcdice/game_system/Kamigakari.rb', line 58

def getGetMaterialTableResult(rank)
  tableName = translate("Kamigakari.MT.name")
  table = translate("Kamigakari.MT.items")

  result, number = get_table_by_d66(table)

  effect, number2 = getMaterialEffect(rank)
  number = "#{number},#{number2}"

  price = getPrice(effect)

  result = translate("Kamigakari.MT.result_format", material: result, effect: effect)
  result += "#{price}" unless price.nil?

  return tableName, result, number
end

#getMaterialEffect(rank) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/bcdice/game_system/Kamigakari.rb', line 75

def getMaterialEffect(rank)
  number = @randomizer.roll_once(6)

  result = ""
  type = ""
  if number < 6
    result, number2 = getMaterialEffectNomal(rank)
    type = translate("Kamigakari.MT.common_material.name")
  else
    result, number2 = getMaterialEffectRare()
    type = translate("Kamigakari.MT.rare_material.name")
  end

  result = "#{type}#{result}"
  number = "#{number},#{number2}"

  return result, number
end

#getMaterialEffectNomal(rank) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/bcdice/game_system/Kamigakari.rb', line 94

def getMaterialEffectNomal(rank)
  table = translate("Kamigakari.MT.common_material.items")

  number = @randomizer.roll_d66(D66SortType::NO_SORT)

  result = get_table_by_number(number, table)
  debug("getMaterialEffectNomal result", result)

  if result =~ /\+n/
    power, number2 = getMaterialEffectPower(rank)

    result = result.sub(/\+n/, "+#{power}")
    number = "#{number},#{number2}"
  end

  return result, number
end

#getMaterialEffectPower(rank) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/bcdice/game_system/Kamigakari.rb', line 112

def getMaterialEffectPower(rank)
  table = [
    [4, [1, 1, 1, 2, 2, 3]],
    [8, [1, 1, 2, 2, 3, 3]],
    [9, [1, 2, 3, 3, 4, 5]],
  ]

  rank = 9 if rank > 9
  rankTable = get_table_by_number(rank, table)
  power, number = get_table_by_1d6(rankTable)

  return power, number
end

#getMaterialEffectRareObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/bcdice/game_system/Kamigakari.rb', line 126

def getMaterialEffectRare()
  table = [
    [3, "**" + translate("Kamigakari.MT.rare_material.give_attribute")], # 付与
    [5, "**" + translate("Kamigakari.MT.rare_material.halve_damage")], # 半減
    [6, translate("Kamigakari.MT.rare_material.optional_by_GM")],
  ]

  number = @randomizer.roll_once(6)
  result = get_table_by_number(number, table)
  debug('getMaterialEffectRare result', result)

  if result.include?("**")
    attribute, number2 = getAttribute()
    result = result.sub("**", attribute.to_s)
    number = "#{number},#{number2}"
  end

  return result, number
end

#getPrice(effect) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/bcdice/game_system/Kamigakari.rb', line 156

def getPrice(effect)
  power =
    if (m = effect.match(/\+(\d+)/))
      m[1].to_i
    elsif effect.include?(translate("Kamigakari.MT.rare_material.give_attribute")) # 付与
      3
    elsif effect.include?(translate("Kamigakari.MT.rare_material.halve_damage")) # 半減
      4
    else
      0
    end

  table = [
    nil,
    "500G(#{translate('Kamigakari.MT.effect_power')}:1)",
    "1000G(#{translate('Kamigakari.MT.effect_power')}:2)",
    "1500G(#{translate('Kamigakari.MT.effect_power')}:3)",
    "2000G(#{translate('Kamigakari.MT.effect_power')}:4)",
    "3000G(#{translate('Kamigakari.MT.effect_power')}:5)",
  ]
  price = table[power]

  return price
end