diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-11 17:50:02 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-11 17:50:02 +0100 |
| commit | 0e9e28c2595c1ec46d8601efa6f4d377ee70cb27 (patch) | |
| tree | aa57be9270ca05d8f8f7f497e6409ead84ed99cd /utils.mjs | |
| parent | 5dcf65616f82cb9b652f6913c93e26ff50983fdf (diff) | |
First version of proposal
Diffstat (limited to 'utils.mjs')
| -rw-r--r-- | utils.mjs | 31 |
1 files changed, 17 insertions, 14 deletions
@@ -12,17 +12,20 @@ export function addToggleBehaviour(list, description) { } } -// document.querySelector("#player-load input[type=file]").onchange = () => { -// if (fileInput.files.length > 0) { -// const file = fileInput.files[0]; -// if (file) { -// const reader = new FileReader(); -// reader.onload = function(e) { -// const content = e.target.result; -// regulars = csvToPlayers(content); -// addToggleBehaviour(regulars, "regular_"); -// }; -// reader.readAsText(file); -// } -// } -// }
\ No newline at end of file +export function getMatchCount(regulars, courts) { + const activeCourts = courts.filter(function (c) { return c.status }); + console.log("There are a total of " + activeCourts.length + " courts available."); + const activePlayers = regulars.filter(function (p) { return p.status;}); + console.log("There are a total of " + activePlayers.length + " players available."); + var possibleMatches = Math.floor(activePlayers.length / 4); + possibleMatches = possibleMatches > activeCourts.length ? activeCourts.length : possibleMatches; + return possibleMatches; +} + +export function shuffle(array) { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; +}
\ No newline at end of file |
