Class: BCDice::GameSystem::Aionia

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

Constant Summary collapse

ID =

ゲームシステムの識別子

"Aionia"
NAME =

ゲームシステム名

"慈悲なきアイオニア"
SORT_KEY =

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

"しひなきあいおにあ"
HELP_MESSAGE =
<<~INFO_MESSAGE_TEXT
  - 技能判定(クリティカル・ファンブルなし)
  AB{n}>={dif} n=10面ダイスの数、dif=難易度
  - 技能判定(クリティカル・ファンブルあり)
  ABT{n}>={dif} n=10面ダイスの数、dif=難易度

  例:AB2>=5        (一般技能を活用して難易度5の技能判定。 クリファンなし。)
  例:ABT3>=15      (専門技能を活用して難易度15の技能判定。クリファンあり。)
  例:AB1+2>=8      (一般技能を活用せず難易度8の技能判定。 ボーナスとして+2点の補正あり。  クリファンなし。)
  例:ABT3-3>=10    (専門技能を活用して難易度10の技能判定。ペナルティとして-3点の補正あり。クリファンあり。)
  例:ABT2>=4/8/12  (一般技能を活用して難易度4/8/12の段階的な技能判定。クリファンあり。)
INFO_MESSAGE_TEXT

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, #initialize, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

This class inherits a constructor from BCDice::Base

Instance Method Details

#eval_game_system_specific_command(command) ⇒ Object



30
31
32
# File 'lib/bcdice/game_system/Aionia.rb', line 30

def eval_game_system_specific_command(command)
  return roll_skills(command)
end

#roll_skills(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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/bcdice/game_system/Aionia.rb', line 34

def roll_skills(command)
  m = %r{AB(T?)(\d+)([+-]\d+)?>=((\d+)((/\d+)*))}.match(command)
  return nil unless m

  # 値の取得
  use_cf = m[1] != ''
  times = m[2].to_i
  bonus = m[3].to_i
  targets = m[4].split('/').map(&:to_i)
  target = targets[0]
  min_target = targets.min
  max_target = targets.max

  # ダイスロール
  dice_list = @randomizer.roll_barabara(times, 10)
  dice_total = dice_list.sum
  total = dice_total + bonus

  # Result用変数宣言
  is_success = false
  has_critical = false
  has_fumble = false

  # 結果判定
  # 難易度が一つの場合
  if targets.count == 1
    if total >= target
      is_success = true
      if total >= target + 20 && use_cf
        result = 'クリティカル'
        has_critical = true
      elsif target <= times
        result = '自動成功'
      else
        result = '成功'
      end
    else
      is_success = false
      if dice_list.count(1) == times && use_cf
        result = 'ファンブル'
        has_fumble = true
      elsif target > 10 * times
        result = '自動失敗'
      else
        result = '失敗'
      end
    end
  # 段階的な難易度判定の場合
  else
    if total >= min_target
      is_success = true
      if total >= max_target + 20 && use_cf
        result = 'クリティカル'
        has_critical = true
      elsif max_target <= times
        result = '自動成功'
      elsif total >= max_target
        result = '全成功'
      else
        times_suc = targets.count { |x| x <= total }
        result = "#{times_suc}段階成功"
      end
    else
      is_success = false
      if dice_list.count(1) == times && use_cf
        result = 'ファンブル'
        has_fumble = true
      elsif min_target > 10 * times
        result = '自動失敗'
      else
        result = '失敗'
      end
    end
  end

  # ボーナスがある場合の処理
  bonus_text = ''
  bonus_result = ''
  if bonus != 0
    if bonus > 0
      bonus_text = "+"
    end
    bonus_text += bonus.to_s
    bonus_result = "#{total}"
  end

  # Resultクラスに結果を入れる
  Result.new.tap do |r|
    r.text = "(#{command}) > #{dice_total}[#{dice_list.join(',')}]#{bonus_text}#{bonus_result}#{result}"
    r.critical = has_critical
    r.fumble = has_fumble
    r.success = is_success
    r.failure = !is_success
  end
end