Beispiel #1
0
        public override bool HasRelationship(Guild g)
        {
            if (g == guild)
            {
                return(false);
            }

            if (guild.FindPendingWar(g) != null)
            {
                return(true);
            }

            AllianceInfo alliance = guild.Alliance;

            if (alliance != null)
            {
                Guild leader = alliance.Leader;

                if (leader != null)
                {
                    if (guild == leader && alliance.IsPendingMember(g) || g == leader && alliance.IsPendingMember(guild))
                    {
                        return(true);
                    }
                }
                else if (alliance.IsPendingMember(g))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public static Guild GetAllianceLeader(Guild g)
        {
            AllianceInfo alliance = g.Alliance;

            if (alliance?.Leader != null && alliance.IsMember(g))
            {
                return(alliance.Leader);
            }

            return(g);
        }
Beispiel #3
0
        private void VerifyGuild_Callback()
        {
            if ((!NewGuildSystem && Guildstone == null) || Members.Count == 0)
            {
                Disband();
            }

            CheckExpiredWars();

            AllianceInfo alliance = Alliance;

            alliance?.CheckLeader();

            alliance = Alliance;                                                      // CheckLeader could possibly change the value of this.Alliance

            if (alliance?.IsMember(this) == false && !alliance.IsPendingMember(this)) // This block is there to fix a bug in the code in an older version.
            {
                Alliance = null;                                                      // Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding
            }
        }
Beispiel #4
0
 public override void Serialize(IDataWriter writer)
 {
     AllianceInfo.Serialize(writer);
     writer.WriteBoolean(Enabled);
     writer.WriteVarUhInt(LeadingGuildId);
 }
Beispiel #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (!IsMember(pm, guild))
            {
                return;
            }

            RankDefinition playerRank = pm.GuildRank;

            switch (info.ButtonID)
            {
            case 1:
            {
                AllianceInfo alliance      = guild.Alliance;
                AllianceInfo otherAlliance = m_Other.Alliance;

                if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                {
                    pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                }
                else if (otherAlliance != null && otherAlliance.Leader != m_Other)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", m_Other.Name, otherAlliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);                                   // You need to negotiate via ~1_val~ instead.
                }
                else
                {
                    WarDeclaration activeWar = guild.FindActiveWar(m_Other);

                    if (activeWar == null)
                    {
                        WarDeclaration war      = guild.FindPendingWar(m_Other);
                        WarDeclaration otherWar = m_Other.FindPendingWar(guild);

                        //Note: OSI differs from what it says on website.  unlimited war = 0 kills/ 0 hrs.  Not > 999.  (sidenote: they both cap at 65535, 7.5 years, but, still.)
                        TextRelay tKills     = info.GetTextEntry(11);
                        TextRelay tWarLength = info.GetTextEntry(10);

                        int      maxKills  = (tKills == null) ? 0 : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0);
                        TimeSpan warLength = TimeSpan.FromHours((tWarLength == null) ? 0 : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0));

                        if (war != null)
                        {
                            war.MaxKills     = maxKills;
                            war.WarLength    = warLength;
                            war.WarRequester = true;
                        }
                        else
                        {
                            guild.PendingWars.Add(new WarDeclaration(guild, m_Other, maxKills, warLength, true));
                        }

                        if (otherWar != null)
                        {
                            otherWar.MaxKills     = maxKills;
                            otherWar.WarLength    = warLength;
                            otherWar.WarRequester = false;
                        }
                        else
                        {
                            m_Other.PendingWars.Add(new WarDeclaration(m_Other, guild, maxKills, warLength, false));
                        }

                        if (war != null)
                        {
                            pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                                      //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.
                        }
                        else
                        {
                            m_Other.GuildMessage(1070781, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));         // ~1_val~ has proposed a war.
                        }
                        pm.SendLocalizedMessage(1070751, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name));    // War proposal has been sent to ~1_val~.
                    }
                }
                break;
            }

            default:
            {
                pm.SendGump(new OtherGuildInfo(pm, guild, m_Other));
                break;
            }
            }
        }
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int val = (info.ButtonID - 1);

            if (val < 0)
            {
                return;
            }

            int type  = (val % 10);
            int index = (val / 10);

            switch (type)
            {
            case 0:
            {
                Page page;

                switch (index)
                {
                case 0: page = Page.Information; break;

                case 1: page = Page.Guilds; break;

                case 2: page = Page.Alliances; break;

                default: return;
                }

                _from.SendGump(new GuildAdminGump(_from, page, 0, null, null, null));
            } break;

            case 1:                     //change page
            {
                switch (index)
                {
                case 0:
                {
                    if (_list != null && _listPage > 0)
                    {
                        _from.SendGump(new GuildAdminGump(_from, _pageType, (_listPage - 1), null, null, _state));
                    }
                } break;

                case 1:
                {
                    if (_list != null)
                    {
                        _from.SendGump(new GuildAdminGump(_from, _pageType, (_listPage + 1), null, null, _state));
                    }
                } break;
                }
            } break;

            case 4:                     //search or show guild details
            {
                switch (index)
                {
                case 0:
                case 1:
                {
                    TextRelay relay  = info.GetTextEntry(0);
                    string    toFind = (relay == null ? null : relay.Text.Trim().ToLower());
                    string    notice = "";

                    List <Guild> foundList = SearchForGuild(toFind, (index == 0), out notice);

                    if (foundList.Count == 1)
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, "One match found.", null, foundList[0]));
                    }
                    else
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.Guilds, 0, (notice == null ? (foundList.Count == 0 ? "Nothing matched your search terms." : null) : notice), foundList, null));
                    }

                    break;
                }

                default:
                {
                    index -= 2;

                    if (_list != null && index >= 0 && index < _list.Count)
                    {
                        Guild g = _list[index];

                        if (g == null)
                        {
                            break;
                        }

                        _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, null, null, g));
                    }

                    break;
                }
                }
            } break;

            case 5:                     //show alliance details
            {
                List <AllianceInfo> allianceList = new List <AllianceInfo>(_allianceTable.Keys);

                if (allianceList != null && index >= 0 && index < allianceList.Count)
                {
                    AllianceInfo aInfo = allianceList[index];

                    if (aInfo == null)
                    {
                        break;
                    }

                    _from.SendGump(new GuildAdminGump(_from, Page.AllianceDetails, 0, null, null, aInfo));
                }
            } break;

            case 6:                     //show war details
            {
                if (_state is Guild)
                {
                    _from.SendGump(new GuildAdminGump(_from, Page.WarDetails, 0, null, null, ((Guild)_state).AcceptedWars[index]));
                }
            } break;

            case 7:                     //show guild details
            {
                switch (index)
                {
                case 0:                                         //disband
                {
                    string warning = String.Format("You are about to disband the guild \"{0}.\" Are you sure you want to do this?", ((Guild)_state).Name);
                    _from.SendGump(new WarningGump(1060635, 30720, warning, 0xFFC000, 420, 200, new WarningGumpCallback(DisbandGuild_Callback), _state));

                    break;
                }

                case 1:                                         //alliance details
                {
                    if (((Guild)_state).Alliance == null)
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, "This guild is not a member of an alliance.", null, _state));
                    }
                    else
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.AllianceDetails, 0, null, null, ((Guild)_state).Alliance));
                    }

                    break;
                }

                case 2:                                         //member list
                {
                    _from.SendGump(new GuildAdminGump(_from, Page.GuildMemberList, 0, null, null, (Guild)_state));

                    break;
                }

                case 3:                                         //war list
                {
                    if (((Guild)_state).AcceptedWars == null || ((Guild)_state).AcceptedWars.Count == 0)
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, "This guild is not involved in any wars.", null, _state));
                    }
                    else
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.Wars, 0, null, null, _state));
                    }

                    break;
                }

                case 4:                                         //add member
                {
                    _from.Target = new InternalRecruitTarget((Guild)_state);
                    _from.SendMessage("Select the player to recruit into \"{0}.\"", ((Guild)_state).Name);

                    _from.SendGump(new GuildAdminGump(_from, _pageType, 0, null, null, _state));

                    break;
                }

                case 5:                                         //guild properties [same as the GuildProps command]
                {
                    _from.SendGump(new PropertiesGump(_from, (Guild)_state));
                    _from.SendGump(new GuildInfoGump((Server.Mobiles.PlayerMobile)_from, (Guild)_state));

                    _from.SendGump(new GuildAdminGump(_from, _pageType, 0, null, null, _state));

                    break;
                }
                }
            } break;

            case 8:                     //alliance details
            {
                switch (index)
                {
                case 0:                                         //disband
                {
                    string warning = String.Format("You are about to disband the alliance \"{0}.\" Are you sure you want to do this?", ((AllianceInfo)_state).Name);
                    _from.SendGump(new WarningGump(1060635, 30720, warning, 0xFFC000, 420, 200, new WarningGumpCallback(DisbandAlliance_Callback), _state));

                    break;
                }

                case 1:                                         //member list
                {
                    AllianceInfo aInfo = _state as AllianceInfo;

                    if (_allianceTable.ContainsKey(aInfo))
                    {
                        _from.SendGump(new GuildAdminGump(_from, Page.Guilds, 0, null, _allianceTable[aInfo], null));
                    }
                    else
                    {
                        _from.SendGump(new GuildAdminGump(_from, _pageType, 0, "The list of members for this alliance could not be found.", null, _state));
                    }

                    break;
                }
                }
            } break;

            case 9:                     //war details
            {
                switch (index)
                {
                case 0: _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, null, null, ((WarDeclaration)_state).Guild)); break;

                case 1: _from.SendGump(new GuildAdminGump(_from, Page.GuildInfo, 0, null, null, ((WarDeclaration)_state).Opponent)); break;
                }
            } break;
            }
        }
        public GuildAdminGump(Mobile from, Page page, int listPage, string notice, List <Guild> list, object state)
            : base(50, 40)
        {
            from.CloseGump(typeof(GuildAdminGump));

            if (list == null)
            {
                PopulateGuildList();
            }
            else
            {
                _list = list;
            }

            PopulateAllianceTable();
            PopulateWarTable();

            _from     = from;
            _pageType = page;
            _listPage = listPage;
            _state    = state;

            AddPage(0);
            AddBackground(0, 0, 420, 440, 5054);

            AddBlackAlpha(10, 10, 170, 100);
            AddBlackAlpha(190, 10, 220, 100);
            AddBlackAlpha(10, 120, 400, 260);
            AddBlackAlpha(10, 390, 400, 40);

            if (!Guild.NewGuildSystem)
            {
                AddLabel(20, 130, LabelHue, "This menu does not support old guild systems.");
                return;
            }

            AddPageButton(10, 10, GetButtonID(0, 0), "INFORMATION", Page.Information);
            AddPageButton(10, 30, GetButtonID(0, 1), "GUILD LIST", Page.Guilds, Page.GuildInfo);
            AddPageButton(10, 50, GetButtonID(0, 2), "ALLIANCES", Page.Alliances, Page.AllianceDetails);

            if (notice != null)
            {
                AddHtml(12, 392, 396, 36, Color(notice, LabelColor32), false, false);
            }

            switch (page)
            {
            case Page.Information:
            {
                AddGuildHeader();

                AddLabel(20, 130, LabelHue, "GuildAdmin Version:");
                AddLabel(150, 130, LabelHue, Version);

                AddLabel(20, 150, LabelHue, "Registration Fee:");
                AddLabel(150, 150, LabelHue, Guild.RegistrationFee.ToString("#,0") + " gp");

                AddLabel(20, 170, LabelHue, "Total Guilds:");
                AddLabel(150, 170, LabelHue, _list.Count.ToString());

                AddLabel(20, 190, LabelHue, " Active Alliances:");
                AddLabel(150, 190, LabelHue, _allianceTable.Count.ToString());

                AddLabel(20, 210, LabelHue, " Active Wars:");
                AddLabel(150, 210, LabelHue, _warTable.Count.ToString());

                break;
            }

            case Page.Guilds:
            {
                AddGuildHeader();

                if (_list == null)
                {
                    AddHtml(12, 140, 250, 60, Color("There was a problem building the list of guilds on the server. This page cannot be displayed.", LabelColor32), false, false);
                    break;
                }

                AddLabelCropped(12, 120, 81, 20, LabelHue, "Guild ID");
                AddLabelCropped(95, 120, 81, 20, LabelHue, "Abbreviaton");
                AddLabelCropped(178, 120, 172, 20, LabelHue, "Name");

                if (listPage > 0)
                {
                    AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(375, 122, 0x25EA);
                }

                if ((listPage + 1) * 12 < _list.Count)
                {
                    AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(392, 122, 0x25E6);
                }

                if (_list.Count == 0)
                {
                    AddLabel(12, 140, LabelHue, "There are no guilds to display.");
                }

                for (int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < _list.Count; i++, index++)
                {
                    Guild g = _list[index];

                    if (g == null)
                    {
                        continue;
                    }

                    int offset = (140 + (i * 20));

                    AddLabelCropped(12, offset, 81, 20, LabelHue, g.Id.ToString());
                    AddLabelCropped(95, offset, 81, 20, LabelHue, g.Abbreviation);
                    AddLabelCropped(178, offset, 172, 20, LabelHue, g.Name);

                    AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2), GumpButtonType.Reply, 0);
                }

                break;
            }

            case Page.GuildInfo:
            {
                Guild g = state as Guild;

                if (g == null)
                {
                    break;
                }

                AddGuildHeader();
                AddHtml(10, 125, 400, 20, Color(Center("Guild Information"), LabelColor32), false, false);

                int y = 146;

                AddLabel(20, y, LabelHue, "Name:");
                AddLabel(200, y, LabelHue, g.Name);
                y += 20;

                AddLabel(20, y, LabelHue, "Abbreviation:");
                AddLabel(200, y, LabelHue, g.Abbreviation);
                y += 20;

                AddLabel(20, y, LabelHue, "Guild Leader:");
                if (g.Leader.Account != null)
                {
                    AddLabelCropped(200, y, 150, 20, LabelHue, String.Format("{0} [{1}]", g.Leader.RawName,
                                                                             ((Server.Accounting.Account)g.Leader.Account).Username));
                }
                else
                {
                    AddLabelCropped(200, y, 150, 20, LabelHue, g.Leader.RawName);
                }
                y += 20;

                AddLabel(20, y, LabelHue, "Active Members:");
                AddLabel(200, y, LabelHue, g.Members.Count.ToString());
                y += 44;

                AddButtonLabeled(20, y, GetButtonID(7, 0), "Disband");
                AddButtonLabeled(200, y, GetButtonID(7, 1), "Active Alliance");
                y += 20;

                AddButtonLabeled(20, y, GetButtonID(7, 2), "Member List");
                AddButtonLabeled(200, y, GetButtonID(7, 3), "Active Wars");
                y += 20;

                AddButtonLabeled(20, y, GetButtonID(7, 4), "Add Member");
                AddButtonLabeled(200, y, GetButtonID(7, 5), "Guild Properties");

                break;
            }

            case Page.GuildMemberList:
            {
                Guild g = state as Guild;

                if (g == null)
                {
                    break;
                }

                AddGuildHeader();
                AddLabelCropped(12, 120, 120, 20, LabelHue, "Player Name");
                AddLabelCropped(132, 120, 120, 20, LabelHue, "Account Username");
                AddLabelCropped(252, 120, 120, 20, LabelHue, "Status");

                if (listPage > 0)
                {
                    AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(375, 122, 0x25EA);
                }

                if ((listPage + 1) * 12 < g.Members.Count)
                {
                    AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(392, 122, 0x25E6);
                }

                if (g.Members.Count == 0)
                {
                    AddLabel(12, 140, LabelHue, "This guild has no members.");
                }

                for (int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < g.Members.Count; i++, index++)
                {
                    Mobile m = g.Members[index];

                    if (m == null || m.Account == null)
                    {
                        continue;
                    }

                    int offset = (140 + (i * 20));

                    AddLabelCropped(12, offset, 120, 20, LabelHue, m.RawName);
                    AddLabelCropped(132, offset, 120, 20, LabelHue, ((Server.Accounting.Account)m.Account).Username);

                    if (m.NetState != null)
                    {
                        AddLabelCropped(252, offset, 120, 20, 0x40, "Online");
                    }
                    else
                    {
                        AddLabelCropped(252, offset, 120, 20, 0x20, "Offline");
                    }
                }

                break;
            }

            case Page.Alliances:
            {
                AddGuildHeader();

                if (_allianceTable == null)
                {
                    AddHtml(12, 140, 250, 60, Color("There was a problem building the table of alliances. This page cannot be displayed.", LabelColor32), false, false);
                    break;
                }

                AddLabelCropped(12, 120, 170, 20, LabelHue, "Name");
                AddLabelCropped(184, 120, 81, 20, LabelHue, "Member Count");
                AddLabelCropped(291, 120, 61, 20, LabelHue, "Leader");

                if (listPage > 0)
                {
                    AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(375, 122, 0x25EA);
                }

                if ((listPage + 1) * 12 < _allianceTable.Count)
                {
                    AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(392, 122, 0x25E6);
                }

                if (_allianceTable.Count == 0)
                {
                    AddLabel(12, 140, LabelHue, "There are no alliances to display.");
                }

                List <AllianceInfo> allianceList = new List <AllianceInfo>(_allianceTable.Keys);

                for (int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < allianceList.Count; i++, index++)
                {
                    AllianceInfo info = allianceList[index];

                    if (info == null)
                    {
                        continue;
                    }

                    List <Guild> tempList = null;
                    _allianceTable.TryGetValue(info, out tempList);

                    int offset = (140 + (i * 20));

                    AddLabelCropped(12, offset, 170, 20, LabelHue, info.Name);
                    AddLabelCropped(204, offset, 61, 20, LabelHue, (tempList == null ? "N/A" : tempList.Count.ToString()));
                    AddLabelCropped(291, offset, 61, 20, LabelHue, info.Leader.Abbreviation);

                    AddButton(380, (offset - 1), 0xFA5, 0xFA7, GetButtonID(5, index), GumpButtonType.Reply, 0);
                }

                break;
            }

            case Page.AllianceDetails:
            {
                AllianceInfo info = state as AllianceInfo;

                if (info == null || !_allianceTable.ContainsKey(info))
                {
                    break;
                }

                AddGuildHeader();
                AddHtml(10, 125, 400, 20, Color(Center("Alliance Details"), LabelColor32), false, false);

                int y = 146;

                AddLabel(20, y, LabelHue, "Name:");
                AddLabel(200, y, LabelHue, info.Name);
                y += 20;

                AddLabel(20, y, LabelHue, "Leader:");
                AddLabelCropped(200, y, 180, 20, LabelHue, String.Format("[{0}] {1}", info.Leader.Abbreviation, info.Leader.Name));
                y += 20;

                AddLabel(20, y, LabelHue, "Member Count:");
                AddLabel(200, y, LabelHue, _allianceTable[info].Count.ToString());
                y += 20;

                AddLabel(20, y, LabelHue, "Status:");
                AddLabel(200, y, LabelHue, (_allianceTable[info].Count < 2 ? "Pending Acceptance" : "Active"));
                y += 20;

                y = 270;

                AddButtonLabeled(20, y, GetButtonID(8, 0), "Disband");
                AddButtonLabeled(200, y, GetButtonID(8, 1), "Member List");

                break;
            }

            case Page.Wars:
            {
                Guild g = state as Guild;

                if (g == null)
                {
                    break;
                }

                AddGuildHeader();

                AddLabelCropped(12, 120, 120, 20, LabelHue, "Guild Name");
                AddLabelCropped(134, 120, 120, 20, LabelHue, "Opponent Guild");
                AddLabelCropped(246, 120, 90, 20, LabelHue, "Date Started");

                if (listPage > 0)
                {
                    AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(375, 122, 0x25EA);
                }

                if ((listPage + 1) * 12 < g.AcceptedWars.Count)
                {
                    AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddImage(392, 122, 0x25E6);
                }

                if (g.AcceptedWars.Count == 0)
                {
                    AddLabel(12, 140, LabelHue, "This guild has not accepted any war declarations.");
                }

                for (int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < g.AcceptedWars.Count; i++, index++)
                {
                    WarDeclaration warDecl = g.AcceptedWars[index];

                    if (warDecl == null)
                    {
                        continue;
                    }

                    int offset = (140 + (i * 20));

                    AddLabelCropped(12, offset, 120, 20, LabelHue, g.Name);
                    AddLabelCropped(134, offset, 120, 20, LabelHue, warDecl.Opponent.Name);
                    AddLabelCropped(246, offset, 120, 20, LabelHue, warDecl.WarBeginning.ToShortDateString());

                    AddButton(380, (offset - 1), 0xFA5, 0xFA7, GetButtonID(6, index), GumpButtonType.Reply, 0);
                }

                break;
            }

            case Page.WarDetails:
            {
                WarDeclaration warDecl = state as WarDeclaration;

                if (warDecl == null)
                {
                    break;
                }

                AddGuildHeader();
                AddHtml(10, 125, 400, 20, Color(Center(String.Format("War Details for {0}", warDecl.Guild.Abbreviation)), LabelColor32), false, false);

                int y = 146;

                AddLabel(20, y, LabelHue, "Current Status:");
                AddLabel(200, y, LabelHue, GetStatus(warDecl.Status));
                y += 20;

                AddLabel(20, y, LabelHue, "Initiated at:");
                AddLabel(200, y, LabelHue, warDecl.WarBeginning.ToShortTimeString() + " on " + warDecl.WarBeginning.ToShortDateString());
                y += 40;

                AddHtml(10, y, 400, 20, Color(Center("Conditions of War:"), LabelColor32), false, false);
                y += 30;

                AddLabel(20, y, LabelHue, "Kills [Current/Max]:");
                AddLabel(200, y, LabelHue, String.Format("{0}/{1}", warDecl.Kills.ToString(), warDecl.MaxKills.ToString()));
                y += 20;

                AddLabel(20, y, LabelHue, "Time [Remaining/Length]:");
                AddLabel(200, y, LabelHue, String.Format("{0}/{1}", GetRemainingTime(warDecl), String.Format("{0:D2}:{1:mm}", warDecl.WarLength.Hours, DateTime.MinValue + warDecl.WarLength)));

                y = 290;

                AddButtonLabeled(20, y, GetButtonID(9, 0), "Guild Details");
                AddButtonLabeled(200, y, GetButtonID(9, 1), "Opponent Details");

                break;
            }
            }
        }
