Class: BCDice::GameSystem::YearZeroEngine

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'YearZeroEngine'
NAME =

ゲームシステム名

'YearZeroEngine'
SORT_KEY =

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

'いやあせろえんしん'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定コマンド(nYZEx+x+x)
    (難易度)YZE(能力ダイス数)+(技能ダイス数)+(アイテムダイス数)  # (6のみを数える)

  ・判定コマンド(nMYZx+x+x)
    (難易度)MYZ(能力ダイス数)+(技能ダイス数)+(アイテムダイス数)  # (1と6を数え、プッシュ可能数を表示)
    (難易度)MYZ(能力ダイス数)-(技能ダイス数)+(アイテムダイス数)  # (1と6を数え、プッシュ可能数を表示、技能のマイナス指定)

    ※ 難易度と技能、アイテムダイス数は省略可能
INFO_MESSAGE_TEXT
DIFFICULTY_INDEX =

難易度のインデックス

1
COMMAND_TYPE_INDEX =

コマンドタイプのインデックス

2
ABILITY_INDEX =

能力値ダイスのインデックス

3
SKILL_SIGNED_INDEX =

技能値ダイス符号のインデックス

5
SKILL_INDEX =

技能値ダイスのインデックス

6
GEAR_INDEX =

アイテムダイスのインデックス

8

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

#dice_info_initObject



36
37
38
39
40
41
42
43
44
# File 'lib/bcdice/game_system/YearZeroEngine.rb', line 36

def dice_info_init()
  @total_success_dice = 0
  @total_botch_dice = 0
  @base_botch_dice = 0
  @skill_botch_dice = 0
  @gear_botch_dice = 0
  @push_dice = 0
  @difficulty = 0
end

#eval_game_system_specific_command(command) ⇒ Object



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

def eval_game_system_specific_command(command)
  m = /\A(\d+)?(YZE|MYZ)(\d+)((\+|-)(\d+))?(\+(\d+))?/.match(command)
  unless m
    return ''
  end

  dice_info_init

  @difficulty = m[DIFFICULTY_INDEX].to_i

  command_type = m[COMMAND_TYPE_INDEX]

  @total_success_dice = 0

  dice_pool = m[ABILITY_INDEX].to_i
  ability_dice_text, success_dice, botch_dice = make_dice_roll(dice_pool)

  @total_success_dice += success_dice
  @total_botch_dice += botch_dice
  @base_botch_dice += botch_dice # 能力ダメージ
  @push_dice += (dice_pool - (success_dice + botch_dice))

  dice_count_text = "(#{dice_pool}D6)"
  dice_text = ability_dice_text

  if m[SKILL_INDEX]
    dice_pool = m[SKILL_INDEX].to_i
    skill_dice_text, success_dice, botch_dice = make_dice_roll(dice_pool)

    skill_unsigned = m[SKILL_SIGNED_INDEX]
    if command_type == 'YZE' && skill_unsigned == '-'
      # YZEはシンプルに動作するコマンドなのでマイナス技能の処理は対応しない。
      return "YZEコマンドでは技能ダイスをマイナス指定できません。"
    elsif command_type == 'MYZ' && skill_unsigned == '-'
      @total_success_dice -= success_dice # マイナス技能の成功は通常の成功と相殺される
    else
      @total_success_dice += success_dice
    end

    @total_botch_dice += botch_dice
    @skill_botch_dice += botch_dice # 技能ダイスの1はpushで振り直し可能(例えマイナス技能でも)
    @push_dice += (dice_pool - success_dice) # 技能ダイスのみ1を含むので、ここでは1を計算に入れない

    dice_count_text += "#{skill_unsigned}(#{dice_pool}D6)"
    dice_text += "#{skill_unsigned}#{skill_dice_text}"
  end

  if m[GEAR_INDEX]
    dice_pool = m[GEAR_INDEX].to_i
    gear_dice_text, success_dice, botch_dice = make_dice_roll(dice_pool)

    @total_success_dice += success_dice
    @total_botch_dice += botch_dice
    @gear_botch_dice += botch_dice # ギアダメージ
    @push_dice += (dice_pool - (success_dice + botch_dice))

    dice_count_text += "+(#{dice_pool}D6)"
    dice_text += "+#{gear_dice_text}"
  end

  return make_result_text(command_type, dice_count_text, dice_text)
end

#make_dice_roll(dice_pool) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/bcdice/game_system/YearZeroEngine.rb', line 146

def make_dice_roll(dice_pool)
  dice_list = @randomizer.roll_barabara(dice_pool, 6)
  success_dice = dice_list.count(6)
  botch_dice = dice_list.count(1)

  return "[#{dice_list.join(',')}]", success_dice, botch_dice
end

#make_result_text(command_type, dice_count_text, dice_text) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/bcdice/game_system/YearZeroEngine.rb', line 109

def make_result_text(command_type, dice_count_text, dice_text)
  if command_type == 'YZE'
    return make_result_with_yze(dice_count_text, dice_text)
  elsif command_type == 'MYZ'
    return make_result_with_myz(dice_count_text, dice_text)
  end

  return 'Error' # 到達しないはず
end

#make_result_with_myz(dice_count_text, dice_text) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/bcdice/game_system/YearZeroEngine.rb', line 131

def make_result_with_myz(dice_count_text, dice_text)
  result_text = "#{dice_count_text}#{dice_text} 成功数:#{@total_success_dice}"
  atter_text = "\n出目1:[能力:#{@base_botch_dice},技能:#{@skill_botch_dice},アイテム:#{@gear_botch_dice}) プッシュ可能=#{@push_dice}ダイス"

  if @difficulty > 0
    if @total_success_dice >= @difficulty
      return Result.success("#{result_text} 難易度=#{@difficulty}:判定成功!#{atter_text}")
    else
      return Result.failure("#{result_text} 難易度=#{@difficulty}:判定失敗!#{atter_text}")
    end
  end

  return "#{result_text}#{atter_text}"
end

#make_result_with_yze(dice_count_text, dice_text) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bcdice/game_system/YearZeroEngine.rb', line 119

def make_result_with_yze(dice_count_text, dice_text)
  result_text = "#{dice_count_text}#{dice_text} 成功数:#{@total_success_dice}"
  if @difficulty > 0
    if @total_success_dice >= @difficulty
      return Result.success("#{result_text} 難易度=#{@difficulty}:判定成功!")
    else
      return Result.failure("#{result_text} 難易度=#{@difficulty}:判定失敗!")
    end
  end
  return result_text
end