Example #1
0
        public void Attack(Guid gameId, string userId, Location target)
        {
            try
            {
                _authorizer.AssertAuthorizedForAttack(userId, gameId);

                var game = _repo.Get(gameId);

                game.Attack(userId, target);

                _logger.Info($"Player {game.GetPlayerNumber(userId)} attacked {target.ToString()}");

                _repo.Update(gameId, game);
            }
            catch (InvalidOperationException ex)
            {
                _logger.Warn($"An error occurred attacking: {ex.Message}");
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error("An error occurred attacking", ex);
                throw;
            }
        }