Ejemplo n.º 1
0
 public RankEntry(Mobile m, XmlPoints attachment)
 {
     this.Killer = m;
     this.PointsAttachment = attachment;
 }
Ejemplo n.º 2
0
        private static void UpdateRanking(Mobile m, XmlPoints attachment)
        {
            if (RankList == null)
                RankList = new ArrayList();

            // flag the rank list for updating on the next attempt to retrieve a rank
            needsupdate = true;

            bool found = false;

            // rank the entries
            for (int i = 0; i < RankList.Count; i++)
            {
                RankEntry p = RankList[i] as RankEntry;
                
                // found a match
                if (p != null && p.Killer == m)
                {
                    // update the entry with the new points value
                    p.PointsAttachment = attachment;
                    found = true;
                    break;
                }
            }

            // a new entry so add it
            if (!found)
            {
                RankList.Add(new RankEntry(m, attachment));
            }

            // if points statistics are being displayed in player name properties, then update them

            if (m != null)
                m.InvalidateProperties();
        }
Ejemplo n.º 3
0
            public TopPlayersGump(XmlPoints attachment)
                : base(0,0)
            {
                if (RankList == null || attachment == null)
                    return;

                this.m_attachment = attachment;

                int numberToDisplay = 20;
                int height = numberToDisplay * 20 + 65;

                // prepare the page
                this.AddPage(0);

                int width = 740;
                #if(FACTIONS)
                width = 790;
                #endif

                this.AddBackground(0, 0, width, height, 5054);
                this.AddAlphaRegion(0, 0, width, height);
                this.AddImageTiled(20, 20, width - 40, height - 45, 0xBBC);
                this.AddLabel(20, 2, 55, attachment.Text(200239)); // "Top Player Rankings"

                // guild filter
                this.AddLabel(40, height - 20, 55, attachment.Text(200240));  // "Filter by Guild"
                string filter = null;
                if (this.m_attachment != null)
                    filter = this.m_attachment.guildFilter;

                this.AddImageTiled(140, height - 20, 160, 19, 0xBBC);
                this.AddTextEntry(140, height - 20, 160, 19, 0, 200, filter);

                this.AddButton(20, height - 20, 0x15E1, 0x15E5, 200, GumpButtonType.Reply, 0);

                // name filter
                this.AddLabel(340, height - 20, 55, attachment.Text(200241));  // "Filter by Name"
                string nfilter = null;
                if (this.m_attachment != null)
                    nfilter = this.m_attachment.nameFilter;

                this.AddImageTiled(440, height - 20, 160, 19, 0xBBC);
                this.AddTextEntry(440, height - 20, 160, 19, 0, 100, nfilter);

                this.AddButton(320, height - 20, 0x15E1, 0x15E5, 100, GumpButtonType.Reply, 0);

                RefreshRankList();

                int xloc = 23;
                this.AddLabel(xloc, 20, 0, attachment.Text(200242));  // "Name"
                xloc += 177;
                this.AddLabel(xloc, 20, 0, attachment.Text(200243));  // "Guild"
                #if(FACTIONS)
                xloc += 35;
                this.AddLabel(xloc, 20, 0, attachment.Text(200640));  // "Faction"
                xloc += 15;
                #endif
                xloc += 50;
                this.AddLabel(xloc, 20, 0, attachment.Text(200244));   // "Points"
                xloc += 50;
                this.AddLabel(xloc, 20, 0, attachment.Text(200245));    // "Kills"
                xloc += 50;
                this.AddLabel(xloc, 20, 0, attachment.Text(200246));   // "Deaths"
                xloc += 70;
                this.AddLabel(xloc, 20, 0, attachment.Text(200247));     // "Rank"
                xloc += 45;
                this.AddLabel(xloc, 20, 0, attachment.Text(200248));   // "Change"
                xloc += 45;
                this.AddLabel(xloc, 20, 0, attachment.Text(200249));  // "Time at Rank"

                // go through the sorted list and display the top ranked players

                int y = 40;
                int count = 0;
                for (int i = 0; i < RankList.Count; i++)
                {
                    if (count >= numberToDisplay)
                        break;

                    RankEntry r = RankList[i] as RankEntry;

                    if (r == null)
                        continue;

                    XmlPoints a = r.PointsAttachment;

                    if (a == null)
                        continue;

                    if (r.Killer != null && !r.Killer.Deleted && r.Rank > 0 && a != null && !a.Deleted)
                    {
                        string guildname = null;

                        if (r.Killer.Guild != null)
                            guildname = r.Killer.Guild.Abbreviation;

                        #if(FACTIONS)
                        string factionname = null;
    
                        if (r.Killer is PlayerMobile && ((PlayerMobile)r.Killer).FactionPlayerState != null) 
                            factionname = ((PlayerMobile)r.Killer).FactionPlayerState.Faction.ToString();
                        #endif
                        // check for any ranking change and update rank date
                        if (r.Rank != a.Rank)
                        {
                            a.WhenRanked = DateTime.UtcNow;
                            if (a.Rank > 0)
                                a.DeltaRank = a.Rank - r.Rank;
                            a.Rank = r.Rank;
                        }

                        // check for guild filter
                        if (this.m_attachment != null && this.m_attachment.guildFilter != null && this.m_attachment.guildFilter.Length > 0)
                        {
                            // parse the comma separated list
                            string[] args = this.m_attachment.guildFilter.Split(',');
                            if (args != null)
                            {
                                bool found = false;
                                foreach (string arg in args)
                                {
                                    if (arg != null && guildname == arg.Trim())
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found)
                                    continue;
                            }
                        }

                        // check for name filter
                        if (this.m_attachment != null && this.m_attachment.nameFilter != null && this.m_attachment.nameFilter.Length > 0)
                        {
                            // parse the comma separated list
                            string[] args = this.m_attachment.nameFilter.Split(',');

                            if (args != null)
                            {
                                bool found = false;
                                foreach (string arg in args)
                                {
                                    if (arg != null && r.Killer.Name != null && (r.Killer.Name.ToLower().IndexOf(arg.Trim().ToLower()) >= 0))
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found)
                                    continue;
                            }
                        }

                        count++;

                        TimeSpan timeranked = DateTime.UtcNow - a.WhenRanked;

                        int days = (int)timeranked.TotalDays;
                        int hours = (int)(timeranked.TotalHours - days * 24);
                        int mins = (int)(timeranked.TotalMinutes - ((int)timeranked.TotalHours) * 60);

                        string kills = "???";
                        try
                        {
                            kills = a.Kills.ToString();
                        }
                        catch
                        {
                        }

                        string deaths = "???";
                        try
                        {
                            deaths = a.Deaths.ToString();
                        }
                        catch
                        {
                        }

                        xloc = 23;
                        this.AddLabel(xloc, y, 0, r.Killer.Name);
                        xloc += 177;
                        this.AddLabel(xloc, y, 0, guildname);
                        #if(FACTIONS)
                        xloc += 35;
                        this.AddLabelCropped(xloc, y, 60, 21, 0, factionname);
                        xloc += 15;
                        #endif
                        xloc += 50;
                        this.AddLabel(xloc, y, 0, a.Points.ToString());
                        xloc += 50;
                        this.AddLabel(xloc, y, 0, kills);
                        xloc += 50;
                        this.AddLabel(xloc, y, 0, deaths);
                        xloc += 70;
                        this.AddLabel(xloc, y, 0, a.Rank.ToString());

                        string label = null;

                        if (days > 0)
                            label += String.Format(attachment.Text(200250), days);  // "{0} days "
                        if (hours > 0)
                            label += String.Format(attachment.Text(200251), hours);  // "{0} hours "
                        if (mins > 0)
                            label += String.Format(attachment.Text(200252), mins);   // "{0} mins"

                        if (label == null)
                        {
                            label = attachment.Text(200253);   // "just changed"
                        }

                        string deltalabel = a.DeltaRank.ToString();
                        int deltahue = 0;
                        if (a.DeltaRank > 0)
                        {
                            deltalabel = String.Format("+{0}", a.DeltaRank);
                            deltahue = 68;
                        }
                        else if (a.DeltaRank < 0)
                        {
                            deltahue = 33;
                        }
                        xloc += 50;
                        this.AddLabel(xloc, y, deltahue, deltalabel);
                        xloc += 40;
                        this.AddLabel(xloc, y, 0, label);

                        y += 20;
                    }
                }
            }