Beispiel #8
0
        public void CheckExpiredWars()
        {
            for (int i = 0; i < AcceptedWars.Count; i++)
            {
                WarDeclaration w = AcceptedWars[i];
                Guild          g = w.Opponent;

                WarStatus status = w.Status;

                if (status != WarStatus.InProgress)
                {
                    AllianceInfo myAlliance = Alliance;
                    bool         inAlliance = myAlliance?.IsMember(this) == true;

                    AllianceInfo otherAlliance   = g?.Alliance;
                    bool         otherInAlliance = otherAlliance?.IsMember(this) == true;

                    if (inAlliance)
                    {
                        myAlliance.AllianceMessage(1070739 + (int)status,
                                                   g == null ? "a deleted opponent" : otherInAlliance ? otherAlliance.Name : g.Name);
                        myAlliance.InvalidateMemberProperties();
                    }
                    else
                    {
                        GuildMessage(1070739 + (int)status,
                                     g == null ? "a deleted opponent" : otherInAlliance?otherAlliance.Name: g.Name);
                        InvalidateMemberProperties();
                    }

                    AcceptedWars.Remove(w);

                    if (g == null)
                    {
                        continue;
                    }

                    if (status != WarStatus.Draw)
                    {
                        status = (WarStatus)((int)status + 1 % 2);
                    }

                    if (otherInAlliance)
                    {
                        otherAlliance.AllianceMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
                        otherAlliance.InvalidateMemberProperties();
                    }
                    else
                    {
                        g.GuildMessage(1070739 + (int)status, inAlliance ? Alliance.Name : Name);
                        g.InvalidateMemberProperties();
                    }

                    g.AcceptedWars.Remove(g.FindActiveWar(this));
                }
            }

            for (int i = 0; i < PendingWars.Count; i++)
            {
                WarDeclaration w = PendingWars[i];
                Guild          g = w.Opponent;

                if (w.Status != WarStatus.Pending)
                {
                    // All sanity in here
                    PendingWars.Remove(w);

                    g?.PendingWars.Remove(g.FindPendingWar(this));
                }
            }
        }
