private GainExpModel CalculateExpForAccount(uint level) { uint expAmount = ExpirienceCalculator.GetOnlineRewardForLevel(level); var expModel = new GainExpModel { Amount = expAmount, GainReason = GainExpReason.Online, TimeStamp = DateTime.Now }; return(expModel); }
private void OnDelayedEvent() { IEnumerable <ComplexAccountState> onlineStates = stateService.GetAllOnline(); Parallel.ForEach(onlineStates, state => { uint userPreviousLevel = state.ComplexAccount.Level; GainExpModel model = CalculateExpForAccount(state.ComplexAccount.Level); state.ComplexAccount.AddExp(model.Amount); informerService.NotifyUserOfExpAddition(state, model); uint userNewLevel = ExpirienceCalculator.GetLevelForExp((uint)state.ComplexAccount.Expirience); if (userNewLevel > userPreviousLevel) { Task.Run(() => informerService.NotifyAllFriendsAboutUser(state)); } }); stateService.FlushStates(); delayedInvoker.RequestDelayedEvent(); }