public override void OnResponse(NetState sender, RelayInfo info) { if (sender.Mobile is Player && ((Player)sender.Mobile).CurrentAlliance != null && ((Player)sender.Mobile).CurrentAlliance.AllianceLeader == sender.Mobile) { Player p = sender.Mobile as Player; BaseAlliance a = p.CurrentAlliance; switch (info.ButtonID) { case (int)Buttons.Button1: { } break; case (int)Buttons.Button2: { } break; case (int)Buttons.Button3: { } break; case (int)Buttons.Button4: { } break; default: break; } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == (int)Buttons.Okay && sender.Mobile is Player && !String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.TextEntry).Text)) { String nameRequested = info.GetTextEntry((int)Buttons.TextEntry).Text; if (NameVerification.Validate(nameRequested, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote) && AllianceDefinition.Alliances.Count <= AllianceDefinition.AllianceLimit) { BaseAlliance alliance = new BaseAlliance(); alliance.AllianceName = nameRequested; PlayerMobile pm = sender.Mobile as PlayerMobile; AllianceState alState = new AllianceState(); ((Player)pm).allyState = alState; alliance.membersOf.Add(pm); alliance.AllianceLeader = pm as Player; alliance.Serial = pm.Serial; alliance.SerialString = pm.Serial.ToString(); if ((Guild)pm.Guild != null) { alliance.childGuilds.Add((Guild)pm.Guild); } AllianceDefinition.Alliances.Add(alliance); ((Player)pm).CurrentAlliance = alliance; if (pm.Guild != null) { foreach (Mobile m in ((Guild)pm.Guild).Members) { if (m is Player && ((Player)m).CurrentAlliance == null) { Player p = m as Player; p.CurrentAlliance = alliance; alliance.membersOf.Add(p); alState = new AllianceState(); p.allyState = alState; p.SendMessage("Your guild has joined a new alliance."); } } } sender.Mobile.SendMessage("You have sucessfully created a new alliance."); } else { sender.Mobile.SendMessage("This is not an acceptable alliance name."); } } }
public AllianceInterface(Mobile from, InterfaceKey interfaceKey) : base(50, 50) { key = interfaceKey; if (AllianceDefinition.Alliances.Count > 0) { foreach (BaseAlliance a in AllianceDefinition.Alliances) { alliancesToParse.Add(a); } currentAllianceParsed = alliancesToParse[key.Value]; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; this.AddPage(0); this.AddBackground(23, 15, 459, 278, 9250); this.AddAlphaRegion(39, 32, 194, 54); this.AddLabel(111, 48, currentAllianceParsed.primaryHue - 1, currentAllianceParsed.AllianceName); this.AddButton(230, 258, 2468, 2466, (int)Buttons.Previous, GumpButtonType.Reply, 0); this.AddButton(406, 257, 2469, 2470, (int)Buttons.Next, GumpButtonType.Reply, 0); this.AddImage(41, 36, 8481); this.AddLabel(47, 257, 0, @"Alliance Limit: "); this.AddTextEntry(135, 257, 29, 20, 0, (int)Buttons.AllianceLimitEntry, AllianceDefinition.AllianceLimit.ToString()); this.AddLabel(85, 98, 0, @"Member Count: " + currentAllianceParsed.membersOf.Count); this.AddButton(325, 258, 2463, 2461, (int)Buttons.Delete, GumpButtonType.Reply, 0); this.AddLabel(71, 119, 0, @"Cities Controlled: " + currentAllianceParsed.CitiesControlled); this.AddLabel(71, 141, 0, @"Collective Points: " + currentAllianceParsed.CollectivePoints); this.AddLabel(44, 162, 0, @"Total Silver Amassed: " + currentAllianceParsed.TotalSilverGathered); this.AddLabel(291, 37, 0, @"Primary Hue:"); this.AddTextEntry(382, 36, 52, 20, 0, (int)Buttons.PrimeHueEntry, currentAllianceParsed.primaryHue.ToString()); this.AddLabel(277, 63, 0, @"Secondary Hue:"); this.AddTextEntry(382, 63, 52, 20, 0, (int)Buttons.SecondHueEntry, currentAllianceParsed.secondaryHue.ToString()); this.AddButton(444, 37, 1209, 1210, (int)Buttons.PrimeHueButton, GumpButtonType.Reply, 0); this.AddButton(444, 67, 1209, 1210, (int)Buttons.SecondHueButton, GumpButtonType.Reply, 0); this.AddButton(173, 261, 1209, 1210, (int)Buttons.AllianceLimitButton, GumpButtonType.Reply, 0); this.AddLabel(41, 223, 0, @"Total Alliances: " + alliancesToParse.Count); this.AddImage(432, 188, 9005); } else { from.SendMessage("There are currently no alliances with which to interface."); } }
private static void ConstructAlliances() { if (!File.Exists(allianceXML)) { return; } XmlDocument doc = new XmlDocument(); XmlElement root; try { doc.Load(allianceXML); root = doc["Alliances"]; AllianceLimit = Convert.ToInt32(root.GetAttribute("limit")); foreach (XmlElement ele in root.GetElementsByTagName("alliance")) { BaseAlliance alliance = new BaseAlliance(); alliance.AllianceName = ele.Attributes["name"].Value; alliance.SerialString = ele.Attributes["serial"].Value; alliance.leaderSerial = ele.Attributes["leader"].Value; string serials = ele.InnerText.ToString(); string[] serialStrings = serials.Split(','); foreach (string s in serialStrings) { string serial = s.Trim(); alliance.memberSerials.Add(serial); } Alliances.Add(alliance); } } catch { } }
public static void Deserialize(BinaryFileReader reader) { int version = reader.ReadInt(); if (version >= 0) { AllianceLimit = reader.ReadInt(); useXML = reader.ReadBool(); int count = reader.ReadInt(); for (int i = 1; i <= count; i++) { BaseAlliance alliance = new BaseAlliance(); alliance.Deserialize(reader); Alliances.Add(alliance); } } reader.Close(); }
public JoinAllianceQuery(Mobile m) : base(50, 50) { if (m is Player) { alliance = ((Player)m).CurrentAlliance; } from = m; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; this.AddPage(0); this.AddBackground(87, 53, 323, 164, 9350); this.AddHtml(104, 85, 284, 45, m.Name + @" Is inviting you to join an alliance. Do you accept?", true, true); this.AddButton(214, 162, 247, 248, (int)Buttons.Okay, GumpButtonType.Reply, 0); this.AddButton(303, 162, 241, 242, (int)Buttons.Cancel, GumpButtonType.Reply, 0); }
public JoinAllianceQuery(Mobile m) : base(50, 50) { if (m is Player) alliance = ((Player)m).CurrentAlliance; from = m; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; this.AddPage(0); this.AddBackground(87, 53, 323, 164, 9350); this.AddHtml(104, 85, 284, 45, m.Name + @" Is inviting you to join an alliance. Do you accept?", true, true); this.AddButton(214, 162, 247, 248, (int)Buttons.Okay, GumpButtonType.Reply, 0); this.AddButton(303, 162, 241, 242, (int)Buttons.Cancel, GumpButtonType.Reply, 0); }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == (int)Buttons.Okay && sender.Mobile is Player && !String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.TextEntry).Text)) { String nameRequested = info.GetTextEntry((int)Buttons.TextEntry).Text; if (NameVerification.Validate(nameRequested, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote) && AllianceDefinition.Alliances.Count <= AllianceDefinition.AllianceLimit) { BaseAlliance alliance = new BaseAlliance(); alliance.AllianceName = nameRequested; PlayerMobile pm = sender.Mobile as PlayerMobile; AllianceState alState = new AllianceState(); ((Player)pm).allyState = alState; alliance.membersOf.Add(pm); alliance.AllianceLeader = pm as Player; alliance.Serial = pm.Serial; alliance.SerialString = pm.Serial.ToString(); if ((Guild)pm.Guild != null) alliance.childGuilds.Add((Guild)pm.Guild); AllianceDefinition.Alliances.Add(alliance); ((Player)pm).CurrentAlliance = alliance; if (pm.Guild != null) { foreach (Mobile m in ((Guild)pm.Guild).Members) { if (m is Player && ((Player)m).CurrentAlliance == null) { Player p = m as Player; p.CurrentAlliance = alliance; alliance.membersOf.Add(p); alState = new AllianceState(); p.allyState = alState; p.SendMessage("Your guild has joined a new alliance."); } } } sender.Mobile.SendMessage("You have sucessfully created a new alliance."); } else sender.Mobile.SendMessage("This is not an acceptable alliance name."); } }
private static void ConstructAlliances() { if (!File.Exists(allianceXML)) return; XmlDocument doc = new XmlDocument(); XmlElement root; try { doc.Load(allianceXML); root = doc["Alliances"]; AllianceLimit = Convert.ToInt32(root.GetAttribute("limit")); foreach (XmlElement ele in root.GetElementsByTagName("alliance")) { BaseAlliance alliance = new BaseAlliance(); alliance.AllianceName = ele.Attributes["name"].Value; alliance.SerialString = ele.Attributes["serial"].Value; alliance.leaderSerial = ele.Attributes["leader"].Value; string serials = ele.InnerText.ToString(); string[] serialStrings = serials.Split(','); foreach (string s in serialStrings) { string serial = s.Trim(); alliance.memberSerials.Add(serial); } Alliances.Add(alliance); } } catch { } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == (int)Buttons.Delete) { currentAllianceParsed.Sanitize(); if (AllianceDefinition.Alliances.Count > 0) { foreach (BaseAlliance a in AllianceDefinition.Alliances) alliancesToParse.Add(a); currentAllianceParsed = alliancesToParse[key.Value]; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } sender.Mobile.SendMessage("Selected alliance has been purged."); } if (info.ButtonID == (int)Buttons.Next) { if (key.Value < alliancesToParse.Count -1) { sender.Mobile.CloseGump(typeof(AllianceInterface)); key.Value++; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } if (info.ButtonID == (int)Buttons.Previous) { if (key.Value > 0) { sender.Mobile.CloseGump(typeof(AllianceInterface)); key.Value--; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } if (info.ButtonID == (int)Buttons.PrimeHueButton) { if(!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text)) { int newHue = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text)) { try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text); } catch { sender.Mobile.SendMessage("Invalid hue entry, please try again."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newHue <= 0 || newHue > 3000) { sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); sender.Mobile.SendMessage("Hue value out of range (1-3000)"); return; } if (newHue > 0 && newHue < 3000) currentAllianceParsed.primaryHue = newHue; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } if (info.ButtonID == (int)Buttons.SecondHueButton) { if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text)) { int newHue = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text)) { try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.SecondHueEntry).Text); } catch { sender.Mobile.SendMessage("Invalid hue entry, please try again."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newHue <= 0 || newHue > 3000) { sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); sender.Mobile.SendMessage("Hue value out of range (1-3000)"); return; } if (newHue > 0 && newHue < 3000) currentAllianceParsed.secondaryHue = newHue; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } if (info.ButtonID == (int)Buttons.AllianceLimitButton) { int newLimit = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text)) { try { newLimit = Int32.Parse(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text); } catch { sender.Mobile.SendMessage("You have entered invalid characters."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit <= 0) { sender.Mobile.SendMessage("The alliance limit must be a number larger than 0"); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit < AllianceDefinition.Alliances.Count) { sender.Mobile.SendMessage("The alliance limit can not be less than the number of active alliances."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit > 0 && newLimit >= AllianceDefinition.Alliances.Count) { AllianceDefinition.AllianceLimit = newLimit; sender.Mobile.SendMessage("The maximum number of alliances has been changed."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } }
public AllianceInterface(Mobile from, InterfaceKey interfaceKey) : base(50, 50) { key = interfaceKey; if (AllianceDefinition.Alliances.Count > 0) { foreach (BaseAlliance a in AllianceDefinition.Alliances) alliancesToParse.Add(a); currentAllianceParsed = alliancesToParse[key.Value]; this.Closable = true; this.Disposable = true; this.Dragable = true; this.Resizable = false; this.AddPage(0); this.AddBackground(23, 15, 459, 278, 9250); this.AddAlphaRegion(39, 32, 194, 54); this.AddLabel(111, 48, currentAllianceParsed.primaryHue -1, currentAllianceParsed.AllianceName); this.AddButton(230, 258, 2468, 2466, (int)Buttons.Previous, GumpButtonType.Reply, 0); this.AddButton(406, 257, 2469, 2470, (int)Buttons.Next, GumpButtonType.Reply, 0); this.AddImage(41, 36, 8481); this.AddLabel(47, 257, 0, @"Alliance Limit: "); this.AddTextEntry(135, 257, 29, 20, 0, (int)Buttons.AllianceLimitEntry, AllianceDefinition.AllianceLimit.ToString()); this.AddLabel(85, 98, 0, @"Member Count: " + currentAllianceParsed.membersOf.Count); this.AddButton(325, 258, 2463, 2461, (int)Buttons.Delete, GumpButtonType.Reply, 0); this.AddLabel(71, 119, 0, @"Cities Controlled: " + currentAllianceParsed.CitiesControlled); this.AddLabel(71, 141, 0, @"Collective Points: " + currentAllianceParsed.CollectivePoints); this.AddLabel(44, 162, 0, @"Total Silver Amassed: " + currentAllianceParsed.TotalSilverGathered); this.AddLabel(291, 37, 0, @"Primary Hue:"); this.AddTextEntry(382, 36, 52, 20, 0, (int)Buttons.PrimeHueEntry, currentAllianceParsed.primaryHue.ToString()); this.AddLabel(277, 63, 0, @"Secondary Hue:"); this.AddTextEntry(382, 63, 52, 20, 0, (int)Buttons.SecondHueEntry, currentAllianceParsed.secondaryHue.ToString()); this.AddButton(444, 37, 1209, 1210, (int)Buttons.PrimeHueButton, GumpButtonType.Reply, 0); this.AddButton(444, 67, 1209, 1210, (int)Buttons.SecondHueButton, GumpButtonType.Reply, 0); this.AddButton(173, 261, 1209, 1210, (int)Buttons.AllianceLimitButton, GumpButtonType.Reply, 0); this.AddLabel(41, 223, 0, @"Total Alliances: " + alliancesToParse.Count); this.AddImage(432, 188, 9005); } else from.SendMessage("There are currently no alliances with which to interface."); }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == (int)Buttons.Delete) { currentAllianceParsed.Sanitize(); if (AllianceDefinition.Alliances.Count > 0) { foreach (BaseAlliance a in AllianceDefinition.Alliances) { alliancesToParse.Add(a); } currentAllianceParsed = alliancesToParse[key.Value]; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } sender.Mobile.SendMessage("Selected alliance has been purged."); } if (info.ButtonID == (int)Buttons.Next) { if (key.Value < alliancesToParse.Count - 1) { sender.Mobile.CloseGump(typeof(AllianceInterface)); key.Value++; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } if (info.ButtonID == (int)Buttons.Previous) { if (key.Value > 0) { sender.Mobile.CloseGump(typeof(AllianceInterface)); key.Value--; sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } if (info.ButtonID == (int)Buttons.PrimeHueButton) { if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text)) { int newHue = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text)) { try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text); } catch { sender.Mobile.SendMessage("Invalid hue entry, please try again."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newHue <= 0 || newHue > 3000) { sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); sender.Mobile.SendMessage("Hue value out of range (1-3000)"); return; } if (newHue > 0 && newHue < 3000) { currentAllianceParsed.primaryHue = newHue; } sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } if (info.ButtonID == (int)Buttons.SecondHueButton) { if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text)) { int newHue = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text)) { try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.SecondHueEntry).Text); } catch { sender.Mobile.SendMessage("Invalid hue entry, please try again."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newHue <= 0 || newHue > 3000) { sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); sender.Mobile.SendMessage("Hue value out of range (1-3000)"); return; } if (newHue > 0 && newHue < 3000) { currentAllianceParsed.secondaryHue = newHue; } sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } if (info.ButtonID == (int)Buttons.AllianceLimitButton) { int newLimit = 0; if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text)) { try { newLimit = Int32.Parse(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text); } catch { sender.Mobile.SendMessage("You have entered invalid characters."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit <= 0) { sender.Mobile.SendMessage("The alliance limit must be a number larger than 0"); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit < AllianceDefinition.Alliances.Count) { sender.Mobile.SendMessage("The alliance limit can not be less than the number of active alliances."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); return; } if (newLimit > 0 && newLimit >= AllianceDefinition.Alliances.Count) { AllianceDefinition.AllianceLimit = newLimit; sender.Mobile.SendMessage("The maximum number of alliances has been changed."); sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key)); } } } }