Class: BCDice::GameSystem::OrgaRain

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'OrgaRain'
NAME =

ゲームシステム名

'在りて遍くオルガレイン'
SORT_KEY =

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

'ありてあまねくおるかれいん'
HELP_MESSAGE =

ダイスボットの使い方

<<~MESSAGETEXT
  判定:[n]OR(count)

  []内のコマンドは省略可能。
  「n」でダイス数を指定。省略時は「1」。
  (count)で命数を指定。「3111」のように記述。最大6つ。順不同可。

  【書式例】
  ・5OR6042 → 5dで命数「0,2,4,6」の判定
  ・6OR33333 → 6dで命数「3,3,3,3,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) ⇒ OrgaRain

Returns a new instance of OrgaRain.



28
29
30
31
# File 'lib/bcdice/game_system/OrgaRain.rb', line 28

def initialize(command)
  super(command)
  @sort_add_dice = true # ダイスのソート有
end

Instance Method Details

#check_roll(dice_count, count_no) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bcdice/game_system/OrgaRain.rb', line 46

def check_roll(dice_count, count_no)
  dice_array = @randomizer.roll_barabara(dice_count, 10).sort
  dice_text = dice_array.join(',')

  result_array = []
  success = 0
  dice_array.map { |x| x == 10 ? 0 : x }.each do |i|
    multiple = count_no.count(i)
    if multiple > 0
      result_array.push("#{i}(x#{multiple})")
      success += multiple
    else
      result_array.push("×")
    end
  end

  count_text = count_no.join(',')
  result_text = result_array.join(',')

  return "#{dice_count}D10(命数:#{count_text}) > #{dice_text}#{result_text} > 成功数:#{success}"
end

#eval_game_system_specific_command(command) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/bcdice/game_system/OrgaRain.rb', line 37

def eval_game_system_specific_command(command)
  m = command.match(/(\d+)?OR(\d{0,6})$/i)
  return nil unless m

  dice_count = (m[1] || 1).to_i
  count_no = (m[2] || "").each_char.map(&:to_i).sort
  return check_roll(dice_count, count_no)
end