Exemplo n.º 1
0
        public void AddWin(int numPerTeam, DuelInfo duelInfo)
        {
            if (m_Wins.ContainsKey(numPerTeam))
            {
                m_Wins[numPerTeam]++;
            }
            else
            {
                m_Wins.Add(numPerTeam, 1);
            }

            if (m_FastestWins.ContainsKey(numPerTeam) && m_FastestWins[numPerTeam].DuelTime.Seconds > duelInfo.DuelTime.Seconds)
            {
                m_FastestWins[numPerTeam] = duelInfo;
            }
            else if (!m_FastestWins.ContainsKey(numPerTeam))
            {
                m_FastestWins.Add(numPerTeam, duelInfo);
            }

            if (m_LongestWins.ContainsKey(numPerTeam) && m_LongestWins[numPerTeam].DuelTime.Seconds < duelInfo.DuelTime.Seconds)
            {
                m_LongestWins[numPerTeam] = duelInfo;
            }
            else if (!m_LongestWins.ContainsKey(numPerTeam))
            {
                m_LongestWins.Add(numPerTeam, duelInfo);
            }
        }
Exemplo n.º 2
0
        public static Dictionary <int, DuelInfo> ReadPointsDictionary(GenericReader reader)
        {
            Dictionary <int, DuelInfo> dictionary = new Dictionary <int, DuelInfo>();

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    int      key   = reader.ReadInt();
                    DuelInfo dInfo = new DuelInfo(reader);
                    dictionary.Add(key, dInfo);
                }

                break;
            }
            }

            return(dictionary);
        }
