/// <summary> /// join action /// </summary> /// <param name="guest">guest</param> /// <param name="name">name of game to join</param> /// <returns></returns> public string joinToGame(TcpClient guest, string name) { //find if (poolGameToJoin.ContainsKey(name)) { //get MultiPlayerGame multiGame = poolGameToJoin[name]; //set multiGame.setGuest(guest); string stringJoinJson = poolGameToJoin[name].getMaze().ToJSON(); allActivePoolGame.Add(name, multiGame); poolGameToJoin.Remove(name); return(stringJoinJson); } // else Console.WriteLine("server - there is no free player to play"); return("client - there is no free player to play"); }
/// <summary> /// for start action /// </summary> /// <param name="host">the host</param> /// <param name="name">name of the game</param> /// <param name="rows">rows</param> /// <param name="cols">col</param> /// <returns></returns> public string startGame(TcpClient host, string name, int rows, int cols) { Maze maze; // check if we have exist maze, if not -create new one if (poolMaze.ContainsKey(name)) { maze = poolMaze[name]; } else { maze = generateMaze(name, rows, cols); } //make a multi game MultiPlayerGame multiGame = new MultiPlayerGame(host, maze); poolGameToJoin.Add(maze.Name, multiGame); //wait multiGame.waitForGuest(); return(maze.ToJSON()); }