From e1dc03774b9efec0df14bdf59159bcb597cd0a82 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 May 2024 18:16:29 +0200 Subject: allow dynamic roles list --- rtt-module.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rtt-module.js b/rtt-module.js index 5c7e3c6..e035ed7 100755 --- a/rtt-module.js +++ b/rtt-module.js @@ -42,10 +42,14 @@ module.exports.fuzz = function(fuzzerInputData) { // TODO randomize options const options = {} + let roles = RULES.roles + if (typeof roles === "function") + roles = roles(scenario, options) + const ctx = { data: fuzzerInputData, - player_count: RULES.roles.length, - players: RULES.roles.map(r => ({role: r, name: "rtt-fuzzer"})), + player_count: roles.length, + players: roles.map(r => ({role: r, name: "rtt-fuzzer"})), scenario, options, replay: [], @@ -70,7 +74,7 @@ module.exports.fuzz = function(fuzzerInputData) { ctx.active = ctx.state.active if (ctx.active === 'Both' || ctx.active === 'All') { // If multiple players can act, we'll pick a random player to go first. - ctx.active = data.pickValue(RULES.roles) + ctx.active = data.pickValue(roles) } const state_freeze = JSON.stringify(ctx.state) -- cgit v1.2.3