示例#1
0
        public static int GetExperienceGain(LadderEntry us, LadderEntry them, bool weWon)
        {
            if (us == null || them == null)
            {
                return(0);
            }

            int ourLevel   = GetLevel(us.Experience);
            int theirLevel = GetLevel(them.Experience);

            int scalar = GetOffsetScalar(ourLevel, theirLevel, weWon);

            if (scalar == 0)
            {
                return(0);
            }

            int xp = 25 * scalar;

            if (!weWon)
            {
                xp = (xp * GetLossFactor(ourLevel)) / 100;
            }

            xp /= 100;

            if (xp <= 0)
            {
                xp = 1;
            }

            return(xp * (weWon ? 1 : -1));
        }
示例#2
0
        public LadderEntry Find(Mobile mob)
        {
            LadderEntry entry = (LadderEntry)m_Table[mob];

            if (entry == null)
            {
                m_Table[mob] = entry = new LadderEntry(mob, this);
                entry.Index  = m_Entries.Count;
                m_Entries.Add(entry);
            }

            return(entry);
        }
示例#3
0
        private void Append(StringBuilder sb, LadderEntry le)
        {
            if (le == null)
            {
                return;
            }

            if (sb.Length > 0)
            {
                sb.Append(", ");
            }

            sb.Append(le.Mobile.Name);
        }
示例#4
0
        public Ladder(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

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

                m_Table   = new Hashtable(count);
                m_Entries = new ArrayList(count);

                for (int i = 0; i < count; ++i)
                {
                    LadderEntry entry = new LadderEntry(reader, this, version);

                    if (entry.Mobile != null)
                    {
                        m_Table[entry.Mobile] = entry;
                        entry.Index           = m_Entries.Count;
                        m_Entries.Add(entry);
                    }
                }

                if (version == 0)
                {
                    m_Entries.Sort();

                    for (int i = 0; i < m_Entries.Count; ++i)
                    {
                        LadderEntry entry = (LadderEntry)m_Entries[i];

                        entry.Index = i;
                    }
                }

                break;
            }
            }
        }
示例#5
0
        public void UpdateEntry(LadderEntry entry)
        {
            int index = entry.Index;

            if (index >= 0 && index < m_Entries.Count)
            {
                // sanity

                int c;

                while ((index - 1) >= 0 && (c = entry.CompareTo(m_Entries[index - 1])) < 0)
                {
                    index = Swap(index, index - 1);
                }

                while ((index + 1) < m_Entries.Count && (c = entry.CompareTo(m_Entries[index + 1])) > 0)
                {
                    index = Swap(index, index + 1);
                }
            }
        }
示例#6
0
        public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
        {
            m_From   = from;
            m_Gate   = gate;
            m_Arenas = Arena.Arenas;

            AddPage(0);

            int height = 12 + 20 + (m_Arenas.Count * 31) + 24 + 12;

            AddBackground(0, 0, 499 + 40, height, 0x2436);

            List <Arena> list = m_Arenas;

            for (int i = 1; i < list.Count; i += 2)
            {
                AddImageTiled(12, 32 + (i * 31), 475 + 40, 30, 0x2430);
            }

            AddAlphaRegion(10, 10, 479 + 40, height - 20);

            AddColumnHeader(35, null);
            AddColumnHeader(115, "Arena");
            AddColumnHeader(325, "Participants");
            AddColumnHeader(40, "Obs");

            AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0);
            AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0);

            for (int i = 0; i < list.Count; ++i)
            {
                Arena ar = list[i];

                string name = ar.Name;

                if (name == null)
                {
                    name = "(no name)";
                }

                int x = 12;
                int y = 32 + (i * 31);

                int color = (ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC);

                AddRadio(x + 3, y + 1, 9727, 9730, false, i);
                x += 35;

                AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
                x += 115;

                StringBuilder sb = new StringBuilder();

                if (ar.Players.Count > 0)
                {
                    Ladder ladder = Ladder.Instance;

                    if (ladder == null)
                    {
                        continue;
                    }

                    LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;

                    for (int j = 0; j < ar.Players.Count; ++j)
                    {
                        Mobile      mob = (Mobile)ar.Players[j];
                        LadderEntry c   = ladder.Find(mob);

                        if (p1 == null || c.Index < p1.Index)
                        {
                            p4 = p3;
                            p3 = p2;
                            p2 = p1;
                            p1 = c;
                        }
                        else if (p2 == null || c.Index < p2.Index)
                        {
                            p4 = p3;
                            p3 = p2;
                            p2 = c;
                        }
                        else if (p3 == null || c.Index < p3.Index)
                        {
                            p4 = p3;
                            p3 = c;
                        }
                        else if (p4 == null || c.Index < p4.Index)
                        {
                            p4 = c;
                        }
                    }

                    Append(sb, p1);
                    Append(sb, p2);
                    Append(sb, p3);
                    Append(sb, p4);

                    if (ar.Players.Count > 4)
                    {
                        sb.Append(", ...");
                    }
                }
                else
                {
                    sb.Append("Empty");
                }

                AddBorderedText(x + 5, y + 5, 325 - 5, sb.ToString(), color, 0);
                x += 325;

                AddBorderedText(x, y + 5, 40, Center(ar.Spectators.ToString()), color, 0);
            }
        }
