GuildMessage() public méthode

public GuildMessage ( int number ) : void
number int
Résultat void
        public override void OnResponse(NetState state, RelayInfo info)
        {
            int cat = info.ButtonID;

            switch (cat)
            {
            case 0:
                return;

            case 1:
            {
                GuildGump.EnsureClosed(m_Mobile);
                m_Mobile.SendGump(new ViewGuildRosterGump(m_Mobile, m_ThierGuild));
                return;
            }

            case 2:
            {
                if (m_Guild == null)
                {
                    m_Mobile.SendMessage("You are not in a guild");
                }
                else if (m_ThierGuild == null)
                {
                    m_Mobile.SendMessage("You have selected an invalid guild");
                }
                else if (m_Guild == m_ThierGuild)
                {
                    m_Mobile.SendMessage("You cannot declare war with your own guild");
                }
                else if (m_Guild.Leader != m_Mobile)
                {
                    m_Mobile.SendMessage("You are not the leader of this guild");
                }
                else if ((m_Guild.WarInvitations.Contains(m_ThierGuild) && m_ThierGuild.WarDeclarations.Contains(m_Guild)) || m_Guild.IsWar(m_ThierGuild))
                {
                    m_Mobile.SendMessage("You are already at war with that guild.");
                }
                else
                {
                    if (!m_Guild.WarDeclarations.Contains(m_ThierGuild))
                    {
                        m_Guild.WarDeclarations.Add(m_ThierGuild);
                        m_Guild.GuildMessage(1018019, true, "{0} ({1})", m_ThierGuild.Name, m_ThierGuild.Abbreviation);                                   // Guild Message: Your guild has sent an invitation for war:
                    }

                    if (!m_ThierGuild.WarInvitations.Contains(m_Guild))
                    {
                        m_ThierGuild.WarInvitations.Add(m_Guild);
                        m_ThierGuild.GuildMessage(1018021, true, "{0} ({1})", m_Guild.Name, m_Guild.Abbreviation);                                   // Guild Message: Your guild has received an invitation to war:
                    }
                }
                break;
            }
            }
            m_Mobile.SendGump(new GuildWarInfoGump(m_Mobile, m_Guild));
        }
Exemple #2
0
        public void TurnToMember(Guild g)
        {
            if (g.Alliance != this || !m_PendingMembers.Contains(g) || m_Members.Contains(g))
            {
                return;
            }

            g.GuildMessage(1070760, Name);    // Your Guild has joined the ~1_ALLIANCENAME~ Alliance.
            AllianceMessage(1070761, g.Name); // A new Guild has joined your Alliance: ~1_GUILDNAME~

            m_PendingMembers.Remove(g);
            m_Members.Add(g);
            g.Alliance.InvalidateMemberProperties();
        }
Exemple #3
0
        public void RemoveGuild(Guild g)
        {
            if (m_PendingMembers.Contains(g))
            {
                m_PendingMembers.Remove(g);
            }

            if (Members.Contains(g)) //Sanity, just incase someone with a custom script adds a character to BOTH arrays
            {
                Members.Remove(g);
                g.InvalidateMemberProperties();

                g.GuildMessage(1070763, Name);    // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance.
                AllianceMessage(1070764, g.Name); // A Guild has left your Alliance: ~1_GUILDNAME~
            }

            //g.Alliance = null;	//NO G.Alliance call here.  Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance.  setting g.Alliance will call this method.
            //to check on OSI: have 3 guilds, make 2 of them a member, one pending.  remove one of the memebers.  alliance still exist?
            //ANSWER: NO

            if (g == m_Leader)
            {
                CalculateAllianceLeader();

                /*
                 * if( m_Leader == null ) //only when m_members.count < 2
                 * Disband();
                 * else
                 * AllianceMessage( 1070765, m_Leader.Name ); // Your Alliance is now led by ~1_GUILDNAME~
                 */
            }

            if (Members.Count < 2)
            {
                Disband();
            }
        }
Exemple #4
0
        public void TurnToMember( Guild g )
        {
            if( g.Alliance != this || !m_PendingMembers.Contains( g ) || m_Members.Contains( g ) )
                return;

            g.GuildMessage( 1070760, this.Name ); // Your Guild has joined the ~1_ALLIANCENAME~ Alliance.
            AllianceMessage( 1070761, g.Name ); // A new Guild has joined your Alliance: ~1_GUILDNAME~

            m_PendingMembers.Remove( g );
            m_Members.Add( g );
            g.Alliance.InvalidateMemberProperties();
        }
Exemple #5
0
        public void RemoveGuild( Guild g )
        {
            if( m_PendingMembers.Contains( g ) )
            {
                m_PendingMembers.Remove( g );
            }

            if( m_Members.Contains( g ) )	//Sanity, just incase someone with a custom script adds a character to BOTH arrays
            {
                m_Members.Remove( g );
                g.InvalidateMemberProperties();

                g.GuildMessage( 1070763, this.Name ); // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance.
                AllianceMessage( 1070764, g.Name ); // A Guild has left your Alliance: ~1_GUILDNAME~
            }

            //g.Alliance = null;	//NO G.Alliance call here.  Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance.  setting g.Alliance will call this method.
            //to check on OSI: have 3 guilds, make 2 of them a member, one pending.  remove one of the memebers.  alliance still exist?
            //ANSWER: NO

            if( g == m_Leader )
            {
                CalculateAllianceLeader();

                /*
                if( m_Leader == null ) //only when m_members.count < 2
                    Disband();
                else
                    AllianceMessage( 1070765, m_Leader.Name ); // Your Alliance is now led by ~1_GUILDNAME~
                */
            }

            if( m_Members.Count < 2 )
                Disband();
        }
Exemple #6
0
        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;
            }
            }
        }
Exemple #7
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var pm = sender.Mobile as PlayerMobile;

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

            var playerRank = pm !.GuildRank;

            switch (info.ButtonID)
            {
            case 1:
            {
                var alliance      = guild.Alliance;
                var 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,
                        $"{guild.Name}\t{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,
                        $"{m_Other.Name}\t{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
                {
                    var activeWar = guild.FindActiveWar(m_Other);

                    if (activeWar == null)
                    {
                        var war      = guild.FindPendingWar(m_Other);
                        var 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.)
                        var tKills     = info.GetTextEntry(11);
                        var tWarLength = info.GetTextEntry(10);

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

                        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.
                        }
                        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;
            }
            }
        }
Exemple #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 != null && myAlliance.IsMember(this));

					AllianceInfo otherAlliance = ((g != null) ? g.Alliance : null);
					bool otherInAlliance = (otherAlliance != null && otherAlliance.IsMember(this));

					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)
					{
						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);

					if (g != null)
					{
						g.PendingWars.Remove(g.FindPendingWar(this));
					}
				}
			}
		}
Exemple #9
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;
            }
            }
        }