public Preferences(GenericReader reader) { int version = reader.ReadEncodedInt(); switch (version) { case 0: { int count = reader.ReadEncodedInt(); m_Table = new Hashtable(count); m_Entries = new ArrayList(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; } } }
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; } }
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); }
public static Arena FindArena(List <Mobile> players) { Preferences prefs = Preferences.Instance; if (prefs == null) { return(FindArena()); } if (m_Arenas.Count == 0) { return(null); } if (players.Count > 0) { Mobile first = players[0]; List <ArenaController> allControllers = ArenaController.Instances; for (int i = 0; i < allControllers.Count; ++i) { ArenaController controller = 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 = 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); } } } } List <ArenaEntry> arenas = new List <ArenaEntry>(); for (int i = 0; i < m_Arenas.Count; ++i) { Arena arena = m_Arenas[i]; if (!arena.IsOccupied) { arenas.Add(new ArenaEntry(arena)); } } if (arenas.Count == 0) { return(m_Arenas[0]); } int tc = 0; for (int i = 0; i < arenas.Count; ++i) { ArenaEntry ae = arenas[i]; for (int j = 0; j < players.Count; ++j) { PreferencesEntry pe = prefs.Find(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 = arenas[i]; if (rn < ae.Value) { return(ae.m_Arena); } rn -= ae.Value; } return(arenas[Utility.Random(arenas.Count)].m_Arena); }