public void PrimaryAttribute_STR() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(PrimaryAttribute: PrimaryAttributes.STR); Assert.AreEqual(39, heroes.Count()); }
public void ModesCount() { IMetaClient client = new MetaClient(); var modes = client.GetModes(); Assert.AreEqual(25, modes.Count); }
public void NewPlayerEnable() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(NewPlayerEnable: true); Assert.AreEqual(102, heroes.Count()); }
public void CaptainsModeEnabled() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(CaptainsModeEnabled: true); Assert.AreEqual(119, heroes.Count()); }
public void PrimaryAttribute_INT() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(PrimaryAttribute: PrimaryAttributes.INT); Assert.AreEqual(43, heroes.Count()); }
public void SkillCount() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(IsSkill: true); Assert.AreEqual(733, abilities.Count()); }
public void RegionsCount() { IMetaClient client = new MetaClient(); var regions = client.GetRegions(); Assert.AreEqual(22, regions.Count()); }
public void AbilitiesByHeroId() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(HeroId: 1); Assert.AreEqual(5, abilities.Count()); }
public void NeutralCount() { IMetaClient client = new MetaClient(); var items = client.GetItems(IsNeutralDrop: true); Assert.AreEqual(94, items.Count()); }
public void HasScepterUpgrade() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(HasScepterUpgrade: true); Assert.AreEqual(128, abilities.Count()); }
public void ItemsCount() { IMetaClient client = new MetaClient(); var items = client.GetItems(); Assert.AreEqual(403, items.Count()); }
public void HeroesEnabled() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(enabled: true); Assert.AreEqual(120, heroes.Count()); }
public void IsGrantedByShard() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(IsGrantedByShard: true); Assert.AreEqual(30, abilities.Count()); }
public void GetMode() { IMetaClient client = new MetaClient(); var mode = client.GetMode(1); Assert.AreEqual("All Pick", mode); }
public void UltimateCount() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(IsUltimate: true); Assert.AreEqual(142, abilities.Count()); }
public void HeroesCount() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(); Assert.AreEqual(121, heroes.Count()); }
public void AbilitiesCount() { IMetaClient client = new MetaClient(); var abilities = client.GetAbilities(); Assert.AreEqual(2029, abilities.Count()); }
public void GetItem() { IMetaClient client = new MetaClient(); var item = client.GetItem(1); Assert.AreEqual(1, item.Id); Assert.AreEqual("Blink Dagger", item.Name); // TODO: Assert Item Properties }
public void GetAbility() { IMetaClient client = new MetaClient(); var ability = client.GetAbility(5003); Assert.AreEqual(5003, ability.Id); Assert.AreEqual("Mana Break", ability.Name); // TODO: Assert Ability Properties }
public void GetHero() { IMetaClient client = new MetaClient(); var hero = client.GetHero(1); Assert.AreEqual(1, hero.Id); Assert.AreEqual("Anti-Mage", hero.Name); // TODO: Assert Hero Properties }
public void AbilityDraftPool() { IMetaClient client = new MetaClient(); var heroes = client.GetHeroes(); var collection = heroes.Where(_ => _.AbilityDraftPool.Count() > 4).ToList(); var hero = collection.FirstOrDefault(); Assert.AreEqual(1, collection.Count); Assert.AreEqual(74, hero.Id); }
static void Main(string[] args) { TopicClient topicClient = new TopicClient(); List <TopicView> topics = topicClient.getTopics(); Console.WriteLine(topics.Count); MetaClient metaClient = new MetaClient(); Meta meta = metaClient.getMeta(); Console.WriteLine(meta.version); Console.Read(); }
public void GetRegionFromCluster() { IMetaClient client = new MetaClient(); var region = client.GetRegionFromCluster(111); Assert.AreEqual(1, region.Id); Assert.AreEqual("USWest", region.Key); Assert.AreEqual("US West", region.Name); Assert.AreEqual(47.6052, region.Latitude); Assert.AreEqual(-122.16999816894531, region.Longitude); Assert.IsTrue(Enumerable.SequenceEqual(new List <int>() { 111, 112, 113, 114 }, region.Clusters)); }
public static IList <Ability> GetAbilities(this HGV.Daedalus.GetMatchDetails.Player player, MetaClient client) { var abilities = client.GetSkills(); if (player.ability_upgrades == null) { return(new List <Ability>()); } else { return(player.ability_upgrades.Select(_ => _.ability).Distinct().Join(abilities, _ => _, _ => _.Id, (lhs, rhs) => rhs).ToList()); } }
public PlayerService(MetaClient metaClient, IDotaApiClient dotaClient) { this.metaClient = metaClient; this.dotaClient = dotaClient; }
public RegionService(MetaClient metaClient) { this.metaClient = metaClient; }
public HeroService(MetaClient metaClient) { this.metaClient = metaClient; }
public async Task Processing() { var client = new MetaClient(); var heroesTest = client.GetHeroes(); var heroes = client.GetHeroes().Select(_ => new { Key = _.Id, Abilities = _.Abilities.Select(__ => __.Id).ToList() }).ToDictionary(_ => _.Key, _ => _.Abilities); var abilities = client.GetAbilities().Select(_ => _.Id).ToList(); var ultimates = client.GetUltimates().Select(_ => _.Id).ToList(); var talents = client.GetTalents().Select(_ => _.Id).ToList(); while (true) { var context = new DataContext(); using (var transation = context.Database.BeginTransaction()) { try { Daedalus.GetMatchDetails.Match match; if (!this.qProcessing.TryDequeue(out match)) { continue; } var count = context.Matches.Where(_ => _.match_number == match.match_seq_num).Count(); if (count > 0) { continue; } var date = DateTimeOffset.FromUnixTimeSeconds(match.start_time).UtcDateTime; var duration = DateTimeOffset.FromUnixTimeSeconds(match.duration).TimeOfDay.TotalMinutes; var match_summary = new Data.Models.Match() { match_id = match.match_id, match_number = match.match_seq_num, league_id = match.leagueid, duration = duration, day_of_week = (int)date.DayOfWeek, hour_of_day = date.Hour, date = date, cluster = match.cluster, region = client.ConvertClusterToRegion(match.cluster), victory_radiant = match.radiant_win ? 1 : 0, victory_dire = match.radiant_win ? 0 : 1, valid = true, }; var time_limit = 10; if (duration < time_limit) { // this.logger.Warning($" Error: match {match.match_id} is invalid as its durration of {duration:0.00} is lower then the time limit of {time_limit}"); match_summary.valid = false; } context.Matches.Add(match_summary); await context.SaveChangesAsync(); var players_leave = 0; foreach (var player in match.players) { var team = player.player_slot < 6 ? 0 : 1; var order = this.ConvertPlayerSlotToDraftOrder(player.player_slot); var victory = team == 0 ? match.radiant_win : !match.radiant_win; var hero_id = player.hero_id; if (player.leaver_status > 1) { players_leave++; } if (players_leave > 1) { match_summary.valid = false; } /* * if (player.leaver_status > 1) * { * // https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails * var status = player.leaver_status == 2 ? "DISCONNECTED" : player.leaver_status == 3 ? "ABANDONED" : player.leaver_status == 4 ? "AFK" : "Unknown"; * // this.logger.Warning($" Warning: match {match.match_id} ({duration:0.00}) is invalid as player {order} has a leaver status of {player.leaver_status} ({status}) "); * match_summary.valid = false; * } */ var heroes_abilities = new List <int>(); heroes.TryGetValue(hero_id, out heroes_abilities); var match_player = new Data.Models.Player() { // Match match_ref = match_summary.id, victory = victory ? 1 : 0, // Player team = team, draft_order = order, player_slot = player.player_slot, account_id = player.account_id, persona = player.persona, // Hero hero_id = hero_id, kills = player.kills, deaths = player.deaths, assists = player.assists, last_hits = player.last_hits, denies = player.denies, gold = player.gold, level = player.level, gold_per_min = player.gold_per_min, xp_per_min = player.xp_per_min, gold_spent = player.gold_spent, hero_damage = player.hero_damage, tower_damage = player.tower_damage, hero_healing = player.hero_healing, }; context.Players.Add(match_player); await context.SaveChangesAsync(); if (player.ability_upgrades == null) { throw new Exception($" Error: match {match.match_id} is invalid as player {order} has no abilities."); } var query = player.ability_upgrades.Select(_ => _).ToList(); var collection = query.Select(_ => _.ability).Distinct().ToList(); foreach (var ability_id in collection) { var id = ConvertAbilityID(ability_id); var match_skill = new Data.Models.Skill() { // Match match_ref = match_summary.id, // Player player_ref = match_player.id, // Ability ability_id = id, is_skill = abilities.Contains(id) ? 1 : 0, is_ulimate = ultimates.Contains(id) ? 1 : 0, is_taltent = talents.Contains(id) ? 1 : 0, is_hero_same = heroes_abilities.Contains(id) ? 1 : 0, level = query.Where(_ => _.ability == id || _.ability == ability_id).Max(_ => _.level), }; context.Skills.Add(match_skill); } await context.SaveChangesAsync(); } var match_delta = DateTime.Now - match_summary.date.ToLocalTime().AddMinutes(match_summary.duration); // this.logger.Info($"Processed: match {match_summary.match_id} which ended {match_delta.Humanize(3)} mins ago."); transation.Commit(); } catch (Exception ex) { transation.Rollback(); // this.logger.Error(ex); } } } }
static async Task Main(string[] args) { var httpClient = new HttpClient(); var metaClient = new MetaClient(); var heroes = metaClient.GetHeroes(); var abilities = metaClient.GetAbilities(); var items = metaClient.GetItems(); Directory.CreateDirectory(@"images\heroes\banner"); Directory.CreateDirectory(@"images\heroes\profile"); Directory.CreateDirectory(@"images\heroes\portrait"); Directory.CreateDirectory(@"images\heroes\animation"); Directory.CreateDirectory(@"images\abilities"); Directory.CreateDirectory(@"images\items"); foreach (var hero in heroes) { try { var img = hero.Key.Replace("npc_dota_hero_", ""); var url = $"https://cdn.cloudflare.steamstatic.com/apps/dota2/videos/dota_react/heroes/renders/{img}.png"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\heroes\profile\{hero.Id}.png")) { stream.CopyTo(fileStream); } } catch (Exception ex) { Console.WriteLine($"Failed to Download Hero profile {hero.Name} "); } } foreach (var hero in heroes) { try { var img = hero.Key.Replace("npc_dota_hero_", ""); var url = $"https://cdn.cloudflare.steamstatic.com/apps/dota2/images/dota_react/heroes/{img}.png"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\heroes\banner\{hero.Id}.jpg")) { stream.CopyTo(fileStream); } } catch (Exception) { Console.WriteLine($"Failed to Download hero banner {hero.Key} "); } } foreach (var hero in heroes) { try { var img = hero.Key.Replace("npc_dota_hero_", ""); var url = $"http://cdn.dota2.com/apps/dota2/images/heroes/{img}_vert.jpg"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\heroes\portrait\{hero.Id}.jpg")) { stream.CopyTo(fileStream); } } catch (Exception) { Console.WriteLine($"Failed to Download hero portrait {hero.Key} "); } } foreach (var hero in heroes) { try { var img = hero.Key.Replace("npc_dota_hero_", ""); var url = $"https://cdn.cloudflare.steamstatic.com/apps/dota2/videos/dota_react/heroes/renders/{img}.webm"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\heroes\animation\{hero.Id}.webm")) { stream.CopyTo(fileStream); } } catch (Exception) { Console.WriteLine($"Failed to Download hero animation {hero.Key} "); } } foreach (var ability in abilities) { try { var img = ability.Key; var url = $"https://cdn.cloudflare.steamstatic.com/apps/dota2/images/dota_react/abilities/{img}.png"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\abilities\{ability.Id}.jpg")) { stream.CopyTo(fileStream); } } catch (Exception) { Console.WriteLine($"Failed to Download Ability {ability.Key}"); } } foreach (var item in items) { try { var img = item.Key.Replace("item_", ""); var url = $"https://cdn.cloudflare.steamstatic.com/apps/dota2/images/items/{img}_lg.png"; var stream = await httpClient.GetStreamAsync(url); using (var fileStream = File.Create($@"images\items\{item.Id}.jpg")) { stream.CopyTo(fileStream); } } catch (Exception) { Console.WriteLine($"Failed to Download Item {item.Key}"); } } }
public AbilityService(MetaClient metaClient) { this.metaClient = metaClient; }