Exemple #1
0
        private async Task InitializationOfTheGame(WebSocket websocket)
        {
            command = "JoinGame";

            int sizeOfPlayers = manager.GetTotalPlayers() > 6 ? 6 : manager.GetTotalPlayers();

            game.InstantiateGameSession(sizeOfPlayers);
            List <WebSocket> playersPlaying = manager.GetFirstPlayersPlaying(sizeOfPlayers);

            bool isCreator;
            bool isPlaying = true;

            GameStatus gameStatus = game.gameStatus;

            for (int playerID = 0; playerID < playersPlaying.Count; playerID++)
            {
                if (websocket == playersPlaying[playerID])
                {
                    isCreator = true;
                }
                else
                {
                    isCreator = false;
                }

                await SendJSON(playersPlaying[playerID], new
                {
                    command,
                    gameStatus,
                    playerID,
                    sizeOfPlayers,
                    isPlaying,
                    isCreator
                });
            }
        }