Class: BCDice::GameSystem::WorldOfDarkness

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'WorldOfDarkness'
NAME =

ゲームシステム名

'ワールド・オブ・ダークネス'
SORT_KEY =

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

'わあるとおふたあくねす'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定コマンド(xSTn+y or xSTSn+y or xSTAn+y)
   (ダイス個数)ST(難易度)+(自動成功)
   (ダイス個数)STS(難易度)+(自動成功) ※出目10で振り足し
   (ダイス個数)STA(難易度)+(自動成功) ※出目10は2成功 [20thルール]

   難易度=省略時6
   自動成功=省略時0
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



28
29
30
31
32
33
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
# File 'lib/bcdice/game_system/WorldOfDarkness.rb', line 28

def eval_game_system_specific_command(command)
  difficulty = 6
  auto_success = 0
  enabled_reroll = false
  enabled_20th = false

  md = command.match(/\A(\d+)(ST[SA]?)(\d+)?([+-]\d+)?/)

  dice_pool = md[1].to_i
  case md[2]
  when 'STS'
    enabled_reroll = true
  when 'STA'
    enabled_20th = true
  end
  difficulty = md[3].to_i if md[3]
  auto_success = md[4].to_i if md[4]

  difficulty = 6 if difficulty < 2

  sequence = []
  sequence.push "DicePool=#{dice_pool}, Difficulty=#{difficulty}, AutomaticSuccess=#{auto_success}"

  # 出力では Difficulty=11..12 もあり得る
  difficulty = 10 if difficulty > 10

  total_success = 0
  total_botch = 0
  once_success = false

  dice, ten_success, success, botch = roll_wod(dice_pool, difficulty)
  sequence.push dice.join(',')
  total_success += success
  total_botch += botch

  # 成功がひとつでもあったか覚えておく
  once_success = true if success > 0 || ten_success > 0

  if enabled_20th
    # 20周年記念版なら10の目は2成功扱い
    total_success += ten_success * 2
  else
    # Revised Editionでは10は1成功と数える
    total_success += ten_success

    # 振り足し判定ありなら10が出ただけ振り足しを行う
    if enabled_reroll
      while ten_success > 0
        # 振り足しの出目1は大失敗ではない
        dice, ten_success, success = roll_wod(ten_success, difficulty)
        sequence.push dice.join(',')
        total_success += (success + ten_success)
      end
    end
  end

  total_success -= [total_success, total_botch].min

  total_success += auto_success # 意志力による自動成功は打ち消されない

  if total_success > 0
    sequence.push "成功数#{total_success}"
  elsif total_botch > 0 && once_success == false
    # ボッチが存在し、かつ成功がひとつもない場合のみ大失敗
    sequence.push "大失敗"
  else
    sequence.push "失敗"
  end

  output = sequence.join('')
  return output
end

#roll_wod(dice_pool, difficulty) ⇒ Object

出目10と1、難易度以上が出た成功の目をカウントする。 それぞれの解釈はバージョンによって異なるため、呼び出し元で行う。



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/WorldOfDarkness.rb', line 103

def roll_wod(dice_pool, difficulty)
  # FIXME: まとめて振る
  dice = Array.new(dice_pool) do
    dice_now = @randomizer.roll_once(10)
    dice_now
  end

  dice.sort!

  success = 0
  botch = 0
  ten_success = 0

  dice.each do |d|
    case d
    when 10
      ten_success += 1
    when difficulty...10
      success += 1
    when 1
      botch += 1
    end
  end

  return dice, ten_success, success, botch
end