public async void GetOnlinePlayers(ITibiaService tibiaService, IEventPublisher eventPublisher) { if (_hasRun) { var members = await tibiaService.GetMemberCharacters(); var onlinePlayers = tibiaService.GetOnlineCharactersFromTibia(); foreach (var member in members) { if (onlinePlayers.Any(o => o.Name == member.Name)) { tibiaService.LogOnlineTime(member); var onlinePlayer = onlinePlayers.Single(o => o.Name == member.Name); if (member.Level == 0) { member.Level = onlinePlayer.Level; tibiaService.UpdateCharacter(member); } if (member.Level < onlinePlayer.Level) { await eventPublisher.ProcessEvent($"{member.Name} has leveled up!", member.User, EventDefinitionService.StaticEventIDs.LevelUp, false); member.Level = onlinePlayer.Level; tibiaService.UpdateCharacter(member); } } } } }
// GET: /<controller>/ public IActionResult Index() { ViewBag.Statistics = _tibiaService.GetOnlineCharactersFromTibia(); return(View()); }