Beispiel #1
0
        public IHttpActionResult GetMaze(string name, int rows, int cols)
        {
            MazeGame game    = (MazeGame)model.GenerateNewGame(name, rows, cols);
            WebMaze  newMaze = new WebMaze();

            newMaze.SetMaze(game.maze);
            //Add to list.
            mazes.Add(newMaze);
            return(Ok(newMaze));
        }
Beispiel #2
0
        /// <summary>
        /// generate a new multi player game with the name name. This function adds the
        /// generating client to the game.
        /// </summary>
        /// <param name="clientId"> string - The requesting client id </param>
        /// <param name="name"> string - the generated maze name </param>
        /// <param name="rows"> int - the number of rows in the generated maze </param>
        /// <param name="cols"> int - the number of cols in the generated maze </param>
        /// <param name="username"> string - The requesting client username(he has to be signed in) </param>
        public static void StartGame(string clientId, string name, int rows, int cols, string username)
        {
            //Generate new game.
            GameInfo info   = new GameInfo();
            MazeGame game   = (MazeGame)model.GenerateNewGame(name, rows, cols);
            WebMaze  myMaze = new WebMaze();

            //Set the maze.
            myMaze.SetMaze(game.maze);
            //Save info in GameInfo
            info.Maze          = myMaze;
            info.FirstClient   = clientId;
            info.FirstUsername = username;
            //Add to list.
            gameInformation.Add(info);
            clientToGameInfo[clientId] = info;
        }