Beispiel #9
0
        public override void Deserialize(IGenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 5:
            {
                int count = reader.ReadInt();

                PendingWars = new List <WarDeclaration>();
                for (int i = 0; i < count; i++)
                {
                    PendingWars.Add(new WarDeclaration(reader));
                }

                count        = reader.ReadInt();
                AcceptedWars = new List <WarDeclaration>();
                for (int i = 0; i < count; i++)
                {
                    AcceptedWars.Add(new WarDeclaration(reader));
                }

                bool isAllianceLeader = reader.ReadBool();

                if (isAllianceLeader)
                {
                    m_AllianceInfo = new AllianceInfo(reader);
                }
                else
                {
                    m_AllianceLeader = reader.ReadGuild() as Guild;
                }

                goto case 4;
            }

            case 4:
            {
                AllyDeclarations = reader.ReadStrongGuildList <Guild>();
                AllyInvitations  = reader.ReadStrongGuildList <Guild>();

                goto case 3;
            }

            case 3:
            {
                TypeLastChange = reader.ReadDateTime();

                goto case 2;
            }

            case 2:
            {
                m_Type = (GuildType)reader.ReadInt();

                goto case 1;
            }

            case 1:
            {
                LastFealty = reader.ReadDateTime();

                goto case 0;
            }

            case 0:
            {
                m_Leader = reader.ReadMobile();

                if (m_Leader is PlayerMobile mobile)
                {
                    mobile.GuildRank = RankDefinition.Leader;
                }

                m_Name         = reader.ReadString();
                m_Abbreviation = reader.ReadString();

                Allies          = reader.ReadStrongGuildList <Guild>();
                Enemies         = reader.ReadStrongGuildList <Guild>();
                WarDeclarations = reader.ReadStrongGuildList <Guild>();
                WarInvitations  = reader.ReadStrongGuildList <Guild>();

                Members    = reader.ReadStrongMobileList();
                Candidates = reader.ReadStrongMobileList();
                Accepted   = reader.ReadStrongMobileList();

                Guildstone = reader.ReadItem();
                Teleporter = reader.ReadItem();

                Charter = reader.ReadString();
                Website = reader.ReadString();

                break;
            }
            }

            AllyDeclarations ??= new List <Guild>();
            AllyInvitations ??= new List <Guild>();
            AcceptedWars ??= new List <WarDeclaration>();
            PendingWars ??= new List <WarDeclaration>();

            Timer.DelayCall(TimeSpan.Zero, VerifyGuild_Callback);
        }
        public void CreateAlliance_Callback(Mobile from, string text)
        {
            PlayerMobile pm = from as PlayerMobile;


            AllianceInfo alliance      = guild.Alliance;
            AllianceInfo otherAlliance = m_Other.Alliance;

            if (!IsMember(from, guild) || alliance != null)
            {
                return;
            }


            RankDefinition playerRank = pm.GuildRank;


            if (!playerRank.GetFlag(RankFlags.AllianceControl))
            {
                pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
            }
            else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
            {
                //Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
                pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
            }
            else if (otherAlliance != null)
            {
                if (otherAlliance.IsPendingMember(m_Other))
                {
                    pm.SendLocalizedMessage(1063416, m_Other.Name); // ~1_val~ is currently considering another alliance proposal.
                }
                else
                {
                    pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance.
                }
            }
            else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
            {
                pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war.
            }
            else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
            {
                pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war.
            }
            else
            {
                string name = Utility.FixHtml(text.Trim());

                if (!BaseGuildGump.CheckProfanity(name))
                {
                    pm.SendLocalizedMessage(1070886); // That alliance name is not allowed.
                }
                else if (name.Length > Guild.NameLimit)
                {
                    pm.SendLocalizedMessage(1070887, Guild.NameLimit.ToString()); // An alliance name cannot exceed ~1_val~ characters in length.
                }
                else if (AllianceInfo.Alliances.ContainsKey(name.ToLower()))
                {
                    pm.SendLocalizedMessage(1063428); // That alliance name is not available.
                }
                else
                {
                    pm.SendLocalizedMessage(1070750, m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.

                    m_Other.GuildMessage(1070780, guild.Name);      // ~1_val~ has proposed an alliance.

                    new AllianceInfo(guild, name, m_Other);
                }
            }
        }
        public override void PopulateGump()
        {
            Guild g     = Guild.GetAllianceLeader(guild);
            Guild other = Guild.GetAllianceLeader(m_Other);

            WarDeclaration war       = g.FindPendingWar(other);
            WarDeclaration activeWar = g.FindActiveWar(other);

            AllianceInfo alliance      = guild.Alliance;
            AllianceInfo otherAlliance = m_Other.Alliance;
            //NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses

            bool PendingWar = (war != null);
            bool ActiveWar  = (activeWar != null);

            AddPage(0);

            AddBackground(0, 0, 520, 335, 0x242C);
            AddHtmlLocalized(20, 15, 480, 26, 1062975, 0x0, false, false); // <div align=center><i>Guild Relationship</i></div>
            AddImageTiled(20, 40, 480, 2, 0x2711);
            AddHtmlLocalized(20, 50, 120, 26, 1062954, 0x0, true, false);  // <i>Guild Name</i>
            AddHtml(150, 53, 360, 26, m_Other.Name, false, false);

            AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true, false); // <i>Alliance</i>

            if (otherAlliance != null)
            {
                if (otherAlliance.IsMember(m_Other))
                {
                    AddHtml(150, 83, 360, 26, otherAlliance.Name, false, false);
                }
                //else if( otherAlliance.Leader == guild && ( otherAlliance.IsPendingMember( m_Other ) || otherAlliance.IsPendingMember( guild ) ) )

                /*		else if( (otherAlliance.Leader == guild && otherAlliance.IsPendingMember( m_Other ) ) || ( otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) ) )
                 *      {
                 *          AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0xF), false, false );
                 *      }
                 *      //AddHtml( 150, 83, 360, 26, ( alliance.PendingMembers.Contains( guild ) || alliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", alliance.Name ) : alliance.Name, false, false );
                 *      //AddHtml( 150, 83, 360, 26, ( otherAlliance == alliance &&  otherAlliance.PendingMembers.Contains( guild ) || otherAlliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", otherAlliance.Name ) : otherAlliance.Name, false, false );
                 */
            }

            AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true, false); // <i>Abbreviation</i>
            AddHtml(150, 113, 120, 26, m_Other.Abbreviation, false, false);


            string kills      = "0/0";
            string time       = "00:00";
            string otherKills = "0/0";

            WarDeclaration otherWar;

            if (ActiveWar)
            {
                kills = String.Format("{0}/{1}", activeWar.Kills, activeWar.MaxKills);

                TimeSpan timeRemaining = TimeSpan.Zero;

                if (activeWar.WarLength != TimeSpan.Zero && (activeWar.WarBeginning + activeWar.WarLength) > DateTime.UtcNow)
                {
                    timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.UtcNow;
                }

                //time = String.Format( "{0:D2}:{1:D2}", timeRemaining.Hours.ToString(), timeRemaining.Subtract( TimeSpan.FromHours( timeRemaining.Hours ) ).Minutes );	//Is there a formatter for htis? it's 2AM and I'm tired and can't find it
                time = String.Format("{0:D2}:{1:mm}", timeRemaining.Hours, DateTime.MinValue + timeRemaining);

                otherWar = m_Other.FindActiveWar(guild);
                if (otherWar != null)
                {
                    otherKills = String.Format("{0}/{1}", otherWar.Kills, otherWar.MaxKills);
                }
            }
            else if (PendingWar)
            {
                kills = Color(String.Format("{0}/{1}", war.Kills, war.MaxKills), 0x990000);
                //time = Color( String.Format( "{0}:{1}", war.WarLength.Hours, ((TimeSpan)(war.WarLength - TimeSpan.FromHours( war.WarLength.Hours ))).Minutes ), 0xFF0000 );
                time = Color(String.Format("{0:D2}:{1:mm}", war.WarLength.Hours, DateTime.MinValue + war.WarLength), 0x990000);

                otherWar = m_Other.FindPendingWar(guild);
                if (otherWar != null)
                {
                    otherKills = Color(String.Format("{0}/{1}", otherWar.Kills, otherWar.MaxKills), 0x990000);
                }
            }

            AddHtmlLocalized(280, 110, 120, 26, 1062966, 0x0, true, false); // <i>Your Kills</i>
            AddHtml(410, 113, 120, 26, kills, false, false);

            AddHtmlLocalized(20, 140, 120, 26, 1062968, 0x0, true, false); // <i>Time Remaining</i>
            AddHtml(150, 143, 120, 26, time, false, false);

            AddHtmlLocalized(280, 140, 120, 26, 1062967, 0x0, true, false); // <i>Their Kills</i>
            AddHtml(410, 143, 120, 26, otherKills, false, false);

            AddImageTiled(20, 172, 480, 2, 0x2711);

            int number = 1062973;// <div align=center>You are at peace with this guild.</div>


            if (PendingWar)
            {
                if (war.WarRequester)
                {
                    number = 1063027; // <div align=center>You have challenged this guild to war!</div>
                }
                else
                {
                    number = 1062969;                             // <div align=center>This guild has challenged you to war!</div>

                    AddButtonAndBackground(20, 260, 5, 1062981);  // Accept Challenge
                    AddButtonAndBackground(275, 260, 6, 1062983); //Modify Terms
                }

                AddButtonAndBackground(20, 290, 7, 1062982); // Dismiss Challenge
            }
            else if (ActiveWar)
            {
                number = 1062965;                                           // <div align=center>You are at war with this guild!</div>
                AddButtonAndBackground(20, 290, 8, 1062980);                // Surrender
            }
            else if (alliance != null && alliance == otherAlliance)         //alliance, Same Alliance
            {
                if (alliance.IsMember(guild) && alliance.IsMember(m_Other)) //Both in Same alliance, full members
                {
                    number = 1062970;                                       // <div align=center>You are allied with this guild.</div>

                    if (alliance.Leader == guild)
                    {
                        AddButtonAndBackground(20, 260, 12, 1062984);  // Remove Guild from Alliance
                        AddButtonAndBackground(275, 260, 13, 1063433); // Promote to Alliance Leader	//Note: No 'confirmation' like the other leader guild promotion things
                                                                       //Remove guild from alliance	//Promote to Alliance Leader
                    }

                    //Show roster, Centered, up
                    AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster
                                                                   //Leave Alliance
                    AddButtonAndBackground(20, 290, 11, 1062985);  // Leave Alliance
                }
                else if (alliance.Leader == guild && alliance.IsPendingMember(m_Other))
                {
                    number = 1062971; // <div align=center>You have requested an alliance with this guild.</div>

                    //Show Alliance Roster, Centered, down.
                    AddButtonAndBackground(148, 245, 10, 1063164); //Show Alliance Roster
                                                                   //Withdraw Request
                    AddButtonAndBackground(20, 290, 14, 1062986);  // Withdraw Request

                    AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false);
                }
                else if (alliance.Leader == m_Other && alliance.IsPendingMember(guild))
                {
                    number = 1062972; // <div align=center>This guild has requested an alliance.</div>

                    //Show alliance Roster, top
                    AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster
                                                                   //Deny Request
                                                                   //Accept Request
                    AddButtonAndBackground(20, 260, 15, 1062988);  // Deny Request
                    AddButtonAndBackground(20, 290, 16, 1062987);  // Accept Request

                    AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99), false, false);
                }
            }
            else
            {
                AddButtonAndBackground(20, 260, 2, 1062990); // Request Alliance
                AddButtonAndBackground(20, 290, 1, 1062989); // Declare War!
            }

            AddButtonAndBackground(275, 290, 0, 3000091); //Cancel

            AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true, false);
            AddImageTiled(20, 245, 480, 2, 0x2711);
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (!IsMember(pm, guild))
            {
                return;
            }

            RankDefinition playerRank = pm.GuildRank;

            Guild guildLeader = Guild.GetAllianceLeader(guild);
            Guild otherGuild  = Guild.GetAllianceLeader(m_Other);

            WarDeclaration war       = guildLeader.FindPendingWar(otherGuild);
            WarDeclaration activeWar = guildLeader.FindActiveWar(otherGuild);
            WarDeclaration otherWar  = otherGuild.FindPendingWar(guildLeader);

            AllianceInfo alliance      = guild.Alliance;
            AllianceInfo otherAlliance = otherGuild.Alliance;

            switch (info.ButtonID)
            {
                #region War
            case 5:     //Accept the war
            {
                if (war != null && !war.WarRequester && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        //Accept the war
                        guild.PendingWars.Remove(war);
                        war.WarBeginning = DateTime.UtcNow;
                        guild.AcceptedWars.Add(war);

                        if (alliance != null && alliance.IsMember(guild))
                        {
                            alliance.AllianceMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            alliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            guild.GuildMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            guild.InvalidateMemberProperties();
                        }
                        //Technically  SHOULD say Your guild is now at war w/out any info, intentional diff.

                        otherGuild.PendingWars.Remove(otherWar);
                        otherWar.WarBeginning = DateTime.UtcNow;
                        otherGuild.AcceptedWars.Add(otherWar);

                        if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other))
                        {
                            otherAlliance.AllianceMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            otherAlliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            otherGuild.GuildMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            otherGuild.InvalidateMemberProperties();
                        }
                    }
                }

                break;
            }

            case 6:     //Modify war terms
            {
                if (war != null && !war.WarRequester && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild));
                    }
                }
                break;
            }

            case 7:     //Dismiss war
            {
                if (war != null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        //Dismiss the war
                        guild.PendingWars.Remove(war);
                        otherGuild.PendingWars.Remove(otherWar);
                        pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                                  //Messages to opposing guild? (Testing on OSI says no)
                    }
                }
                break;
            }

            case 8:     //Surrender
            {
                if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                {
                    pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                }
                else
                {
                    if (activeWar != null)
                    {
                        if (alliance != null && alliance.IsMember(guild))
                        {
                            alliance.AllianceMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));        // You have lost the war with ~1_val~.
                            alliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            guild.GuildMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));        // You have lost the war with ~1_val~.
                            guild.InvalidateMemberProperties();
                        }

                        guild.AcceptedWars.Remove(activeWar);

                        if (otherAlliance != null && otherAlliance.IsMember(otherGuild))
                        {
                            otherAlliance.AllianceMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));        // You have won the war against ~1_val~!
                            otherAlliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            otherGuild.GuildMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));        // You have won the war against ~1_val~!
                            otherGuild.InvalidateMemberProperties();
                        }

                        otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(guild));
                    }
                }
                break;
            }

            case 1:     //Declare War
            {
                if (war == null && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else if (otherAlliance != null && otherAlliance.Leader != m_Other)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", m_Other.Name, otherAlliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);                                   // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        pm.SendGump(new WarDeclarationGump(pm, guild, m_Other));
                    }
                }
                break;
            }

                #endregion
            case 2:     //Request Alliance
            {
                #region New alliance
                if (alliance == null)
                {
                    if (!playerRank.GetFlag(RankFlags.AllianceControl))
                    {
                        pm.SendLocalizedMessage(1070747);         // You don't have permission to create an alliance.
                    }
                    else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
                    {
                        pm.SendLocalizedMessage(1070758);         // You cannot propose an alliance to a guild with a different faction allegiance.
                    }
                    else if (otherAlliance != null)
                    {
                        if (otherAlliance.IsPendingMember(m_Other))
                        {
                            pm.SendLocalizedMessage(1063416, m_Other.Name);         // ~1_val~ is currently considering another alliance proposal.
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1063426, m_Other.Name);         // ~1_val~ already belongs to an alliance.
                        }
                    }
                    else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, m_Other.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, guild.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1063439);         // Enter a name for the new alliance:
                        pm.BeginPrompt(new PromptCallback(CreateAlliance_Callback));
                    }
                }
                #endregion
                #region Existing Alliance
                else
                {
                    if (!playerRank.GetFlag(RankFlags.AllianceControl))
                    {
                        pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                    }
                    else if (alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                    }
                    else if (otherAlliance != null)
                    {
                        if (otherAlliance.IsPendingMember(m_Other))
                        {
                            pm.SendLocalizedMessage(1063416, m_Other.Name);         // ~1_val~ is currently considering another alliance proposal.
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1063426, m_Other.Name);         // ~1_val~ already belongs to an alliance.
                        }
                    }
                    else if (alliance.IsPendingMember(guild))
                    {
                        pm.SendLocalizedMessage(1063416, guild.Name);         // ~1_val~ is currently considering another alliance proposal.
                    }
                    else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, m_Other.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, guild.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
                    {
                        pm.SendLocalizedMessage(1070758);         // You cannot propose an alliance to a guild with a different faction allegiance.
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1070750, m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.

                        m_Other.GuildMessage(1070780, guild.Name);      // ~1_val~ has proposed an alliance.

                        m_Other.Alliance = alliance;                    //Calls addPendingGuild
                                                                        //alliance.AddPendingGuild( m_Other );
                    }
                }
                #endregion
                break;
            }

            case 10:        //Show Alliance Roster
            {
                if (alliance != null && alliance == otherAlliance)
                {
                    pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance));
                }

                break;
            }

            case 11:        //Leave Alliance
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.IsMember(guild))
                {
                    guild.Alliance = null;          //Calls alliance.Removeguild
                                                    //						alliance.RemoveGuild( guild );

                    m_Other.InvalidateWarNotoriety();

                    guild.InvalidateMemberNotoriety();
                }
                break;
            }

            case 12:        //Remove Guild from alliance
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                }
                else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other))
                {
                    m_Other.Alliance = null;

                    m_Other.InvalidateMemberNotoriety();

                    guild.InvalidateWarNotoriety();
                }
                break;
            }

            case 13:        //Promote to Alliance leader
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                }
                else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other))
                {
                    pm.SendLocalizedMessage(1063434, String.Format("{0}\t{1}", m_Other.Name, alliance.Name));         // ~1_val~ is now the leader of ~2_val~.

                    alliance.Leader = m_Other;
                }
                break;
            }

            case 14:        //Withdraw Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other))
                {
                    m_Other.Alliance = null;
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                }
                break;
            }

            case 15:     //Deny Alliance Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other && otherAlliance.IsPendingMember(guild))
                {
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                              //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.	//Per OSI commented out.

                    guild.Alliance = null;
                }
                break;
            }

            case 16:     //Accept Alliance Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (otherAlliance != null && otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember(guild))
                {
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.

                    otherAlliance.TurnToMember(m_Other);      //No need to verify it's in the guild or already a member, the function does this

                    otherAlliance.TurnToMember(guild);
                }
                break;
            }
            }
        }
