TurnToMember() публичный Метод

public TurnToMember ( Guild g ) : void
g Guild
Результат void
Пример #1
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;
            }
            }
        }