~xenrox/10man-ts3

8d5a7613b595baa4268eecad68b59625029514ba — Thorben Günther 2 years ago cf24405
Autostart match if 10 players are queueing up.
1 files changed, 26 insertions(+), 1 deletions(-)

M app.ts
M app.ts => app.ts +26 -1
@@ 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;
        }
    }
}