diff --git a/lib/bcdice/game_system/KemonoNoMori.rb b/lib/bcdice/game_system/KemonoNoMori.rb index d69c2649b..246bb24e0 100644 --- a/lib/bcdice/game_system/KemonoNoMori.rb +++ b/lib/bcdice/game_system/KemonoNoMori.rb @@ -42,25 +42,18 @@ class KemonoNoMori < Base def eval_game_system_specific_command(command) case command - when /KA\d[-+\d]*/ - return check_1D12(command, true) - when /KC\d[-+\d]*/ - return check_1D12(command, false) - when 'CTR' - return getTrapResult() - when 'EET' - return getEscapeExperienceTableResult(command) - else - return roll_tables(command, TABLES) + when /KA\d[-+\d]*/ then check_1D12(command, true) + when /KC\d[-+\d]*/ then check_1D12(command, false) + when 'CTR' then get_trap_result() + when 'EET' then get_escape_experience_table_result(command) + else roll_tables(command, TABLES) end end def check_1D12(command, is_action_judge) debug('獸ノ森の1d12判定') m = /K[AC](\d[-+\d]*)/.match(command) - unless m - return '' - end + return nil unless m # 修正込みの目標値を計算 target_total = ArithmeticEvaluator.eval(m[1]) @@ -74,41 +67,35 @@ def check_1D12(command, is_action_judge) debug('dice_total, target_total, success_degree = ', dice_total, target_total, success_degree) if dice_total == 12 - return "(1D12<=#{target_total}) > #{dice_total} > 大失敗" + Result.fumble("(1D12<=#{target_total}) > #{dice_total} > 大失敗") elsif dice_total == 11 - return "(1D12<=#{target_total}) > #{dice_total} > 大成功(成功度+#{success_degree}, 次の継続判定の目標値を10に変更)" + Result.critical("(1D12<=#{target_total}) > #{dice_total} > 大成功(成功度+#{success_degree}, 次の継続判定の目標値を10に変更)") elsif dice_total <= target_total - return "(1D12<=#{target_total}) > #{dice_total} > 成功(成功度+#{success_degree})" + Result.success("(1D12<=#{target_total}) > #{dice_total} > 成功(成功度+#{success_degree})") else - return "(1D12<=#{target_total}) > #{dice_total} > 失敗" + Result.failure("(1D12<=#{target_total}) > #{dice_total} > 失敗") end end - def getTrapResult() - trapCheckNumber = @randomizer.roll_once(12) - - # 12が出た場合のみ罠が動作する - if trapCheckNumber == 12 - chaseNumber = @randomizer.roll_once(12) - chase = nil - case chaseNumber - when 1, 2, 3, 4 - chase = '小型動物' - when 5, 6, 7, 8 - chase = '大型動物' - when 9, 10, 11, 12 - chase = '人間の放浪者' - end - return "罠動作チェック(1D12) > #{trapCheckNumber} > 罠が動作していた! > 獲物表(#{chaseNumber}) > #{chase}が罠にかかっていた" + def get_trap_result() + tra_check_num = @randomizer.roll_once(12) + unless tra_check_num == 12 + return Result.new("罠動作チェック(1D12) > #{tra_check_num} > 罠は動作していなかった") end - return "罠動作チェック(1D12) > #{trapCheckNumber} > 罠は動作していなかった" + chase_num = @randomizer.roll_once(12) + chase = case chase_num + when 1, 2, 3, 4 then '小型動物' + when 5, 6, 7, 8 then '大型動物' + when 9, 10, 11, 12 then '人間の放浪者' + end + Result.new("罠動作チェック(1D12) > #{tra_check_num} > 罠が動作していた! > 獲物表(#{chase_num}) > #{chase}が罠にかかっていた") end - def getEscapeExperienceTableResult(command) - escapeExperience = roll_tables(command, TABLES) - escapeDuration = @randomizer.roll_once(12) - return "#{escapeExperience} (再登場: #{escapeDuration}時間後)" + def get_escape_experience_table_result(command) + escape_experience = roll_tables(command, TABLES) + escape_duration = @randomizer.roll_once(12) + Result.new("#{escape_experience} (再登場: #{escape_duration}時間後)") end TABLES = { diff --git a/test/data/KemonoNoMori.toml b/test/data/KemonoNoMori.toml index 7bbd18779..7b635b85f 100644 --- a/test/data/KemonoNoMori.toml +++ b/test/data/KemonoNoMori.toml @@ -2,6 +2,7 @@ game_system = "KemonoNoMori" input = "KA9" output = "(1D12<=9) > 1 > 成功(成功度+1)" +success = true rands = [ { sides = 12, value = 1 }, ] @@ -10,6 +11,7 @@ rands = [ game_system = "KemonoNoMori" input = "KA8+1" output = "(1D12<=9) > 9 > 成功(成功度+1)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -18,6 +20,7 @@ rands = [ game_system = "KemonoNoMori" input = "ka10" output = "(1D12<=10) > 9 > 成功(成功度+2)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -26,6 +29,7 @@ rands = [ game_system = "KemonoNoMori" input = "KA18+2-1" output = "(1D12<=19) > 9 > 成功(成功度+2)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -34,6 +38,7 @@ rands = [ game_system = "KemonoNoMori" input = "KA20" output = "(1D12<=20) > 9 > 成功(成功度+3)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -42,6 +47,7 @@ rands = [ game_system = "KemonoNoMori" input = "KA9" output = "(1D12<=9) > 10 > 失敗" +failure = true rands = [ { sides = 12, value = 10 }, ] @@ -50,6 +56,8 @@ rands = [ game_system = "KemonoNoMori" input = "kA9" output = "(1D12<=9) > 11 > 大成功(成功度+1, 次の継続判定の目標値を10に変更)" +success = true +critical = true rands = [ { sides = 12, value = 11 }, ] @@ -58,6 +66,8 @@ rands = [ game_system = "KemonoNoMori" input = "ka10" output = "(1D12<=10) > 11 > 大成功(成功度+2, 次の継続判定の目標値を10に変更)" +success = true +critical = true rands = [ { sides = 12, value = 11 }, ] @@ -66,6 +76,8 @@ rands = [ game_system = "KemonoNoMori" input = "KA19" output = "(1D12<=19) > 11 > 大成功(成功度+2, 次の継続判定の目標値を10に変更)" +success = true +critical = true rands = [ { sides = 12, value = 11 }, ] @@ -74,6 +86,8 @@ rands = [ game_system = "KemonoNoMori" input = "SKa20" output = "(1D12<=20) > 11 > 大成功(成功度+3, 次の継続判定の目標値を10に変更)" +success = true +critical = true secret = true rands = [ { sides = 12, value = 11 }, @@ -83,6 +97,8 @@ rands = [ game_system = "KemonoNoMori" input = "KA12" output = "(1D12<=12) > 12 > 大失敗" +failure = true +fumble = true rands = [ { sides = 12, value = 12 }, ] @@ -91,6 +107,7 @@ rands = [ game_system = "KemonoNoMori" input = "KC9" output = "(1D12<=9) > 1 > 成功(成功度+1)" +success = true rands = [ { sides = 12, value = 1 }, ] @@ -99,6 +116,7 @@ rands = [ game_system = "KemonoNoMori" input = "SKC8+1" output = "(1D12<=9) > 9 > 成功(成功度+1)" +success = true secret = true rands = [ { sides = 12, value = 9 }, @@ -108,6 +126,7 @@ rands = [ game_system = "KemonoNoMori" input = "kc10" output = "(1D12<=10) > 9 > 成功(成功度+1)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -116,6 +135,7 @@ rands = [ game_system = "KemonoNoMori" input = "KC18-1+2" output = "(1D12<=19) > 9 > 成功(成功度+1)" +success = true rands = [ { sides = 12, value = 9 }, ] @@ -124,6 +144,7 @@ rands = [ game_system = "KemonoNoMori" input = "skc17+1+1+1" output = "(1D12<=20) > 9 > 成功(成功度+1)" +success = true secret = true rands = [ { sides = 12, value = 9 }, @@ -133,6 +154,7 @@ rands = [ game_system = "KemonoNoMori" input = "kC9" output = "(1D12<=9) > 10 > 失敗" +failure = true rands = [ { sides = 12, value = 10 }, ] @@ -141,6 +163,8 @@ rands = [ game_system = "KemonoNoMori" input = "KC10" output = "(1D12<=10) > 11 > 大成功(成功度+1, 次の継続判定の目標値を10に変更)" +success = true +critical = true rands = [ { sides = 12, value = 11 }, ] @@ -149,6 +173,8 @@ rands = [ game_system = "KemonoNoMori" input = "Kc20" output = "(1D12<=20) > 11 > 大成功(成功度+1, 次の継続判定の目標値を10に変更)" +success = true +critical = true rands = [ { sides = 12, value = 11 }, ] @@ -157,6 +183,8 @@ rands = [ game_system = "KemonoNoMori" input = "Skc12" output = "(1D12<=12) > 12 > 大失敗" +failure = true +fumble = true secret = true rands = [ { sides = 12, value = 12 },