/// <summary> /// Decreases the kind action scales for all users. /// </summary> /// <returns></returns> public Task <OperationResult> DecreaseKindActionScales() { return (_azureManager.UpdateEntitiesAsync( new TableQuery <UserAzure>().Where( TableQuery.GenerateFilterConditionForInt("KindScale", QueryComparisons.GreaterThan, 0)) .Select(new[] { "KindScale", "KindScaleHighCurrentDays", "KindScaleHighMaxDays" }), async users => { foreach (var user in users) { if (user.KindScale < GameConstants.KindScale.DailyRegression) { user.KindScale = 0; user.KindScaleHighCurrentDays = 0; } else { if (user.KindScale > GameConstants.KindScale.AchievementLimit) { user.KindScaleHighCurrentDays = (user.KindScaleHighCurrentDays ?? 0) + 1; if (!user.KindScaleHighMaxDays.HasValue || user.KindScaleHighCurrentDays > user.KindScaleHighMaxDays) { user.KindScaleHighMaxDays = user.KindScaleHighCurrentDays; } } user.KindScale -= GameConstants.KindScale.DailyRegression; } await _azureManager.UpdateEntityAsync(user, replace: false); } })); }