summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-22 18:16:29 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-05 18:01:19 +0200
commite1dc03774b9efec0df14bdf59159bcb597cd0a82 (patch)
treea2deb93ec325fed556c3a75e38b01b99a962d1ff
parent0e7af3c6ae2b61a2a02a4a1dfbcd63f714a505a1 (diff)
downloadfuzzer-e1dc03774b9efec0df14bdf59159bcb597cd0a82.tar.gz
allow dynamic roles list
-rwxr-xr-xrtt-module.js10
1 files 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)