class BCDice::GameSystem::DoubleCross

Constants

HELP_MESSAGE

ダイスボットの使い方

ID

ゲームシステムの識別子

NAME

ゲームシステム名

NEGATIVE_EMOTION_TABLE

感情表(ネガティブ)

POSITIVE_EMOTION_TABLE

感情表(ポジティブ)

SORT_KEY

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

Private Class Methods

negative_emotion_table(locale) click to toggle source

@param locale [Symbol] @return [RangeTable]

# File lib/bcdice/game_system/DoubleCross.rb, line 323
def negative_emotion_table(locale)
  DiceTable::RangeTable.new(
    I18n.translate("DoubleCross.ET.negative.name", locale: locale),
    "1D100",
    [
      # [0, '侮蔑(ぶべつ)'],
      [1..5,    I18n.translate("DoubleCross.ET.negative.items.1_5", locale: locale)],
      [6..10,   I18n.translate("DoubleCross.ET.negative.items.6_10", locale: locale)],
      [11..15,  I18n.translate("DoubleCross.ET.negative.items.11_15", locale: locale)],
      [16..20,  I18n.translate("DoubleCross.ET.negative.items.16_20", locale: locale)],
      [21..25,  I18n.translate("DoubleCross.ET.negative.items.21_25", locale: locale)],
      [26..30,  I18n.translate("DoubleCross.ET.negative.items.26_30", locale: locale)],
      [31..35,  I18n.translate("DoubleCross.ET.negative.items.31_35", locale: locale)],
      [36..40,  I18n.translate("DoubleCross.ET.negative.items.36_40", locale: locale)],
      [41..45,  I18n.translate("DoubleCross.ET.negative.items.41_45", locale: locale)],
      [46..50,  I18n.translate("DoubleCross.ET.negative.items.46_50", locale: locale)],
      [51..55,  I18n.translate("DoubleCross.ET.negative.items.51_55", locale: locale)],
      [56..60,  I18n.translate("DoubleCross.ET.negative.items.56_60", locale: locale)],
      [61..65,  I18n.translate("DoubleCross.ET.negative.items.61_65", locale: locale)],
      [66..70,  I18n.translate("DoubleCross.ET.negative.items.66_70", locale: locale)],
      [71..75,  I18n.translate("DoubleCross.ET.negative.items.71_75", locale: locale)],
      [76..80,  I18n.translate("DoubleCross.ET.negative.items.76_80", locale: locale)],
      [81..85,  I18n.translate("DoubleCross.ET.negative.items.81_85", locale: locale)],
      [86..90,  I18n.translate("DoubleCross.ET.negative.items.86_90", locale: locale)],
      [91..95,  I18n.translate("DoubleCross.ET.negative.items.91_95", locale: locale)],
      [96..100, I18n.translate("DoubleCross.ET.negative.items.96_100", locale: locale)],
      # [101, '無関心(むかんしん)'],
      # [102, '任意(にんい)'],
    ]
  ).freeze
end
positive_emotion_table(locale) click to toggle source

@param locale [Symbol] @return [RangeTable]

# File lib/bcdice/game_system/DoubleCross.rb, line 289
def positive_emotion_table(locale)
  DiceTable::RangeTable.new(
    I18n.translate("DoubleCross.ET.positive.name", locale: locale),
    "1D100",
    [
      # [0, '傾倒(けいとう)'],
      [1..5,    I18n.translate("DoubleCross.ET.positive.items.1_5", locale: locale)],
      [6..10,   I18n.translate("DoubleCross.ET.positive.items.6_10", locale: locale)],
      [11..15,  I18n.translate("DoubleCross.ET.positive.items.11_15", locale: locale)],
      [16..20,  I18n.translate("DoubleCross.ET.positive.items.16_20", locale: locale)],
      [21..25,  I18n.translate("DoubleCross.ET.positive.items.21_25", locale: locale)],
      [26..30,  I18n.translate("DoubleCross.ET.positive.items.26_30", locale: locale)],
      [31..35,  I18n.translate("DoubleCross.ET.positive.items.31_35", locale: locale)],
      [36..40,  I18n.translate("DoubleCross.ET.positive.items.36_40", locale: locale)],
      [41..45,  I18n.translate("DoubleCross.ET.positive.items.41_45", locale: locale)],
      [46..50,  I18n.translate("DoubleCross.ET.positive.items.46_50", locale: locale)],
      [51..55,  I18n.translate("DoubleCross.ET.positive.items.51_55", locale: locale)],
      [56..60,  I18n.translate("DoubleCross.ET.positive.items.56_60", locale: locale)],
      [61..65,  I18n.translate("DoubleCross.ET.positive.items.61_65", locale: locale)],
      [66..70,  I18n.translate("DoubleCross.ET.positive.items.66_70", locale: locale)],
      [71..75,  I18n.translate("DoubleCross.ET.positive.items.71_75", locale: locale)],
      [76..80,  I18n.translate("DoubleCross.ET.positive.items.76_80", locale: locale)],
      [81..85,  I18n.translate("DoubleCross.ET.positive.items.81_85", locale: locale)],
      [86..90,  I18n.translate("DoubleCross.ET.positive.items.86_90", locale: locale)],
      [91..95,  I18n.translate("DoubleCross.ET.positive.items.91_95", locale: locale)],
      [96..100, I18n.translate("DoubleCross.ET.positive.items.96_100", locale: locale)],
      # [101, '懐旧(かいきゅう)'],
      # [102, '任意(にんい)'],
    ]
  )
