コード例 #1
0
ファイル: GameController.cs プロジェクト: clarson15/AIBracket
        public IActionResult GetFeaturedGame()
        {
            var game = GameCacheManager.GetFeaturedGameId();

            if (game == null)
            {
                return(Ok(0));
            }
            return(Ok(game));
        }
コード例 #2
0
 public static void Main(string[] args)
 {
     GameCacheManager.Start();
     CreateWebHostBuilder(args).Build().Run();
 }
コード例 #3
0
        public async Task <IActionResult> GetBotsByUser(string Id)
        {
            var data = await _userManager.FindByIdAsync(User.Claims.FirstOrDefault(x => x.Type == "id")?.Value);

            if (data == null || data.Id.ToString() != Id)
            {
                var bots1 = _appDbContext.Bots.Where(x => x.IdentityId.ToString() == Id).OrderBy(x => x.Game).Select(x => new { x.Id, x.Name, x.Game, Active = GameCacheManager.IsBotActive(x.Id.ToString()), HighScore = _appDbContext.PacmanGames.Where(y => y.BotId.ToString() == x.Id.ToString()).DefaultIfEmpty().Max(y => y.Score) });
                return(Ok(bots1));
            }
            var bots = _appDbContext.Bots.Where(x => x.IdentityId == data.Id).OrderBy(x => x.Game).Select(x => new { x.Id, x.Name, x.PrivateKey, x.Game, Active = GameCacheManager.IsBotActive(x.Id.ToString()), HighScore = _appDbContext.PacmanGames.Where(y => y.BotId.ToString() == x.Id.ToString()).DefaultIfEmpty().Max(y => y.Score) });

            return(Ok(bots));
        }