Class: BCDice::GameSystem::TokumeiTenkousei

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'TokumeiTenkousei'
NAME =

ゲームシステム名

'特命転攻生'
SORT_KEY =

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

'とくめいてんこうせい'
HELP_MESSAGE =

ダイスボットの使い方

<<~HELP
  ・判定 (xD6+y>=n)
   ゾロ目での自動振り足し
   1の出目に応じてEPPの獲得量を表示
   目標値 "?" には未対応
HELP

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) ⇒ TokumeiTenkousei

Returns a new instance of TokumeiTenkousei.



23
24
25
26
27
# File 'lib/bcdice/game_system/TokumeiTenkousei.rb', line 23

def initialize(command)
  super(command)

  @sort_add_dice = true
end

Instance Method Details

#epp(count_one) ⇒ String?

エキストラパワーポイント獲得

Parameters:

  • count_one (Integer)

Returns:

  • (String, nil)


90
91
92
93
94
# File 'lib/bcdice/game_system/TokumeiTenkousei.rb', line 90

def epp(count_one)
  if count_one > 0
    "#{count_one * 5}EPP獲得"
  end
end

#eval_game_system_specific_command(command) ⇒ Object



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

def eval_game_system_specific_command(command)
  parser = Command::Parser.new(/\d+D6/, round_type: round_type)
  cmd = parser.parse(command)
  unless cmd
    return nil
  end

  times = cmd.command.to_i

  dice_list = @randomizer.roll_barabara(times, 6).sort
  @dice_list = [dice_list]
  while same_all_dice?(dice_list)
    dice_list = @randomizer.roll_barabara(times, 6).sort
    @dice_list.push(dice_list)
  end

  dice_list_flatten = @dice_list.flatten
  dice_total = dice_list_flatten.sum()
  count_one = dice_list_flatten.count(1)

  total = dice_total + cmd.modify_number

  result =
    if cmd.cmp_op
      total.send(cmd.cmp_op, cmd.target_number) ? Result.success("成功") : Result.failure("失敗")
    end

  sequence = [
    "(#{cmd})",
    interim_expr(cmd, dice_total),
    total.to_s,
    result.text,
    epp(count_one)
  ].compact

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

#interim_expr(cmd, dice_total) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/bcdice/game_system/TokumeiTenkousei.rb', line 75

def interim_expr(cmd, dice_total)
  if @dice_list.flatten.size == 1 && cmd.modify_number == 0
    return nil
  end

  dice_list = @dice_list.map { |ds| "[#{ds.join(',')}]" }.join("")
  modifier = Format.modifier(cmd.modify_number)

  return [dice_total.to_s, dice_list, modifier].join("")
end

#same_all_dice?(dice_list) ⇒ Boolean

出目が全て同じか

Returns:

  • (Boolean)


71
72
73
# File 'lib/bcdice/game_system/TokumeiTenkousei.rb', line 71

def same_all_dice?(dice_list)
  dice_list.size > 1 && dice_list.uniq.size == 1
end