コード例 #1
0
        public IActionResult Index()
        {
            //Create an instance of the GameBoardViewModel
            GameBoardViewModel game = new GameBoardViewModel();

            //Instantiate the game business class
            gameRules = new GameBusinessService();

            //Setup the game board
            gameBoard  = gameRules.SetupGame(10, gameBoard);
            gameStatus = "In Progress";
            MyLogger.GetInstance().Info("Session - " + HttpContext.Session.GetString("username"));
            //If the session is not empty - user logged in
            if (!string.IsNullOrEmpty(HttpContext.Session.GetString("username")))
            {
                //Grab their username
                userName = HttpContext.Session.GetString("username");
            }
            else
            {
                userName = "";
            }


            game.GameBoard  = gameBoard;
            game.numOfClick = clicks;
            game.UserName   = userName;

            //Pass the GameBoardViewModel with the next view
            return(View("Index", game));
        }
コード例 #2
0
        //Manages request when a player wants to play new game
        public IActionResult PlayAgain()
        {
            //Reset the click proprty and gamestatus
            clicks     = 0;
            gameStatus = "In Progress";

            //Setup the game board
            gameBoard = gameRules.SetupGame(10, gameBoard);


            //Create game board view model
            GameBoardViewModel game = new GameBoardViewModel();

            game.GameBoard  = gameBoard;
            game.UserName   = userName;
            game.numOfClick = clicks;

            return(View("Index", game));
        }