/// <summary>
        /// Обработчик главной страницы
        /// </summary>
        public async Task <IActionResult> Index()
        {
            var model = new HomeIndexModel()
            {
                AvailableGames = GamePackage.ListAvailable()
                                 .Select(pkg => GameInfo.FromGamePackage(pkg))
                                 .ToList(),
                ActiveSessions = sessionsManager.GetSessions()
                                 .Select(s => SessionInfo.FromGameSession(s))
                                 .OrderBy(si => si.StartedAt)
                                 .ToList()
            };

            if (model.IsSigned)
            {
                try
                {
                    var playerSession = userCtx.GetGameSession();
                    model.PlayerSession = SessionInfo.FromGameSession(playerSession);
                    model.IsSigned      = true;
                }
                catch (NullReferenceException)
                {
                    await userCtx.PerformLogout();
                }
            }

            return(View(model));
        }
Esempio n. 2
0
        public async Task CreateSessionTest()
        {
            await manager.StartNewGame(GameName, testGameMaster);

            Assert.AreNotEqual(0, manager.GetSessions().Count);
        }