public void BattleUpdated() { Dispatcher.InvokeAsync(delegate { lock (_bot) { if (_bot.Game != null && _bot.Game.ActiveBattle != null) { OpponentName.Text = PokemonNamesManager.Instance.Names[_bot.Game.ActiveBattle.OpponentId]; if (_bot.Game.ActiveBattle.IsShiny) { OpponentName.Text = "Shiny " + OpponentName.Text; } if (_bot.Game.ActiveBattle.IsWild) { OpponentName.Text = "Wild " + OpponentName.Text; } OpponentCaughtIcon.Visibility = _bot.Game.ActiveBattle.AlreadyCaught ? Visibility.Visible : Visibility.Hidden; OpponentLevel.Text = _bot.Game.ActiveBattle.OpponentLevel.ToString(); OpponentMaxHealth.Text = _bot.Game.ActiveBattle.OpponentHealth.ToString(); OpponentCurrentHealth.Text = _bot.Game.ActiveBattle.CurrentHealth.ToString(); if (_bot.Game.ActiveBattle.OpponentStatus.ToLowerInvariant() == "none") { OpponentStatus.Text = ""; } else { OpponentStatus.Text = _bot.Game.ActiveBattle.OpponentStatus; } OpponentType1.Text = TypesManager.Instance.Type1[_bot.Game.ActiveBattle.OpponentId].ToString(); OpponentType2.Text = TypesManager.Instance.Type2[_bot.Game.ActiveBattle.OpponentId].ToString(); string gender = _bot.Game.ActiveBattle.OpponentGender; OpponentGender.Icon = gender == "M" ? FontAwesomeIcon.Mars : gender == "F" ? FontAwesomeIcon.Venus : FontAwesomeIcon.Question; OpponentForm.Text = _bot.Game.ActiveBattle.AlternateForm.ToString(); PokemonStats stats = EffortValuesManager.Instance.BattleValues[_bot.Game.ActiveBattle.OpponentId]; List <string> evs = new List <string>(); foreach (StatType type in Enum.GetValues(typeof(StatType)).Cast <StatType>()) { int ev = stats.GetStat(type); if (ev > 0) { evs.Add($"{type}: {ev}"); } } OpponentEVs.ToolTip = string.Join(Environment.NewLine, evs); Pokemon active = _bot.Game.Team[_bot.Game.ActiveBattle.SelectedPokemonIndex]; ActiveName.Text = active.Name; ActiveLevel.Text = active.Level.ToString(); ActiveMaxHealth.Text = active.MaxHealth.ToString(); ActiveCurrentHealth.Text = active.CurrentHealth.ToString(); if (active.Experience.CurrentLevel == 100) { NextLevel.Visibility = Visibility.Hidden; } else { NextLevel.Visibility = Visibility.Visible; NextLevel.Text = $"To level {active.Experience.CurrentLevel + 1}: {active.Experience.RemainingExperience}"; } if (active.Status.ToLowerInvariant() == "none") { ActiveStatus.Text = ""; } else { ActiveStatus.Text = active.Status; } ActiveType1.Text = TypesManager.Instance.Type1[active.Id].ToString(); ActiveType2.Text = TypesManager.Instance.Type2[active.Id].ToString(); ActiveGender.Icon = active.Gender == "M" ? FontAwesomeIcon.Mars : active.Gender == "F" ? FontAwesomeIcon.Venus : FontAwesomeIcon.Question; } } }); }
public void BattleUpdated() { Dispatcher.InvokeAsync(delegate { lock (_bot) { if (_bot.Game != null && _bot.Game.ActiveBattle != null) { string opponent = PokemonNamesManager.Instance.Names[_bot.Game.ActiveBattle.OpponentId]; if (_lastOpponentName != opponent) { _lastOpponentName = opponent; string sprite = _nameCleaner.Replace(opponent.ToLowerInvariant(), ""); //sprite = sprite.Replace("-", "_"); if (_bot.Game.ActiveBattle.IsShiny) { sprite = $"{_spriteDatabasePrefix}/animados-shiny/{sprite}.gif"; } else { sprite = $"{_spriteDatabasePrefix}/animados/{sprite}.gif"; } AnimationBehavior.SetSourceUri(OpponentGraphic, new Uri(sprite)); } if (_bot.Game.ActiveBattle.IsShiny) { opponent = "Shiny " + opponent; } if (_bot.Game.ActiveBattle.IsWild) { opponent = "Wild " + opponent; } OpponentName.Text = opponent; OpponentCaughtIcon.Visibility = _bot.Game.ActiveBattle.AlreadyCaught ? Visibility.Visible : Visibility.Hidden; OpponentLevel.Text = _bot.Game.ActiveBattle.OpponentLevel.ToString(); OpponentMaxHealth.Text = _bot.Game.ActiveBattle.OpponentHealth.ToString(); OpponentCurrentHealth.Text = _bot.Game.ActiveBattle.CurrentHealth.ToString(); if (_bot.Game.ActiveBattle.OpponentStatus.ToLowerInvariant() == "none") { OpponentStatus.Text = ""; } else { OpponentStatus.Text = _bot.Game.ActiveBattle.OpponentStatus; } OpponentType1.Text = TypesManager.Instance.Type1[_bot.Game.ActiveBattle.OpponentId].ToString(); OpponentType2.Text = TypesManager.Instance.Type2[_bot.Game.ActiveBattle.OpponentId].ToString(); string gender = _bot.Game.ActiveBattle.OpponentGender; OpponentGender.Icon = gender == "M" ? FontAwesomeIcon.Mars : gender == "F" ? FontAwesomeIcon.Venus : FontAwesomeIcon.Question; OpponentForm.Text = _bot.Game.ActiveBattle.AlternateForm.ToString(); PokemonStats stats = EffortValuesManager.Instance.BattleValues[_bot.Game.ActiveBattle.OpponentId]; List <string> evs = new List <string>(); foreach (StatType type in Enum.GetValues(typeof(StatType)).Cast <StatType>()) { int ev = stats.GetStat(type); if (ev > 0) { evs.Add($"{type}: {ev}"); } } OpponentEVs.ToolTip = string.Join(Environment.NewLine, evs); Pokemon active = _bot.Game.Team[_bot.Game.ActiveBattle.SelectedPokemonIndex]; ActiveName.Text = active.Name; ActiveLevel.Text = active.Level.ToString(); ActiveMaxHealth.Text = active.MaxHealth.ToString(); ActiveCurrentHealth.Text = active.CurrentHealth.ToString(); if (_lastActiveName != active.Name) { _lastActiveName = active.Name; string sprite = _nameCleaner.Replace(active.Name.ToLowerInvariant(), ""); //sprite = sprite.Replace("-", "_"); if (active.IsShiny) { sprite = $"{_spriteDatabasePrefix}/animados-espalda-shiny/{sprite}.gif"; // shiny back } else { sprite = $"{_spriteDatabasePrefix}/animados-espalda/{sprite}.gif"; } AnimationBehavior.SetSourceUri(PlayerGraphic, new Uri(sprite)); } if (active.Experience.CurrentLevel == 100) { NextLevel.Visibility = Visibility.Hidden; } else { NextLevel.Visibility = Visibility.Visible; NextLevel.Text = $"To level {active.Experience.CurrentLevel + 1}: {active.Experience.RemainingExperience}"; } if (active.Status.ToLowerInvariant() == "none") { ActiveStatus.Text = ""; } else { ActiveStatus.Text = active.Status; } ActiveType1.Text = TypesManager.Instance.Type1[active.Id].ToString(); ActiveType2.Text = TypesManager.Instance.Type2[active.Id].ToString(); ActiveGender.Icon = active.Gender == "M" ? FontAwesomeIcon.Mars : active.Gender == "F" ? FontAwesomeIcon.Venus : FontAwesomeIcon.Question; } } }); }