Ejemplo n.º 4
0
            public PointsGump(XmlPoints a, Mobile from, Mobile target, string text)
                : base(0,0)
            {
                if (target == null || a == null)
                    return;
                
                this.m_attachment = a;
                this.m_target = target;
                this.m_text = text;

                // prepare the page
                this.AddPage(0);
    
                if (from == target)
                {
                    this.AddBackground(0, 0, 440, 295, 5054);
                    this.AddAlphaRegion(0, 0, 440, 295);
                }
                else
                {
                    this.AddBackground(0, 0, 440, 190, 5054);
                    this.AddAlphaRegion(0, 0, 440, 190);
                }
                this.AddLabel(20, 2, 55, String.Format(GetText(from, 200224), target.Name));  // "Points Standing for {0}"

                // 1 on 1 duel status
                if (a.Challenger != null)
                {
                    int challengehue = 68;

                    if (a.m_CancelTimer != null && a.m_CancelTimer.Running)
                        challengehue = 33;
                    // also check the challenger timer to see if he is cancelling
                    XmlPoints ca = (XmlPoints)XmlAttach.FindAttachment(a.Challenger, typeof(XmlPoints));
                    if (ca != null && !ca.Deleted)
                    {
                        if ((ca.m_CancelTimer != null && ca.m_CancelTimer.Running) || (ca.ChallengeGame != null && ca.ChallengeGame.ChallengeBeingCancelled))
                            challengehue = 33;
                    }

                    this.AddLabel(20, 143, challengehue, String.Format(GetText(from, 200225), a.Challenger.Name));  // "Currently challenging {0}"
                }
                else if (a.ChallengeGame != null && !a.ChallengeGame.Deleted)
                {
                    this.AddLabel(50, 143, 68, String.Format("{0}", a.ChallengeGame.ChallengeName));
                    // add the info button that will open the game gump
                    this.AddButton(23, 143, 0x5689, 0x568A, 310, GumpButtonType.Reply, 0);
                }

                this.AddHtml(20, 20, 400, 120, text, true, true);

                int x1 = 20;
                int x2 = 150;
                int x3 = 290;

                if (from == target)
                {
                    // add the see kills checkbox
                    this.AddLabel(x1 + 30, 165, 55, a.Text(200226));  // "See kills"
                    this.AddButton(x1, 165, (a.ReceiveBroadcasts ? 0xD3 : 0xD2), (a.ReceiveBroadcasts ? 0xD2 : 0xD3), 100, GumpButtonType.Reply, 0);

                    // add the broadcast kills checkbox
                    this.AddLabel(x2 + 30, 165, 55, a.Text(200227));  // "Broadcast kills"
                    this.AddButton(x2, 165, (a.Broadcast ? 0xD3 : 0xD2), (a.Broadcast ? 0xD2 : 0xD3), 200, GumpButtonType.Reply, 0);

                    // add the topplayers button
                    this.AddLabel(x3 + 30, 165, 55, a.Text(200228));  // "Top players"
                    this.AddButton(x3, 165, 0xFAB, 0xFAD, 300, GumpButtonType.Reply, 0);

                    // add the challenge button
                    this.AddLabel(x1 + 30, 190, 55, a.Text(200229));   // "Challenge"
                    this.AddButton(x1, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0);

                    // add the last man standing challenge button
                    this.AddLabel(x2 + 30, 190, 55, a.Text(200230));   // "LMS"
                    this.AddButton(x2, 190, 0xFAB, 0xFAD, 401, GumpButtonType.Reply, 0);

                    // add the deathmatch challenge button
                    this.AddLabel(x3 + 30, 190, 55, a.Text(200231));  // "Deathmatch"
                    this.AddButton(x3, 190, 0xFAB, 0xFAD, 403, GumpButtonType.Reply, 0);

                    // add the kingofthehill challenge button
                    this.AddLabel(x1 + 30, 215, 55, a.Text(200232));  // "KotH"
                    this.AddButton(x1, 215, 0xFAB, 0xFAD, 404, GumpButtonType.Reply, 0);

                    // add the deathball challenge button
                    this.AddLabel(x2 + 30, 215, 55, a.Text(200233));  // "DeathBall"
                    this.AddButton(x2, 215, 0xFAB, 0xFAD, 405, GumpButtonType.Reply, 0);

                    // add the teamlms challenge button
                    this.AddLabel(x3 + 30, 215, 55, a.Text(200234));  // "Team LMS"
                    this.AddButton(x3, 215, 0xFAB, 0xFAD, 406, GumpButtonType.Reply, 0);

                    // add the team deathmatch challenge button
                    this.AddLabel(x1 + 30, 240, 55, a.Text(200235));   // "Team DMatch"
                    this.AddButton(x1, 240, 0xFAB, 0xFAD, 407, GumpButtonType.Reply, 0);

                    // add the team deathball challenge button
                    this.AddLabel(x2 + 30, 240, 55, a.Text(200236));  // "Team DBall"
                    this.AddButton(x2, 240, 0xFAB, 0xFAD, 408, GumpButtonType.Reply, 0);

                    // add the team KotH challenge button
                    this.AddLabel(x3 + 30, 240, 55, a.Text(200237));  // "Team KotH"
                    this.AddButton(x3, 240, 0xFAB, 0xFAD, 409, GumpButtonType.Reply, 0);
                    
                    // add the CTF challenge button
                    this.AddLabel(x1 + 30, 265, 55, a.Text(200238));  // "CTF"
                    this.AddButton(x1, 265, 0xFAB, 0xFAD, 410, GumpButtonType.Reply, 0);
                }
            }
Ejemplo n.º 5
0
 public static void AddAllPoints_OnCommand(CommandEventArgs e)
 {
     int count = 0;
     foreach (Mobile m in World.Mobiles.Values)
     {
         if (m.Player)
         {
             // does this player already have a points attachment?
             ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlPoints));
             if (list == null || list.Count == 0)
             {
                 XmlAttachment x = new XmlPoints();
                 XmlAttach.AttachTo(e.Mobile, m, x);
                 count++;
             }
         }
     }
     e.Mobile.SendMessage("Added XmlPoints attachments to {0} players", count);
 }
Ejemplo n.º 6
0
 public CancelTimer(XmlPoints a, TimeSpan delay)
     : base(delay)
 {
     this.Priority = TimerPriority.OneSecond;
     this.m_attachment = a;
 }
Ejemplo n.º 7
0
			public RankEntry(Mobile m, XmlPoints attachment)
			{
				Killer = m;
				PointsAttachment = attachment;
			}