Class: BCDice::GameSystem::Karukami

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'Karukami'
NAME =

ゲームシステム名

'カルカミ'
SORT_KEY =

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

'かるかみ'
HELP_MESSAGE =

ダイスボットの使い方

<<~HELP_MESSAGE
  ■ 行為判定、ダメージ算出 (xUB+y@c>=t)
    6面ダイスをx個ダイスロールし、クリティカル値以上の出目が出たら振り足して合計値を算出します。
    x: ダイス数
    y: 修正値(省略可)
    c: クリティカル値(省略可)
    t: 目標値値(省略可)
    例)2UB, 2UB>=7, 3UB+1@5, 3UB+1@5<10
HELP_MESSAGE

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

def eval_game_system_specific_command(command)
  roll_ub(command)
end

#roll_ub(command) ⇒ Object



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

def roll_ub(command)
  parser = Command::Parser.new("UB", round_type: @round_type)
                          .has_prefix_number
                          .enable_critical
  parsed = parser.parse(command)
  unless parsed
    return nil
  end

  critical = parsed.critical || 6
  if critical <= 1
    return "(#{parsed}) > クリティカル値は2以上としてください"
  end

  list_list = []
  criticals = 0
  stack = parsed.prefix_number
  while stack > 0
    dice_list = @randomizer.roll_barabara(stack, 6)
    list_list.push(dice_list)
    stack = dice_list.count { |x| x >= critical }
    criticals += stack
  end

  total = list_list.flatten.sum() + parsed.modify_number

  result =
    if list_list.first.all?(1)
      total = 0
      Result.fumble("ファンブル")
    elsif parsed.cmp_op.nil?
      Result.new()
    elsif total.send(parsed.cmp_op, parsed.target_number)
      Result.success("成功")
    else
      Result.failure("失敗")
    end
  result.critical = criticals > 0

  sequence = [
    "(#{parsed})",
    *list_list.map { |list| "[#{list.join(',')}]" },
    total,
    ("#{criticals}クリティカル" if result.critical?),
    result.text,
  ].compact

  result.text = sequence.join("")
  return result
end