Esempio n. 1
0
        /// <summary>
        /// Creates a new <see>WarcraftLadderRecord</see>.
        /// </summary>
        /// <param name="teamType">The type of ladder represented by this record.</param>
        /// <param name="wins">The player's win count.</param>
        /// <param name="losses">The player's loss count.</param>
        /// <param name="level">The player's level.</param>
        /// <param name="hoursUntilExperienceDecay">The time (in hours) until the player's experience decays without playing.  For more information,
        /// see <see>HoursUntilExperienceDecay</see>.</param>
        /// <param name="totalExperience">The player's total experience value.</param>
        /// <param name="rank">The player's rank.</param>
        public WarcraftLadderRecord(WarcraftLadderType teamType, int wins, int losses,
            int level, int hoursUntilExperienceDecay, int totalExperience, int rank)
        {
            if (!Enum.IsDefined(typeof(WarcraftLadderType), teamType))
                throw new InvalidEnumArgumentException("teamType", (int)teamType, typeof(WarcraftLadderType));
            m_type = teamType;

            if (wins < 0)
                throw new ArgumentOutOfRangeException("wins", wins, "Cannot have a negative win count.");
            m_wins = wins;

            if (losses < 0)
                throw new ArgumentOutOfRangeException("losses", losses, "Cannot have a negative loss count.");
            m_losses = losses;

            if (level < 1)
                throw new ArgumentOutOfRangeException("level", level, "Level must be nonzero and nonnegative.");
            m_level = level;

            m_hoursToXpDecay = hoursUntilExperienceDecay;

            if (totalExperience < 0)
                throw new ArgumentOutOfRangeException("totalExperience", totalExperience, "Experience must be nonnegative.");
            m_totalExperience = totalExperience;

            if (rank < 0)
                throw new ArgumentOutOfRangeException("rank", rank, "Rank must be nonnegative.");
            m_rank = rank;

        }
        /// <summary>
        /// Creates a new <see>WarcraftLadderRecord</see>.
        /// </summary>
        /// <param name="teamType">The type of ladder represented by this record.</param>
        /// <param name="wins">The player's win count.</param>
        /// <param name="losses">The player's loss count.</param>
        /// <param name="level">The player's level.</param>
        /// <param name="hoursUntilExperienceDecay">The time (in hours) until the player's experience decays without playing.  For more information,
        /// see <see>HoursUntilExperienceDecay</see>.</param>
        /// <param name="totalExperience">The player's total experience value.</param>
        /// <param name="rank">The player's rank.</param>
        public WarcraftLadderRecord(WarcraftLadderType teamType, int wins, int losses,
                                    int level, int hoursUntilExperienceDecay, int totalExperience, int rank)
        {
            if (!Enum.IsDefined(typeof(WarcraftLadderType), teamType))
            {
                throw new InvalidEnumArgumentException("teamType", (int)teamType, typeof(WarcraftLadderType));
            }
            m_type = teamType;

            if (wins < 0)
            {
                throw new ArgumentOutOfRangeException("wins", wins, "Cannot have a negative win count.");
            }
            m_wins = wins;

            if (losses < 0)
            {
                throw new ArgumentOutOfRangeException("losses", losses, "Cannot have a negative loss count.");
            }
            m_losses = losses;

            if (level < 1)
            {
                throw new ArgumentOutOfRangeException("level", level, "Level must be nonzero and nonnegative.");
            }
            m_level = level;

            m_hoursToXpDecay = hoursUntilExperienceDecay;

            if (totalExperience < 0)
            {
                throw new ArgumentOutOfRangeException("totalExperience", totalExperience, "Experience must be nonnegative.");
            }
            m_totalExperience = totalExperience;

            if (rank < 0)
            {
                throw new ArgumentOutOfRangeException("rank", rank, "Rank must be nonnegative.");
            }
            m_rank = rank;
        }
Esempio n. 3
0
        private void HandleWarcraftUserInfoRequest(ParseData data, DataReader dr)
        {
            int cookie = dr.ReadInt32();

            if (!m_warcraftProfileRequests.ContainsKey(cookie))
            {
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie));
                return;
            }
            WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie];

            string iconID = dr.ReadDwordString(0);

            args.Profile.IconID = iconID;

            int recordCount = dr.ReadByte();

            WarcraftLadderRecord[] ladderRecords = new WarcraftLadderRecord[recordCount];
            for (int i = 0; i < recordCount; i++)
            {
                WarcraftLadderType ladderType = (WarcraftLadderType)dr.ReadInt32();
                int wins   = dr.ReadInt16();
                int losses = dr.ReadInt16();
                int level  = dr.ReadByte();
                int hrs    = dr.ReadByte();
                int xp     = dr.ReadInt16();
                int rank   = dr.ReadInt32();

                WarcraftLadderRecord record = new WarcraftLadderRecord(ladderType, wins, losses, level, hrs, xp, rank);
                ladderRecords[i] = record;
            }

            int raceRecordCount = dr.ReadByte();

            Warcraft3IconRace[]  raceOrder   = new Warcraft3IconRace[] { Warcraft3IconRace.Random, Warcraft3IconRace.Human, Warcraft3IconRace.Orc, Warcraft3IconRace.Undead, Warcraft3IconRace.NightElf, Warcraft3IconRace.Tournament };
            WarcraftRaceRecord[] raceRecords = new WarcraftRaceRecord[raceRecordCount];
            for (int i = 0; i < raceRecordCount; i++)
            {
                int wins   = dr.ReadInt16();
                int losses = dr.ReadInt16();

                WarcraftRaceRecord record = new WarcraftRaceRecord(raceOrder[i], wins, losses);
                raceRecords[i] = record;
            }

            int teamRecordsCount = dr.ReadByte();

            ArrangedTeamRecord[] teamRecords = new ArrangedTeamRecord[teamRecordsCount];
            for (int i = 0; i < teamRecordsCount; i++)
            {
                ArrangedTeamType teamType = (ArrangedTeamType)dr.ReadInt32();
                int      wins             = dr.ReadInt16();
                int      losses           = dr.ReadInt16();
                int      level            = dr.ReadByte();
                int      hrs            = dr.ReadByte();
                int      xp             = dr.ReadInt16();
                int      rank           = dr.ReadInt32();
                long     ftLastGameplay = dr.ReadInt64();
                DateTime lastGamePlayed = DateTime.FromFileTime(ftLastGameplay);
                int      numPartners    = dr.ReadByte();
                string[] partnerList    = new string[numPartners];
                for (int p = 0; p < numPartners; p++)
                {
                    partnerList[p] = dr.ReadCString();
                }

                ArrangedTeamRecord record = new ArrangedTeamRecord(teamType, wins, losses, level, hrs, xp, rank, lastGamePlayed, partnerList);
                teamRecords[i] = record;
            }

            args.Profile.SetStats(ladderRecords, teamRecords, raceRecords);

            args.EventData = data;

            OnWarcraftProfileReceived(args);
        }