コード例 #1
0
        public async Task <IActionResult> SaveFullCharacterDataAsync([FromRoute(Name = "id")] int characterId,
                                                                     [FromBody][NotNull] FullCharacterDataSaveRequest request,
                                                                     [NotNull][FromServices] ICharacterLocationRepository locationRepository,
                                                                     [NotNull][FromServices] IZoneServerRepository zoneRepository,
                                                                     [FromServices][NotNull] ICharacterDataRepository characterDataRepository)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (characterId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(characterId));
            }

            //TODO: Is it safe to not do this as a transaction??
            //TODO: For HTTP callers we should maybe include better information. Though with message queue we can't respond.
            if (!await CheckZoneAuthorizedToModifyCharacterData(characterId))
            {
                return(Forbid());
            }

            //Don't always want to save the position of the user.
            if (request.isPositionSaved)
            {
                await UpdateCharacterLocation(characterId, request.CharacterLocationData, locationRepository, zoneRepository);
            }

            //TODO: Probably need to handle this abit better and more data than just experience.
            //Entity data can now be saved.
            await UpdatePlayerData(characterId, new CharacterDataInstance(request.PlayerDataSnapshot.GetFieldValue <int>(PlayerObjectField.PLAYER_TOTAL_EXPERIENCE)), characterDataRepository);

            if (request.ShouldReleaseCharacterSession)
            {
                await CharacterSessionRepository.TryDeleteClaimedSession(characterId);
            }

            return(Ok());
        }
コード例 #2
0
 public async Task SaveFullCharacterDataAsync(int characterId, FullCharacterDataSaveRequest saveRequest)
 {
     await(await GetService().ConfigureAwaitFalse()).SaveFullCharacterDataAsync(characterId, saveRequest).ConfigureAwaitFalseVoid();
 }