diff --git a/lib/bcdice/game_system/YearZeroEngine.rb b/lib/bcdice/game_system/YearZeroEngine.rb index ff85aec7c..074af1377 100644 --- a/lib/bcdice/game_system/YearZeroEngine.rb +++ b/lib/bcdice/game_system/YearZeroEngine.rb @@ -19,15 +19,17 @@ class YearZeroEngine < Base ・判定コマンド(nMYZx+x+x) (難易度)MYZ(能力ダイス数)+(技能ダイス数)+(アイテムダイス数) # (1と6を数え、プッシュ可能数を表示) + (難易度)MYZ(能力ダイス数)-(技能ダイス数)+(アイテムダイス数) # (1と6を数え、プッシュ可能数を表示、技能のマイナス指定) ※ 難易度と技能、アイテムダイス数は省略可能 INFO_MESSAGE_TEXT - DIFFICULTY_INDEX = 1 # 難易度のインデックス - COMMAND_TYPE_INDEX = 2 # コマンドタイプのインデックス - ABILITY_INDEX = 3 # 能力値ダイスのインデックス - SKILL_INDEX = 5 # 技能値ダイスのインデックス - MODIFIED_INDEX = 7 # 修正ダイスのインデックス + DIFFICULTY_INDEX = 1 # 難易度のインデックス + COMMAND_TYPE_INDEX = 2 # コマンドタイプのインデックス + ABILITY_INDEX = 3 # 能力値ダイスのインデックス + SKILL_SIGNED_INDEX = 5 # 技能値ダイス符号のインデックス + SKILL_INDEX = 6 # 技能値ダイスのインデックス + GEAR_INDEX = 8 # アイテムダイスのインデックス register_prefix('(\d+)?(YZE|MYZ)') @@ -42,7 +44,7 @@ def dice_info_init() end def eval_game_system_specific_command(command) - m = /\A(\d+)?(YZE|MYZ)(\d+)(\+(\d+))?(\+(\d+))?/.match(command) + m = /\A(\d+)?(YZE|MYZ)(\d+)((\+|-)(\d+))?(\+(\d+))?/.match(command) unless m return '' end @@ -70,18 +72,27 @@ def eval_game_system_specific_command(command) dice_pool = m[SKILL_INDEX].to_i skill_dice_text, success_dice, botch_dice = make_dice_roll(dice_pool) - @total_success_dice += success_dice + 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を含む + @skill_botch_dice += botch_dice # 技能ダイスの1はpushで振り直し可能(例えマイナス技能でも) + @push_dice += (dice_pool - success_dice) # 技能ダイスのみ1を含むので、ここでは1を計算に入れない - dice_count_text += "+(#{dice_pool}D6)" - dice_text += "+#{skill_dice_text}" + dice_count_text += "#{skill_unsigned}(#{dice_pool}D6)" + dice_text += "#{skill_unsigned}#{skill_dice_text}" end - if m[MODIFIED_INDEX] - dice_pool = m[MODIFIED_INDEX].to_i - modified_dice_text, success_dice, botch_dice = make_dice_roll(dice_pool) + 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 @@ -89,8 +100,9 @@ def eval_game_system_specific_command(command) @push_dice += (dice_pool - (success_dice + botch_dice)) dice_count_text += "+(#{dice_pool}D6)" - dice_text += "+#{modified_dice_text}" + dice_text += "+#{gear_dice_text}" end + return make_result_text(command_type, dice_count_text, dice_text) end @@ -108,18 +120,27 @@ 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 - result_text = "#{result_text} 難易度=#{@difficulty}:判定成功!" + return Result.success("#{result_text} 難易度=#{@difficulty}:判定成功!") else - result_text = "#{result_text} 難易度=#{@difficulty}:判定失敗!" + return Result.failure("#{result_text} 難易度=#{@difficulty}:判定失敗!") end end return result_text end def make_result_with_myz(dice_count_text, dice_text) - result_text = make_result_with_yze(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}\n出目1:[能力:#{@base_botch_dice},技能:#{@skill_botch_dice},アイテム:#{@gear_botch_dice}) プッシュ可能=#{@push_dice}ダイス" + return "#{result_text}#{atter_text}" end def make_dice_roll(dice_pool) diff --git a/test/data/YearZeroEngine.toml b/test/data/YearZeroEngine.toml index d41cdd523..48f6018bf 100644 --- a/test/data/YearZeroEngine.toml +++ b/test/data/YearZeroEngine.toml @@ -210,6 +210,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3" output = "(3D6) > [2,5,3] 成功数:0 難易度=2:判定失敗!" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -220,6 +221,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3" output = "(3D6) > [2,6,1] 成功数:1 難易度=2:判定失敗!" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 6 }, @@ -230,6 +232,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3" output = "(3D6) > [6,6,6] 成功数:3 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -240,6 +243,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3" output = "(3D6)+(3D6) > [2,5,3]+[1,4,1] 成功数:0 難易度=2:判定失敗!" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -253,6 +257,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3" output = "(3D6)+(3D6) > [2,6,3]+[1,6,1] 成功数:2 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 6 }, @@ -266,6 +271,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3" output = "(3D6)+(3D6) > [6,6,6]+[6,6,6] 成功数:6 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -279,6 +285,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3+3" output = "(3D6)+(3D6)+(3D6) > [2,5,3]+[1,4,1]+[3,1,4] 成功数:0 難易度=2:判定失敗!" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -295,6 +302,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3+3" output = "(3D6)+(3D6)+(3D6) > [2,5,6]+[1,4,6]+[3,1,6] 成功数:3 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -311,6 +319,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+3+3" output = "(3D6)+(3D6)+(3D6) > [6,6,6]+[6,6,6]+[6,6,6] 成功数:9 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -327,6 +336,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+2+1" output = "(3D6)+(2D6)+(1D6) > [2,5,3]+[1,4]+[3] 成功数:0 難易度=2:判定失敗!" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -340,6 +350,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+2+1" output = "(3D6)+(2D6)+(1D6) > [2,5,6]+[4,6]+[6] 成功数:3 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -353,6 +364,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE3+2+1" output = "(3D6)+(2D6)+(1D6) > [6,6,6]+[6,6]+[6] 成功数:6 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -366,6 +378,7 @@ rands = [ game_system = "YearZeroEngine" input = "2YZE1+2+3" output = "(1D6)+(2D6)+(3D6) > [2]+[4,6]+[6,1,5] 成功数:2 難易度=2:判定成功!" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 4 }, @@ -379,6 +392,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2YZE3" output = "(3D6) > [2,5,3] 成功数:0 難易度=2:判定失敗!" +failure = true secret = true rands = [ { sides = 6, value = 2 }, @@ -390,6 +404,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2YZE3+3" output = "(3D6)+(3D6) > [2,5,3]+[1,4,1] 成功数:0 難易度=2:判定失敗!" +failure = true secret = true rands = [ { sides = 6, value = 2 }, @@ -404,6 +419,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2YZE1+2+3" output = "(1D6)+(2D6)+(3D6) > [2]+[4,6]+[6,1,5] 成功数:2 難易度=2:判定成功!" +success = true secret = true rands = [ { sides = 6, value = 2 }, @@ -626,6 +642,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3" output = "(3D6) > [2,5,3] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=3ダイス" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -636,6 +653,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3" output = "(3D6) > [2,6,1] 成功数:1 難易度=2:判定失敗!\n出目1:[能力:1,技能:0,アイテム:0) プッシュ可能=1ダイス" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 6 }, @@ -646,6 +664,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3" output = "(3D6) > [6,6,6] 成功数:3 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=0ダイス" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -656,6 +675,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3" output = "(3D6)+(3D6) > [2,5,3]+[1,4,1] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:2,アイテム:0) プッシュ可能=6ダイス" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -669,6 +689,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3" output = "(3D6)+(3D6) > [2,6,3]+[1,6,1] 成功数:2 難易度=2:判定成功!\n出目1:[能力:0,技能:2,アイテム:0) プッシュ可能=4ダイス" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 6 }, @@ -682,6 +703,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3" output = "(3D6)+(3D6) > [6,6,6]+[6,6,6] 成功数:6 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=0ダイス" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -695,6 +717,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3+3" output = "(3D6)+(3D6)+(3D6) > [2,5,3]+[1,4,1]+[3,1,4] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:2,アイテム:1) プッシュ可能=8ダイス" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -711,6 +734,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3+3" output = "(3D6)+(3D6)+(3D6) > [2,5,6]+[1,4,6]+[3,1,6] 成功数:3 難易度=2:判定成功!\n出目1:[能力:0,技能:1,アイテム:1) プッシュ可能=5ダイス" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -727,6 +751,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3+3" output = "(3D6)+(3D6)+(3D6) > [6,6,6]+[6,6,6]+[6,6,6] 成功数:9 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=0ダイス" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -743,6 +768,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+2+1" output = "(3D6)+(2D6)+(1D6) > [2,5,3]+[1,4]+[3] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:1,アイテム:0) プッシュ可能=6ダイス" +failure = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -756,6 +782,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+2+1" output = "(3D6)+(2D6)+(1D6) > [2,5,6]+[4,6]+[6] 成功数:3 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=3ダイス" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 5 }, @@ -769,6 +796,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+2+1" output = "(3D6)+(2D6)+(1D6) > [6,6,6]+[6,6]+[6] 成功数:6 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=0ダイス" +success = true rands = [ { sides = 6, value = 6 }, { sides = 6, value = 6 }, @@ -782,6 +810,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ1+2+3" output = "(1D6)+(2D6)+(3D6) > [2]+[4,6]+[6,1,5] 成功数:2 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:1) プッシュ可能=3ダイス" +success = true rands = [ { sides = 6, value = 2 }, { sides = 6, value = 4 }, @@ -795,6 +824,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2MYZ3" output = "(3D6) > [2,5,3] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:0,アイテム:0) プッシュ可能=3ダイス" +failure = true secret = true rands = [ { sides = 6, value = 2 }, @@ -806,6 +836,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2MYZ3+3" output = "(3D6)+(3D6) > [2,5,3]+[1,4,1] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:0,技能:2,アイテム:0) プッシュ可能=6ダイス" +failure = true secret = true rands = [ { sides = 6, value = 2 }, @@ -820,6 +851,7 @@ rands = [ game_system = "YearZeroEngine" input = "S2MYZ1+2+3" output = "(1D6)+(2D6)+(3D6) > [2]+[4,6]+[6,1,5] 成功数:2 難易度=2:判定成功!\n出目1:[能力:0,技能:0,アイテム:1) プッシュ可能=3ダイス" +success = true secret = true rands = [ { sides = 6, value = 2 }, @@ -834,6 +866,7 @@ rands = [ game_system = "YearZeroEngine" input = "2MYZ3+3+3" output = "(3D6)+(3D6)+(3D6) > [1,6,3]+[1,4,1]+[3,1,4] 成功数:1 難易度=2:判定失敗!\n出目1:[能力:1,技能:2,アイテム:1) プッシュ可能=6ダイス" +failure = true rands = [ { sides = 6, value = 1 }, { sides = 6, value = 6 }, @@ -845,3 +878,152 @@ rands = [ { sides = 6, value = 1 }, { sides = 6, value = 4 }, ] + +[[ test ]] +game_system = "YearZeroEngine" +input = "2MYZ3-3+3" +output = "(3D6)-(3D6)+(3D6) > [1,6,3]-[1,6,1]+[3,1,4] 成功数:0 難易度=2:判定失敗!\n出目1:[能力:1,技能:2,アイテム:1) プッシュ可能=5ダイス" +failure = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "2MYZ3-3+3" +output = "(3D6)-(3D6)+(3D6) > [1,6,3]-[1,6,6]+[3,1,4] 成功数:-1 難易度=2:判定失敗!\n出目1:[能力:1,技能:1,アイテム:1) プッシュ可能=4ダイス" +failure = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "2MYZ3-3+3" +output = "(3D6)-(3D6)+(3D6) > [1,6,6]-[1,6,2]+[6,1,4] 成功数:2 難易度=2:判定成功!\n出目1:[能力:1,技能:1,アイテム:1) プッシュ可能=3ダイス" +success = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "2MYZ3-3" +output = "(3D6)-(3D6) > [1,6,6]-[1,6,2] 成功数:1 難易度=2:判定失敗!\n出目1:[能力:1,技能:1,アイテム:0) プッシュ可能=2ダイス" +failure = true +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "2MYZ3-3" +output = "(3D6)-(3D6) > [6,6,6]-[1,6,2] 成功数:2 難易度=2:判定成功!\n出目1:[能力:0,技能:1,アイテム:0) プッシュ可能=2ダイス" +success = true +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, +] +[[ test ]] +game_system = "YearZeroEngine" +input = "MYZ3-3+3" +output = "(3D6)-(3D6)+(3D6) > [1,6,3]-[1,6,6]+[3,1,4] 成功数:-1\n出目1:[能力:1,技能:1,アイテム:1) プッシュ可能=4ダイス" +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 3 }, + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "MYZ3-3+3" +output = "(3D6)-(3D6)+(3D6) > [1,6,6]-[1,6,2]+[6,1,4] 成功数:2\n出目1:[能力:1,技能:1,アイテム:1) プッシュ可能=3ダイス" +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 4 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "MYZ3-3" +output = "(3D6)-(3D6) > [1,6,6]-[1,6,2] 成功数:1\n出目1:[能力:1,技能:1,アイテム:0) プッシュ可能=2ダイス" +rands = [ + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "MYZ3-3" +output = "(3D6)-(3D6) > [6,6,6]-[1,6,2] 成功数:2\n出目1:[能力:0,技能:1,アイテム:0) プッシュ可能=2ダイス" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, +] + +[[ test ]] +game_system = "YearZeroEngine" +input = "YZE3-3" +output = "YZEコマンドでは技能ダイスをマイナス指定できません。" +rands = [ + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 6 }, + { sides = 6, value = 1 }, + { sides = 6, value = 6 }, + { sides = 6, value = 2 }, +]