Ejemplo n.º 1
0
        public void JoinRoom(string nickname, string roomID)
        {
            GameManagerModel gameManager = GameManagerModel.GetInstance();
            GameModel        game        = gameManager.GetGame(roomID);

            if (game == null)
            {
                Clients.Caller.throwExeption();
            }
            else
            {
                game.AddPlayer(new PlayerModel(nickname, Context.ConnectionId));
                Clients.Caller.submitJoinRoomForm();
            }
        }
Ejemplo n.º 2
0
        public async Task NewRoom(string nickname)
        {
            GameManagerModel gameManager = GameManagerModel.GetInstance();

            Random      random       = new Random();
            int         randomNumber = random.Next(0, 9999);
            string      newID        = randomNumber.ToString("D4");
            GameModel   newGame      = new GameModel(newID, 5); //change to new input textbox!
            PlayerModel newPlayer    = new PlayerModel(nickname, Context.ConnectionId);

            newGame.AddPlayer(newPlayer);
            gameManager.AddGame(newGame);

            await Groups.Add(Context.ConnectionId, newID);

            Clients.Caller.submitNewRoomForm(newID);
        }