Beispiel #13
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int val = (info.ButtonID - 1);

            if (val < 0)
            {
                return;
            }

            int type  = (val % 10);
            int index = (val / 10);

            switch (type)
            {
            case 0:
            {
                Page page;

                switch (index)
                {
                case 0: page = Page.Information; break;

                case 1: page = Page.Guilds; break;

                case 2: page = Page.Alliances; break;

                default: return;
                }

                m_From.SendGump(new GuildAdminGump(m_From, page, 0, null, null, null));
            } break;

            case 1:     //change page
            {
                switch (index)
                {
                case 0:
                {
                    if (m_List != null && m_ListPage > 0)
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, m_PageType, (m_ListPage - 1), null, null, m_State));
                    }
                } break;

                case 1:
                {
                    if (m_List != null)
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, m_PageType, (m_ListPage + 1), null, null, m_State));
                    }
                } break;
                }
            } break;

            case 4:     //search or show guild details
            {
                switch (index)
                {
                case 0:
                case 1:
                {
                    bool nameSearch = (index == 0);

                    List <Guild> foundList = new List <Guild>();

                    TextRelay relay  = info.GetTextEntry(0);
                    string    toFind = (relay == null ? null : relay.Text.Trim().ToLower());
                    string    notice = null;

                    if (toFind == null || toFind.Length == 0)
                    {
                        notice = String.Format("You must enter {0} to search for.", nameSearch ? "a guild name" : "a guild abbreviation");
                    }
                    else
                    {
                        foreach (KeyValuePair <int, BaseGuild> kvp in Guild.List)
                        {
                            bool isMatch = false;

                            if (nameSearch)
                            {
                                if (kvp.Value.Name.ToLower().IndexOf(toFind) >= 0)
                                {
                                    isMatch = true;
                                }
                            }
                            else
                            {
                                if (kvp.Value.Abbreviation.ToLower().IndexOf(toFind) >= 0)
                                {
                                    isMatch = true;
                                }
                            }

                            if (isMatch && kvp.Value is Guild)
                            {
                                foundList.Add((Guild)kvp.Value);
                            }
                        }

                        foundList.Sort(GuildComparer.Instance);
                    }

                    if (foundList.Count == 1)
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, "One match found.", null, foundList[0]));
                    }
                    else
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.Guilds, 0, (notice == null ? (foundList.Count == 0 ? "Nothing matched your search terms." : null) : notice), foundList, null));
                    }

                    break;
                }

                default:
                {
                    index -= 2;

                    if (m_List != null && index >= 0 && index < m_List.Count)
                    {
                        Guild g = m_List[index];

                        if (g == null)
                        {
                            break;
                        }

                        m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, null, null, g));
                    }

                    break;
                }
                }
            } break;

            case 5:     //show alliance details
            {
                List <AllianceInfo> allianceList = new List <AllianceInfo>(m_AllianceTable.Keys);

                if (allianceList != null && index >= 0 && index < allianceList.Count)
                {
                    AllianceInfo aInfo = allianceList[index];

                    if (aInfo == null)
                    {
                        break;
                    }

                    m_From.SendGump(new GuildAdminGump(m_From, Page.AllianceDetails, 0, null, null, aInfo));
                }
            } break;

            case 6:     //show war details
            {
                if (m_State is Guild)
                {
                    m_From.SendGump(new GuildAdminGump(m_From, Page.WarDetails, 0, null, null, ((Guild)m_State).AcceptedWars[index]));
                }
            } break;

            case 7:     //show guild details
            {
                switch (index)
                {
                case 0:             //disband
                {
                    string warning = String.Format("You are about to disband the guild \"{0}.\" Are you sure you want to do this?", ((Guild)m_State).Name);
                    m_From.SendGump(new WarningGump(1060635, 30720, warning, 0xFFC000, 420, 200, new WarningGumpCallback(DisbandGuild_Callback), m_State));

                    break;
                }

                case 1:             //alliance details
                {
                    if (((Guild)m_State).Alliance == null)
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, "This guild is not a member of an alliance.", null, m_State));
                    }
                    else
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.AllianceDetails, 0, null, null, ((Guild)m_State).Alliance));
                    }

                    break;
                }

                case 2:             //member list
                {
                    m_From.SendGump(new GuildAdminGump(m_From, Page.GuildMemberList, 0, null, null, (Guild)m_State));

                    break;
                }

                case 3:             //war list
                {
                    if (((Guild)m_State).AcceptedWars == null || ((Guild)m_State).AcceptedWars.Count == 0)
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, "This guild is not involved in any wars.", null, m_State));
                    }
                    else
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.Wars, 0, null, null, m_State));
                    }

                    break;
                }

                case 4:             //add member
                {
                    m_From.Target = new InternalRecruitTarget((Guild)m_State);
                    m_From.SendMessage("Select the player to recruit into \"{0}.\"", ((Guild)m_State).Name);

                    m_From.SendGump(new GuildAdminGump(m_From, m_PageType, 0, null, null, m_State));

                    break;
                }

                case 5:             //guild properties [same as the GuildProps command]
                {
                    m_From.SendGump(new PropertiesGump(m_From, (Guild)m_State));
                    m_From.SendGump(new GuildInfoGump((Server.Mobiles.PlayerMobile)m_From, (Guild)m_State));

                    m_From.SendGump(new GuildAdminGump(m_From, m_PageType, 0, null, null, m_State));

                    break;
                }
                }
            } break;

            case 8:     //alliance details
            {
                switch (index)
                {
                case 0:             //disband
                {
                    string warning = String.Format("You are about to disband the alliance \"{0}.\" Are you sure you want to do this?", ((AllianceInfo)m_State).Name);
                    m_From.SendGump(new WarningGump(1060635, 30720, warning, 0xFFC000, 420, 200, new WarningGumpCallback(DisbandAlliance_Callback), m_State));

                    break;
                }

                case 1:             //member list
                {
                    AllianceInfo aInfo = m_State as AllianceInfo;

                    if (m_AllianceTable.ContainsKey(aInfo))
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, Page.Guilds, 0, null, m_AllianceTable[aInfo], null));
                    }
                    else
                    {
                        m_From.SendGump(new GuildAdminGump(m_From, m_PageType, 0, "The list of members for this alliance could not be found.", null, m_State));
                    }

                    break;
                }
                }
            } break;

            case 9:     //war details
            {
                switch (index)
                {
                case 0: m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, null, null, ((WarDeclaration)m_State).Guild)); break;

                case 1: m_From.SendGump(new GuildAdminGump(m_From, Page.GuildInfo, 0, null, null, ((WarDeclaration)m_State).Opponent)); break;
                }
            } break;
            }
        }
 public void Serialize(IDataWriter writer)
 {
     AllianceInfo.Serialize(writer);
     writer.WriteBoolean(Enabled);
     writer.WriteVarInt((Int32)LeadingGuildId);
 }