public bool IsLearnable(LearnableAbility ability, uint?heroLevel = null, uint?spentPoints = null, uint?abilityLevel = null) { if (abilityLevel == null) { abilityLevel = ability.CurrentLevel; } if (abilityLevel >= ability.MaxLevel) { return(false); } if (heroLevel == null) { heroLevel = this.owner.Hero.Level; } if (spentPoints == null) { spentPoints = this.GetSpentPoints(); } if (ability.LearnLevel != spentPoints) { return(false); } if (ability.IsUltimate) { if (this.owner.HeroId == HeroId.npc_dota_hero_meepo) { if (heroLevel < (abilityLevel * 7) + 4) { return(false); } } else if (heroLevel < (abilityLevel + 1) * 6) { return(false); } } else if (heroLevel <= abilityLevel * 2) { return(false); } return(true); }
private void AddAbility(string abilityValue) { var name = WebUtility.HtmlDecode(Regex.Match(abilityValue, @"<img alt=""(.+?)""").Groups[1].Value); var dotaName = this.nameManager.MyAbilityNames.FirstOrDefault(x => x.Value == name).Key; if (string.IsNullOrEmpty(dotaName)) { return; } var ability = this.owner.Hero.BaseSpellbook.Spells.FirstOrDefault(x => x.Name == dotaName); if (ability == null) { return; } var abilityLevel = 1u; var levelData = Regex.Match(abilityValue, @"<td.+?</td>"); while (levelData.Success) { var learnable = new LearnableAbility(ability, name, abilityLevel); var winRate = Regex.Match(levelData.Value, @"<span (.+?)>(.?\d{1,3}\.\d{1,2})%"); if (winRate.Success) { learnable.WinRate = float.Parse(winRate.Groups[2].Value, CultureInfo.InvariantCulture); } var pickRate = Regex.Match(levelData.Value, @"<div class=""toptext"">(\d{1,3}\.\d{1,2})%"); if (pickRate.Success) { learnable.PickRate = float.Parse(pickRate.Groups[1].Value, CultureInfo.InvariantCulture); } this.Abilities.Add(learnable); if (!this.dotabuffAbilityLevels.Contains(++abilityLevel)) { this.Abilities.Add(new LearnableAbility(ability, name, abilityLevel++)); } levelData = levelData.NextMatch(); } }
private void AddTalent(string talentValue, uint level) { var name = WebUtility.HtmlDecode( Regex.Match(talentValue, @"<span class=""talent-name-inner"">(.+?)</span>", RegexOptions.CultureInvariant).Groups[1].Value); float.TryParse( Regex.Match(talentValue, @">Win Rate: (\d{1,3}\.\d{1,2})%").Groups[1].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var winRate); float.TryParse( Regex.Match(talentValue, @">Pick Rate: (\d{1,3}\.\d{1,2})%").Groups[1].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var pickRate); var dotaName = this.nameManager.MyAbilityNames.FirstOrDefault(x => x.Value == name).Key; if (string.IsNullOrEmpty(dotaName)) { return; } var ability = this.owner.Hero.BaseSpellbook.Spells.FirstOrDefault(x => x.Name == dotaName); if (ability == null) { return; } var learnable = new LearnableAbility(ability, name, level) { PickRate = pickRate, WinRate = winRate }; this.Talents.Add(learnable); }