Exemplo n.º 1
0
        public GameStats(MatchDetails m, MatchDetailsPlayer p)
        {
            this.matchDetails       = m;
            this.matchDetailsPlayer = p;

            this.MatchID    = m.MatchID;
            this.GameType   = m.GameMode.ToString();
            this.GameLength = String.Format("{0:d2}:{1:d2}", (m.Duration / 60), (m.Duration % 60));
        }
Exemplo n.º 2
0
        public void Fetch(WebAPISDKEngine engine, long account_id, List <LobbyType> types, int num_matches)
        {
            MatchHistory hist;
            int          total_matches = 0;
            long         last_match_id = 0;
            /* this value is used as a "timeout" if no more matches can be found */
            int num_tries = (num_matches) * 4;

            while ((total_matches < num_matches) && (num_tries > 0))
            {
                hist = engine.GetMatchHistory(account_id, last_match_id, (ushort)(total_matches - num_matches), 0);

                if (hist != null)
                {
                    foreach (Match m in hist.Matches)
                    {
                        MatchDetails currentMatch = engine.GetMatchDetails(m.MatchID);

                        MatchDetailsPlayer p = currentMatch.Players.Where(player => player.AccountID == account_id).FirstOrDefault();

                        if ((p != null) && (types.Contains(currentMatch.LobbyType)))
                        {
                            PlayerGameDiscoveredEvent(this, new PlayerGameStats(currentMatch, p));
                            total_matches++;
                            /* we found a match, there might be more.  Give us some more tries! */
                            num_tries = num_tries + 5;
                        }
                        else
                        {
                            /* match was not found.  Decrement number of tries */
                            num_tries--;
                        }
                    }
                    last_match_id = hist.Matches.OrderByDescending(match => match.MatchID).LastOrDefault().MatchID - 1;
                }

                if (last_match_id == 0)
                {
                    break;
                }
            }


            StatsCompleteEvent(this);
        }
Exemplo n.º 3
0
        public PlayerGameStats(MatchDetails m, MatchDetailsPlayer p)
            : base(m, p)
        {
            this.matchDetails       = m;
            this.matchDetailsPlayer = p;

            /* decode player slot */
            this.onRadiant = ((p.PlayerSlot & (0X80)) == 0);

            /* fetch the hero list and match the hero id */
            this.Hero = Utils.DotaUtils.HeroList.HeroesList.Where(hero => hero.ID == p.HeroID).First().LocalizedName;

            this.Kills   = p.Kills;
            this.Deaths  = p.Deaths;
            this.Assists = p.Assists;
            this.GPM     = p.GoldPerMinute;
            this.XPM     = p.XPPerMinute;
        }
Exemplo n.º 4
0
 public static Player MapPlayer(MatchDetailsPlayer matchDetailsPlayer)
 {
     return(new Player()
     {
         AbilityUpgrades = MapAbilities(matchDetailsPlayer.AbilityUpgrades),
         AccountId = matchDetailsPlayer.AccountId,
         Assists = matchDetailsPlayer.Assists,
         Backpack0 = matchDetailsPlayer.Backpack0,
         Backpack1 = matchDetailsPlayer.Backpack1,
         Backpack2 = matchDetailsPlayer.Backpack2,
         Deaths = matchDetailsPlayer.Deaths,
         Denies = matchDetailsPlayer.Denies,
         Gold = matchDetailsPlayer.Gold,
         GoldPerMin = matchDetailsPlayer.GoldPerMin,
         GoldSpent = matchDetailsPlayer.GoldSpent,
         HeroDamage = matchDetailsPlayer.HeroDamage,
         HeroHealing = matchDetailsPlayer.HeroHealing,
         HeroId = matchDetailsPlayer.HeroId,
         Item0 = matchDetailsPlayer.Item0,
         Item1 = matchDetailsPlayer.Item1,
         Item2 = matchDetailsPlayer.Item2,
         Item3 = matchDetailsPlayer.Item3,
         Item4 = matchDetailsPlayer.Item4,
         Item5 = matchDetailsPlayer.Item5,
         Kills = matchDetailsPlayer.Kills,
         LastHits = matchDetailsPlayer.LastHits,
         LeaverStatus = matchDetailsPlayer.LeaverStatus,
         Level = matchDetailsPlayer.Level,
         PlayerSlot = matchDetailsPlayer.PlayerSlot,
         ScaledHeroDamage = matchDetailsPlayer.ScaledHeroDamage,
         ScaledHeroHealing = matchDetailsPlayer.ScaledHeroHealing,
         ScaledTowerDamage = matchDetailsPlayer.ScaledTowerDamage,
         TowerDamage = matchDetailsPlayer.TowerDamage,
         XpPerMin = matchDetailsPlayer.XpPerMin
     });
 }
Exemplo n.º 5
0
 public TeamGameStats(MatchDetails m, MatchDetailsPlayer p)
     : base(m, p)
 {
 }