Example #1
0
 // GET: Room
 public ActionResult Index(Lobby lobby)
 {
     var cookie = Request.Cookies["userid"];
     if (cookie == null)
         return Redirect("/");
     ViewBag.RoomContainer = lobby;
     var username = FormsAuthentication.Decrypt(cookie.Value).Name;
     var currentUser = lobby.GetPlayerByName(username);
     var room = currentUser?.Room;
     ViewBag.CanJoin = room == null || !room.IsFull;
     ViewBag.CurrentUser = currentUser;
     return View();
 }
Example #2
0
        // GET: Game
        public ActionResult Index(Lobby lobby)
        {
            var cookie = Request.Cookies["userid"];
            if (cookie == null)
                return Redirect("/");
            var userName = FormsAuthentication.Decrypt(cookie.Value).Name;
            var currentPlayer = lobby.GetPlayerByName(userName);
            var room = currentPlayer?.Room;
            if (room == null)
                return RedirectToRoute(new {controller="Home"});
            var gameSession = room.CreateGameSession();
            ViewBag.Player =  gameSession.Players.Single(p => p.Name == userName);

            Response.CacheControl = "no-cache";
            return View(gameSession);
        }