示例#7
0
        public LadderGump(Ladder ladder, int page) : base(50, 50)
        {
            m_Ladder = ladder;
            m_Page   = page;

            AddPage(0);

            ArrayList list = ladder.ToArrayList();

            m_List = list;

            int lc = Math.Min(list.Count, 150);

            int start = page * 15;
            int end   = start + 15;

            if (end > lc)
            {
                end = lc;
            }

            int ct = end - start;

            int height = 12 + 20 + (ct * 20) + 23 + 12;

            AddBackground(0, 0, 499, height, 0x2436);

            for (int i = start + 1; i < end; i += 2)
            {
                AddImageTiled(12, 32 + ((i - start) * 20), 475, 20, 0x2430);
            }

            AddAlphaRegion(10, 10, 479, height - 20);

            if (page > 0)
            {
                AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(446, height - 12 - 2 - 16, 0x2626);
            }

            if (((page + 1) * 15) < lc)
            {
                AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(466, height - 12 - 2 - 16, 0x2622);
            }

            AddHtml(16, height - 12 - 2 - 18, 400, 20, Color(String.Format("Top {3} of {0:N0} duelists, page {1} of {2}", list.Count, page + 1, (lc + 14) / 15, lc), 0xFFC000), false, false);

            AddColumnHeader(75, "Rank");
            AddColumnHeader(115, "Level");
            AddColumnHeader(50, "Guild");
            AddColumnHeader(115, "Name");
            AddColumnHeader(60, "Wins");
            AddColumnHeader(60, "Losses");

            for (int i = start; i < end && i < lc; ++i)
            {
                LadderEntry entry = (LadderEntry)list[i];

                int y = 32 + ((i - start) * 20);
                int x = 12;

                AddBorderedText(x, y, 75, Center(Rank(i + 1)), 0xFFFFFF, 0);
                x += 75;

                /*AddImage( 20, y + 5, 0x2616, 0x96C );
                *               AddImage( 22, y + 5, 0x2616, 0x96C );
                *               AddImage( 20, y + 7, 0x2616, 0x96C );
                *               AddImage( 22, y + 7, 0x2616, 0x96C );
                *
                *               AddImage( 21, y + 6, 0x2616, 0x454 );*/

                AddImage(x + 3, y + 4, 0x805);

                int xp    = entry.Experience;
                int level = Ladder.GetLevel(xp);

                int xpBase, xpAdvance;
                Ladder.GetLevelInfo(level, out xpBase, out xpAdvance);

                int width;

                int xpOffset = xp - xpBase;

                if (xpOffset >= xpAdvance)
                {
                    width = 109; // level 50
                }
                else
                {
                    width = ((109 * xpOffset) + (xpAdvance / 2)) / (xpAdvance - 1);
                }

                //AddImageTiled( 21, y + 6, width, 8, 0x2617 );
                AddImageTiled(x + 3, y + 4, width, 11, 0x806);
                AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0);
                x += 115;

                Mobile mob = entry.Mobile;

                if (mob.Guild != null)
                {
                    AddBorderedText(x, y, 50, Center(mob.Guild.Abbreviation), 0xFFFFFF, 0);
                }

                x += 50;

                AddBorderedText(x + 5, y, 115 - 5, (mob.Name), 0xFFFFFF, 0);
                x += 115;

                AddBorderedText(x, y, 60, Center(entry.Wins.ToString()), 0xFFFFFF, 0);
                x += 60;

                AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0);
                x += 60;

                //AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0} <DIV ALIGN=CENTER>/</DIV> <DIV ALIGN=RIGHT>{1}</DIV>", entry.Wins, entry.Losses ), 0xFFC000, 0 );
            }
        }