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 void AssimilateGuild(Mobile m) { if (m.Guild is Guild) { Guild g = m.Guild as Guild; childGuilds.Add(g); foreach (Mobile mob in g.Members) { if (m != mob && m is Player && ((Player)m).CurrentAlliance == null) { membersOf.Add(m); AllianceState alState = new AllianceState(); if (m is Player) { ((Player)m).CurrentAlliance = this; ((Player)m).allyState = alState; } m.SendMessage("Your guild has joined the {0} alliance.", this.AllianceName); } } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == (int)Buttons.Okay) { Player target = sender.Mobile as Player; target.CurrentAlliance = alliance; Guild g = target.Guild as Guild; alliance.childGuilds.Add(g); alliance.membersOf.Add(target); AllianceState alState = new AllianceState(); target.allyState = alState; alliance.AssimilateGuild(target); target.SendMessage("You enter into a pact with the {0}.", alliance.AllianceName); from.SendMessage("{0} has accepted your alliance invitation.", target.Name); } }
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."); } }