Beispiel #1
0
 private void CheckPermission(Game game)
 {
     if (game.CurrentPlayer.UserId != this.userProvider.GetCurrentUserId())
     {
         throw new Exceptions.ApplicationException("Only current player can perform actions", ErrorCode.UserIsNotAllowedToPerformAction);
     }
 }
Beispiel #2
0
        private DTO.Games.GameActionResult CommitAndGetGameActionResult(Game game)
        {
            var gameActionResult = Mapper.Map <Domain.Games.Game, DTO.Games.GameActionResult>(game, opts => opts.Items.Add("userId", this.CurrentUserId));

            var changedCountries = game.Map.ChangedCountries.ToList();

            foreach (var visibilityModifier in game.Options.VisibilityModifier)
            {
                var visibilityModifierInstance = this.visibilityModifierFactory.Construct(visibilityModifier);

                visibilityModifierInstance.Expand(this.CurrentUser, game, changedCountries);
            }

            gameActionResult.CountryUpdates = Mapper.Map <IEnumerable <DTO.Games.Map.Country> >(changedCountries.ToArray()).ToArray();
            gameActionResult.UnitsToPlace   = game.GetUnitsToPlace(this.mapTemplateProvider.GetTemplate(game.MapTemplateName), game.CurrentPlayer);

            this.UnitOfWork.Commit();

            return(gameActionResult);
        }
 private MapTemplate GetMapTemplate(Game game)
 {
     return this.mapTemplateProvider.GetTemplate(game.MapTemplateName);
 }
        private DTO.Games.GameActionResult CommitAndGetGameActionResult(Game game)
        {
            var gameActionResult = Mapper.Map<Domain.Games.Game, DTO.Games.GameActionResult>(game);

            var changedCountries = game.Map.ChangedCountries.ToList();
            foreach(var visibilityModifier in game.Options.VisibilityModifier)
            {
                var visibilityModifierInstance = this.visibilityModifierFactory.Construct(visibilityModifier);

                visibilityModifierInstance.Expand(this.CurrentUser, game, changedCountries);
            }

            gameActionResult.CountryUpdates = Mapper.Map<IEnumerable<DTO.Games.Map.Country>>(changedCountries.ToArray()).ToArray();
            this.UnitOfWork.Commit();

            return gameActionResult;
        }
 private void CheckPermission(Game game)
 {
     if (game.CurrentPlayer.UserId != this.userProvider.GetCurrentUserId())
     {
         throw new Exceptions.ApplicationException("Only current player can perform actions", ErrorCode.UserIsNotAllowedToPerformAction);
     }
 }
Beispiel #6
0
 private MapTemplate GetMapTemplate(Game game)
 {
     return(this.mapTemplateProvider.GetTemplate(game.MapTemplateName));
 }