Class: BCDice::GameSystem::CrashWorld

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'CrashWorld'
NAME =

ゲームシステム名

'墜落世界'
SORT_KEY =

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

'ついらくせかい'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定 CWn
  初期目標値n (必須)
  例・CW8
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



24
25
26
27
28
29
30
31
32
33
# File 'lib/bcdice/game_system/CrashWorld.rb', line 24

def eval_game_system_specific_command(command)
  result = nil

  case command
  when /CW(\d+)/i
    result = getCrashWorldRoll(Regexp.last_match(1).to_i)
  end

  return result
end

#getCrashWorldRoll(target) ⇒ Object



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
# File 'lib/bcdice/game_system/CrashWorld.rb', line 35

def getCrashWorldRoll(target)
  debug("target", target)

  output = "("
  isEnd = false
  successness = 0
  num = 0

  while !isEnd
    num = @randomizer.roll_once(12)

    # 振った数字を出力へ書き足す
    if output == "("
      output = "(#{num}"
    else
      output = "#{output}, #{num}"
    end

    if num <= target || num == 11
      # 成功/クリティカル(11)。 次回の目標値を変更して継続
      target = num
      successness += 1
    elsif num == 12
      # ファンブルなら終了。
      isEnd = true
    else
      # target < num < 11で終了
      isEnd = true
    end
  end

  if num == 12
    # ファンブルの時、成功度は0
    successness = 0
  end

  output = "#{output})  成功度 : #{successness}"

  if num == 12
    output = "#{output} ファンブル"
  end

  return output
end