From 8d5a7613b595baa4268eecad68b59625029514ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Mon, 8 Nov 2021 16:58:57 +0100 Subject: [PATCH] Autostart match if 10 players are queueing up. --- app.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app.ts b/app.ts index 06634f4..aa1adcd 100644 --- a/app.ts +++ b/app.ts @@ -175,7 +175,12 @@ async function play(clid: string, teamspeakID: string) { try { const data = await request(mutation, variables); - message_channel(data.startQueue + " player(s) in queue."); + const players = data.startQueue; + message_channel(players + " player(s) in queue."); + + if (players == 10) { + start_match(); + } } catch (e) { const error = get_error(e); switch (error) { @@ -285,3 +290,23 @@ async function finish_match(clid: string, teamspeakID: string, winner: string) { } } } + +async function start_match() { + const mutation = gql` + mutation { + createMatch + } + `; + + try { + const data = await request(mutation); + message_channel("Started match."); + } catch (e) { + const error = get_error(e); + switch (error) { + default: + console.error(error); + break; + } + } +} -- 2.44.0