From 3911f51480bae09baeb2942249ff5bba07258ff0 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Sat, 6 Jan 2024 13:34:24 +0100 Subject: detect undo causing an active player switch --- rtt-module.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'rtt-module.js') diff --git a/rtt-module.js b/rtt-module.js index b7e727d..af49030 100755 --- a/rtt-module.js +++ b/rtt-module.js @@ -31,6 +31,8 @@ module.exports.fuzz = function(fuzzerInputData) { let seed = data.consumeIntegralInRange(1, 2**35-31) let scenarios = Array.isArray(RULES.scenarios) ? RULES.scenarios : Object.values(RULES.scenarios).flat() let scenario = data.pickValue(scenarios) + // if (scenario.startsWith("Random")) + // return // TODO randomize options const options = {} @@ -133,6 +135,11 @@ module.exports.fuzz = function(fuzzerInputData) { log_crash(game_setup, state, view, step, active, action, args) throw new RulesCrashError(e, e.stack) } + + if (action === "undo" && state.active !== active) { + log_crash(game_setup, state, view, step, active) + throw new UndoActiveError(`undo caused active to switch from ${active} to ${state.active}`) + } step += 1 } } @@ -181,6 +188,13 @@ class InvalidActionArgument extends Error { } } +class UndoActiveError extends Error { + constructor(message) { + super(message) + this.name = "UndoActiveError" + } +} + class RulesCrashError extends Error { constructor(message, stack) { super(message) -- cgit v1.2.3