示例#1
0
        public PartialViewResult ActivateCell(string x, string y)
        {
            int            USERID      = int.Parse(new JavaScriptSerializer().Serialize(Session["userid"]));
            int            Column      = int.Parse(x.Trim());
            int            Row         = int.Parse(y.Trim());
            GameLogicBLL   gameService = new GameLogicBLL();
            GameBoardModel grid        = Globals.Grid;

            grid.Cells[Column, Row].IsVisited = true;

            Globals.numberClicks++;
            grid.Clicks = Globals.numberClicks;

            if (grid.Cells[Column, Row].IsLive)
            {
                gameService.PublishGameStats(grid, USERID, this.ElapsedTime());
                return(EndGame());
            }
            else
            {
                if (grid.Cells[Column, Row].LiveNeighbors == 0)
                {
                    gameService.showNeighbors(Globals.Grid, Globals.Grid.Cells[Column, Row].Column, Globals.Grid.Cells[Column, Row].Row);
                }
                gameService.UpdateGrid(grid, USERID);
            }

            return(PartialView("Index", grid));
        }
示例#2
0
        public ActionResult resetGame()
        {
            int          USERID      = int.Parse(new JavaScriptSerializer().Serialize(Session["userid"]));
            GameLogicBLL gameService = new GameLogicBLL();

            gameService.deleteGrid(USERID);
            Globals.numberClicks = 0;
            return(View("Index", gameService.CreateGrid(25, 25, USERID)));
        }
示例#3
0
        public ActionResult Index()
        {
            int          USERID      = int.Parse(new JavaScriptSerializer().Serialize(Session["userid"]));
            GameLogicBLL gameService = new GameLogicBLL();

            if (Session["user"] != null)
            {
                Globals.Grid = gameService.FindGrid(USERID);

                if (Globals.Grid == null)
                {
                    Globals.Grid = gameService.CreateGrid(25, 25, USERID);
                }
            }
            else
            {
                ModelError e = new ModelError("You must be logged in to access this page.");
            }

            return(View("Index", Globals.Grid));
        }