Exemplo n.º 1
0
        /*/// <summary>
         * /// Plays a move in the maze according to the gamer.
         * /// </summary>
         * /// <param name="move">The move.</param>
         * /// <param name="gamer">The gamer.</param>
         * /// <returns></returns>
         * public string PlayMove(string move, ClientNotifier gamer)
         * {
         *  MultiGame game = cash.GetGameByGamer(gamer);
         *  JMove jMove = new JMove(game.Name, move);
         *  string json = JsonConvert.SerializeObject(jMove);
         *  game.UpdateMove(json, gamer);
         *
         *  return json;
         * }*/

        /// <summary>
        /// Closes the game.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="gamer">The gamer.</param>
        /// <returns></returns>
        public void CloseGame(string name)
        {
            //MultiGame game = cash.GetGame(name);
            MultiGame game = cash.GetMultiGame(name);

            //game.CloseGame();

            //cash.RemoveGame(name);
            cash.RemoveMultiGame(name);
        }
Exemplo n.º 2
0
        public void AddMultiGame(string name, MultiGame game)
        {
            if (multiGames.ContainsKey(name))
            {
                multiGames[name] = game;
                return;
            }

            multiGames.Add(name, game);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Connect a gamer to the game.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="gamer">The gamer.</param>
        /// <returns></returns>
        public Maze JoinGame(string name, string gamer)
        {
            //MultiGame game = cash.GetGame(name);
            MultiGame game = cash.GetMultiGame(name);

            game.AddGamer(gamer);
            //game.NotifyGamers();

            Maze maze = game.Maze;

            return(maze);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts the game.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="rows">The rows.</param>
        /// <param name="cols">The cols.</param>
        /// <param name="gamer">The gamer.</param>
        /// <returns></returns>
        public Maze StartGame(string name, int rows, int cols, string player /*, ClientNotifier gamer*/)
        {
            //Maze maze = GenerateMaze(name, rows, cols);
            IMazeGenerator mazeGenerator = new DFSMazeGenerator();
            Maze           maze          = mazeGenerator.Generate(rows, cols);

            maze.Name = name;
            MultiGame game = new MultiGame(name, maze, player);

            //game.AddGamer(gamer);
            //cash.AddGame(name, game);
            cash.AddMultiGame(name, game);
            return(maze);
        }