Example #1
0
        public Preferences(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

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

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

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

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

                break;
            }
            }
        }
Example #2
0
        public Preferences(IGenericReader reader)
        {
            var version = reader.ReadEncodedInt();

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

                m_Table = new Dictionary <Mobile, PreferencesEntry>(count);
                Entries = new List <PreferencesEntry>(count);

                for (var i = 0; i < count; ++i)
                {
                    var entry = new PreferencesEntry(reader, version);

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

                break;
            }
            }
        }
Example #3
0
        public Preferences(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

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

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

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

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

                        break;
                    }
            }
        }
Example #4
0
        public PreferencesEntry Find(Mobile mob)
        {
            if (m_Table.TryGetValue(mob, out var entry))
            {
                m_Table[mob] = entry = new PreferencesEntry(mob);
                Entries.Add(entry);
            }

            return(entry);
        }
Example #5
0
        public PreferencesGump(Mobile from, Preferences prefs)
            : base(50, 50)
        {
            this.m_From  = from;
            this.m_Entry = prefs.Find(from);

            if (this.m_Entry == null)
            {
                return;
            }

            List <Arena> arenas = Arena.Arenas;

            this.AddPage(0);

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

            this.AddBackground(0, 0, 499 + 40 - 365, height, 0x2436);

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

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

            this.AddColumnHeader(35, null);
            this.AddColumnHeader(115, "Arena");

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

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

                string name = ar.Name;

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

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

                int color = 0xCCFFCC;

                this.AddCheck(x + 3, y + 1, 9730, 9727, this.m_Entry.Disliked.Contains(name), i);
                x += 35;

                this.AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
                x += 115;
            }
        }
Example #6
0
		public PreferencesEntry Find( Mobile mob )
		{
			PreferencesEntry entry = (PreferencesEntry) m_Table[mob];

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

			return entry;
		}
Example #7
0
        public PreferencesEntry Find(Mobile mob)
        {
            PreferencesEntry entry = (PreferencesEntry)this.m_Table[mob];

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

            return(entry);
        }
Example #8
0
        public PreferencesEntry Find(Mobile mob)
        {
            PreferencesEntry entry;

            m_Table.TryGetValue(mob, out entry);

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

            return(entry);
        }
Example #9
0
        public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
        {
            m_Entry = prefs.Find(from);

            if (m_Entry == null)
            {
                return;
            }

            var arenas = Arena.Arenas;

            AddPage(0);

            var height = 12 + 20 + arenas.Count * 31 + 24 + 12;

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

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

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

            AddColumnHeader(35, null);
            AddColumnHeader(115, "Arena");

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

            for (var i = 0; i < arenas.Count; ++i)
            {
                var ar = arenas[i];

                var name = ar.Name ?? "(no name)";

                var x = 12;
                var y = 32 + i * 31;

                var color = 0xCCFFCC;

                AddCheck(x + 3, y + 1, 9730, 9727, m_Entry.Disliked.Contains(name), i);
                x += 35;

                AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
            }
        }
Example #10
0
		public PreferencesGump( Mobile from, Preferences prefs ) : base( 50, 50 )
		{
			m_From = from;
			m_Entry = prefs.Find( from );

			if ( m_Entry == null )
				return;

			List<Arena> arenas = Arena.Arenas;

			AddPage( 0 );

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

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

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

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

			AddColumnHeader(  35, null );
			AddColumnHeader( 115, "Arena" );

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

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

				string name = ar.Name;

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

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

				int color = 0xCCFFCC;

				AddCheck( x + 3, y + 1, 9730, 9727, m_Entry.Disliked.Contains(name), i );
				x += 35;

				AddBorderedText( x + 5, y + 5, 115 - 5, name, color, 0 );
				x += 115;
			}
		}
Example #11
0
        public static Arena FindArena(ArrayList players)
        {
            Preferences prefs = Preferences.Instance;

            if (prefs == null)
            {
                return(FindArena());
            }

            if (m_Arenas.Count == 0)
            {
                return(null);
            }

            if (players.Count > 0)
            {
                Mobile first = (Mobile)players[0];

                ArrayList allControllers = ArenaController.Instances;

                for (int i = 0; i < allControllers.Count; ++i)
                {
                    ArenaController controller = (ArenaController)allControllers[i];

                    if (controller != null && !controller.Deleted && controller.Arena != null && controller.IsPrivate && controller.Map == first.Map && first.InRange(controller, 24))
                    {
                        Multis.BaseHouse house   = Multis.BaseHouse.FindHouseAt(controller);
                        bool             allNear = true;

                        for (int j = 0; j < players.Count; ++j)
                        {
                            Mobile check = (Mobile)players[j];
                            bool   isNear;

                            if (house == null)
                            {
                                isNear = (controller.Map == check.Map && check.InRange(controller, 24));
                            }
                            else
                            {
                                isNear = (Multis.BaseHouse.FindHouseAt(check) == house);
                            }

                            if (!isNear)
                            {
                                allNear = false;
                                break;
                            }
                        }

                        if (allNear)
                        {
                            return(controller.Arena);
                        }
                    }
                }
            }

            ArrayList arenas = new ArrayList();

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

                if (!arena.IsOccupied)
                {
                    arenas.Add(new ArenaEntry(arena));
                }
            }

            if (arenas.Count == 0)
            {
                return((Arena)m_Arenas[0]);
            }

            int tc = 0;

            for (int i = 0; i < arenas.Count; ++i)
            {
                ArenaEntry ae = (ArenaEntry)arenas[i];

                for (int j = 0; j < players.Count; ++j)
                {
                    PreferencesEntry pe = prefs.Find((Mobile)players[j]);

                    if (pe.Disliked.Contains(ae.m_Arena.Name))
                    {
                        ++ae.m_VotesAgainst;
                    }
                    else
                    {
                        ++ae.m_VotesFor;
                    }
                }

                tc += ae.Value;
            }

            int rn = Utility.Random(tc);

            for (int i = 0; i < arenas.Count; ++i)
            {
                ArenaEntry ae = (ArenaEntry)arenas[i];

                if (rn < ae.Value)
                {
                    return(ae.m_Arena);
                }

                rn -= ae.Value;
            }

            return(((ArenaEntry)arenas[Utility.Random(arenas.Count)]).m_Arena);
        }
Example #12
0
		public PreferencesEntry Find( Mobile mob )
		{
			PreferencesEntry entry;
			m_Table.TryGetValue( mob, out entry );

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

			return entry;
		}
Example #13
0
		public Preferences( GenericReader reader )
		{
			int version = reader.ReadEncodedInt();

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

					m_Table = new Dictionary<Mobile, PreferencesEntry>( count );
					m_Entries = new List<PreferencesEntry>( count );

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

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

					break;
				}
			}
		}