public TelegramUtil(Client client, Telegram.Bot.TelegramBotClient telegram, PokeMaster.Logic.Shared.ISettings settings, Inventory inv) { instance = this; _client = client; _telegram = telegram; _botSettings = settings; _inventory = inv; Array values = Enum.GetValues(typeof(TelegramUtilInformationTopics)); foreach (TelegramUtilInformationTopics topic in values) { _informationDescription[topic] = TranslationHandler.GetString(_informationDescriptionIDs[topic], _informationDescriptionDefault[topic]); _information[topic] = false; } DoLiveStats(settings); DoInformation(); }
public async void DoLiveStats(PokeMaster.Logic.Shared.ISettings settings) { try { if (_chatid != -1 && _livestats) { var usage = ""; var inventory = _client.Inventory.GetHoloInventory(); var profil = _client.Player.GetPlayer(); var stats = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData.PlayerStats).ToArray(); foreach (var c in stats) { if (c != null) { int l = c.Level; var expneeded = ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)); var curexp = ((c.Experience - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)); var curexppercent = (Convert.ToDouble(curexp) / Convert.ToDouble(expneeded)) * 100; usage += "\nNickname: " + profil.PlayerData.Username + "\nLevel: " + c.Level + "\nEXP Needed: " + ((c.NextLevelXp - c.PrevLevelXp) - StringUtils.getExpDiff(c.Level)) + $"\nCurrent EXP: {curexp} ({Math.Round(curexppercent)}%)" + "\nEXP to Level up: " + ((c.NextLevelXp) - (c.Experience)) + "\nKM walked: " + c.KmWalked + "\nPokeStops visited: " + c.PokeStopVisits + "\nStardust: " + profil.PlayerData.Currencies.ToArray()[1].Amount; } } await _telegram.SendTextMessageAsync(_chatid, usage, replyMarkup : new ReplyKeyboardHide()).ConfigureAwait(false); } await System.Threading.Tasks.Task.Delay(settings.TelegramLiveStatsDelay).ConfigureAwait(false); DoLiveStats(settings); } catch (Exception ex1) { Logger.ExceptionInfo(ex1.ToString()); } }