Exemplo n.º 3
0
        public static string GetLongestTimes(DuelPoints duelPoints)
        {
            if (duelPoints == null || (duelPoints.LongestLoses.Count == 0 && duelPoints.LongestWins.Count == 0))
            {
                return("No records");
            }

            StringBuilder sb = new StringBuilder();

            if (duelPoints.LongestWins.Count > 0)
            {
                sb.Append("Longest Wins" + br);
                IDictionaryEnumerator myEnum = duelPoints.LongestWins.GetEnumerator();

                while (myEnum.MoveNext())
                {
                    int      players = (int)myEnum.Key;
                    DuelInfo dInfo   = (DuelInfo)myEnum.Value;

                    if (dInfo.DuelTime.Minutes == 0)
                    {
                        sb.Append(String.Format("{0}vs{0} - {1} seconds{2}", players, dInfo.DuelTime.Seconds, br));
                    }
                    else
                    {
                        sb.Append(String.Format("{0}vs{0} - {1} minutes {2} seconds{3}", players, dInfo.DuelTime.Minutes, dInfo.DuelTime.Seconds, br));
                    }
                }
            }

            if (duelPoints.LongestLoses.Count > 0)
            {
                sb.Append(br);
                sb.Append("Longest Loses" + br);
                IDictionaryEnumerator myEnum = duelPoints.LongestLoses.GetEnumerator();

                while (myEnum.MoveNext())
                {
                    int      players = (int)myEnum.Key;
                    DuelInfo dInfo   = (DuelInfo)myEnum.Value;


                    if (dInfo.DuelTime.Minutes == 0)
                    {
                        sb.Append(String.Format("{0}vs{0} - {1} seconds{2}", players, dInfo.DuelTime.Seconds, br));
                    }
                    else
                    {
                        sb.Append(String.Format("{0}vs{0} - {1} minutes {2} seconds{3}", players, dInfo.DuelTime.Minutes, dInfo.DuelTime.Seconds, br));
                    }
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 4
0
		public void AddWin(int numPerTeam, DuelInfo duelInfo)
		{
			if (m_Wins.ContainsKey(numPerTeam))
				m_Wins[numPerTeam]++;
			else
				m_Wins.Add(numPerTeam, 1);

			if (m_FastestWins.ContainsKey(numPerTeam) && m_FastestWins[numPerTeam].DuelTime.Seconds > duelInfo.DuelTime.Seconds)
				m_FastestWins[numPerTeam] = duelInfo;
			else if (!m_FastestWins.ContainsKey(numPerTeam))
				m_FastestWins.Add(numPerTeam, duelInfo);

			if (m_LongestWins.ContainsKey(numPerTeam) && m_LongestWins[numPerTeam].DuelTime.Seconds < duelInfo.DuelTime.Seconds)
				m_LongestWins[numPerTeam] = duelInfo;
			else if (!m_LongestWins.ContainsKey(numPerTeam))
				m_LongestWins.Add(numPerTeam, duelInfo);
		}
Exemplo n.º 5
0
        public static void AddLoss(Duel duel, Mobile m)
        {
            DuelPoints dPoints;

            if (m_PointsTable.TryGetValue(m.Serial, out dPoints))
            {
                DuelInfo dInfo = new DuelInfo(duel.Attackers.Contains(m) ? duel.Attackers : duel.Defenders,
                                              TimeSpan.FromSeconds(DuelController.Instance.DuelLengthInSeconds - duel.DuelTimer.SecondsRemaining));
                dPoints.AddLoss(duel.Attackers.Count, dInfo);
            }
            else
            {
                dPoints = new DuelPoints(m);
                DuelInfo dInfo = new DuelInfo(duel.Attackers.Contains(m) ? duel.Attackers : duel.Defenders,
                                              TimeSpan.FromSeconds(DuelController.Instance.DuelLengthInSeconds - duel.DuelTimer.SecondsRemaining));
                dPoints.AddLoss(duel.Attackers.Count, dInfo);
                m_PointsTable[m.Serial] = dPoints;
            }
        }
Exemplo n.º 6
0
        public static void WritePointsDictionary(Dictionary <int, DuelInfo> dictionary, GenericWriter writer)
        {
            writer.Write((int)0);

            int count = dictionary.Count;

            writer.Write((int)count);

            IDictionaryEnumerator myEnum = dictionary.GetEnumerator();

            while (myEnum.MoveNext())
            {
                int      key  = (int)myEnum.Key;
                DuelInfo info = (DuelInfo)myEnum.Value;

                writer.Write((int)key);
                info.Serialize(writer);
            }
        }
Exemplo n.º 7
0
		public static void AddLoss(Duel duel, Mobile m)
		{
			DuelPoints dPoints;
			if (m_PointsTable.TryGetValue(m.Serial, out dPoints))
			{
				DuelInfo dInfo = new DuelInfo(duel.Attackers.Contains(m) ? duel.Attackers : duel.Defenders,
					TimeSpan.FromSeconds(DuelController.Instance.DuelLengthInSeconds - duel.DuelTimer.SecondsRemaining));
				dPoints.AddLoss(duel.Attackers.Count, dInfo);
			}
			else
			{
				dPoints = new DuelPoints(m);
				DuelInfo dInfo = new DuelInfo(duel.Attackers.Contains(m) ? duel.Attackers : duel.Defenders,
					TimeSpan.FromSeconds(DuelController.Instance.DuelLengthInSeconds - duel.DuelTimer.SecondsRemaining));
				dPoints.AddLoss(duel.Attackers.Count, dInfo);
				m_PointsTable[m.Serial] = dPoints;
			}
		}
Exemplo n.º 8
0
		public static Dictionary<int, DuelInfo> ReadPointsDictionary(GenericReader reader)
		{
			Dictionary<int, DuelInfo> dictionary = new Dictionary<int, DuelInfo>();

			int version = reader.ReadInt();

			switch (version)
			{
				case 0:
					{
						int count = reader.ReadInt();

						for (int i = 0; i < count; i++)
						{
							int key = reader.ReadInt();
							DuelInfo dInfo = new DuelInfo(reader);
							dictionary.Add(key, dInfo);
						}

						break;
					}
			}

			return dictionary;
		}