From 3e8fe76752d0be4d09744dc854bf0144cfc4a9a6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 14 Jun 2022 20:34:27 +0200 Subject: Remove exports.ready function. --- rules.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/rules.js b/rules.js index 1457abd..f14ba5c 100644 --- a/rules.js +++ b/rules.js @@ -49,6 +49,13 @@ const player_names = [ "None" ] +const player_names_by_scenario = { + "2P": player_names.slice(0, 2), + "3P": player_names.slice(0, 3), + "4P": player_names.slice(0, 4), + "5P": player_names.slice(0, 5), +} + const player_index = Object.fromEntries(Object.entries(player_names).map(([k,v])=>[v,k|0])) const region_names = { @@ -126,21 +133,7 @@ const scenario_player_count = { "2P": 2, "3P": 3, "4P": 4, "5P": 5 } exports.scenarios = [ "3P", "4P", "5P", "2P" ] exports.roles = function (scenario) { - switch (scenario) { - case "2P": return player_names.slice(0, 2) - case "3P": return player_names.slice(0, 3) - case "4P": return player_names.slice(0, 4) - case "5P": return player_names.slice(0, 5) - } -} - -exports.ready = function (scenario, options, players) { - switch (scenario) { - case "2P": return players.length === 2 - case "3P": return players.length === 3 - case "4P": return players.length === 4 - case "5P": return players.length === 5 - } + return player_names_by_scenario[scenario] } function random(n) { -- cgit v1.2.3