Ejemplo n.º 1
0
        public async Task AcceptMoveRequest(string index)
        {
            int gameId = GetCurrentGameId();
            var game   = await gamesCrudService.GetGameAsync(gameId);

            if (!game.IsAlive() || !int.TryParse(index, out int posIndex))
            {
                await Clients.Group(gameId.ToString()).SendAsync("Disconnect");
            }
            else
            {
                await HandleMoveRequest(game, posIndex);
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> TryEnterGameAsync(string connectionId, string login, int gameId)
        {
            var game = await gamesCrudService.GetGameAsync(gameId);

            if (!game.IsAlive())
            {
                await CloseGameAsync(gameId);

                return(false);
            }
            var user = await userCrudService.GetByLoginAsync(login);

            var res = game.Instance.RegistPlayer(connectionId, user);

            return(res);
        }
Ejemplo n.º 3
0
        public async Task CreateAsync(int gameId, int tagId)
        {
            var sessionData = (await gamesCrudService.GetGameAsync(gameId)).Data;

            if (sessionData != null && await unitOfWork.DbContext.Tags.AnyAsync(t => t.Id == tagId))
            {
                var entity = new SessionTag
                {
                    Session = sessionData,
                    TagId   = tagId
                };
                unitOfWork.DbContext.SessionTags.Add(entity);
                await unitOfWork.DbContext.SaveChangesAsync();
            }
        }