end

Public Instance Methods

eval_game_system_specific_command(command) click to toggle source

ダイスボット固有コマンドの処理を行う @param [String] command コマンド @return [String] ダイスボット固有コマンドの結果 @return [nil] 無効なコマンドだった場合

# File lib/bcdice/game_system/DoubleCross.rb, line 206
def eval_game_system_specific_command(command)
  if (dx = parse_dx(command))
    return dx.execute(@randomizer)
  end

  if command == 'ET'
    return roll_emotion_table()
  end

  return nil
end

Private Instance Methods

parse_dx(command) click to toggle source

成功判定コマンドの構文解析を行う @param [String] command コマンド文字列 @return [DX, nil]

# File lib/bcdice/game_system/DoubleCross.rb, line 223
def parse_dx(command)
  parse_dx_od(command) || parse_dx_shippu_doto(command)
end
parse_dx_od(command) click to toggle source

OD Tool式の成功判定コマンドの正規表現マッチ情報からノードを作る @param command [String] @return [DX]

# File lib/bcdice/game_system/DoubleCross.rb, line 230
def parse_dx_od(command)
  parser = Command::Parser.new(/\d+DX/, round_type: round_type)
                          .enable_critical
                          .restrict_cmp_op_to(nil, :>=)
  parsed = parser.parse(command)
  return nil unless parsed

  num = parsed.command.to_i
  critical_value = parsed.critical || 10

  self.class::DX.new(num, critical_value, parsed.modify_number, parsed.target_number)
end
parse_dx_shippu_doto(command) click to toggle source

疾風怒濤式の成功判定コマンドの正規表現マッチ情報からノードを作る @param command [String] @return [DX]

# File lib/bcdice/game_system/DoubleCross.rb, line 246
def parse_dx_shippu_doto(command)
  parser = Command::Parser.new(/\d+DX\d*/, round_type: round_type)
                          .restrict_cmp_op_to(nil, :>=)
  parsed = parser.parse(command)
  return nil unless parsed

  num, critical_value = parsed.command.split("DX", 2).map { |x| x&.to_i }
  critical_value ||= 10

  self.class::DX.new(num, critical_value, parsed.modify_number, parsed.target_number)
end
roll_emotion_table() click to toggle source

感情表を振る

ポジティブとネガティブの両方を振って、表になっている側に○を付ける。

@return [Result]

# File lib/bcdice/game_system/DoubleCross.rb, line 263
def roll_emotion_table
  pos_result = self.class::POSITIVE_EMOTION_TABLE.roll(@randomizer)
  neg_result = self.class::NEGATIVE_EMOTION_TABLE.roll(@randomizer)

  positive = @randomizer.roll_once(2) == 1
  pos_neg_text =
    if positive
      ["○#{pos_result.content}", neg_result.content]
    else
      [pos_result.content, "○#{neg_result.content}"]
    end

  name = translate("DoubleCross.ET.name")
  output_parts = [
    "#{name}(#{pos_result.sum}-#{neg_result.sum})",
    pos_neg_text.join(' - ')
  ]

  return Result.new(output_parts.join(' > '))
end