Ejemplo n.º 1
0
        public void RecruitMember(PlayerMobile player, PlayerMobile targetPlayer)
        {
            if (!IsMember(player))
            {
                player.SendMessage("You are not a member of this guild.");
                return;
            }

            GuildMemberEntry playerEntry = GetGuildMemberEntry(player);

            if (playerEntry == null)
            {
                return;
            }

            if (CanApproveCandidates(playerEntry.m_Rank))
            {
                player.SendMessage("Which player do you wish to add to the guild?");
                player.Target = new RecruitMemberTarget(player, this);
            }

            else if (CanAddCandidates(playerEntry.m_Rank))
            {
                player.SendMessage("Which player do you wish to nominate as a candidate for guild membership?");
                player.Target = new RecruitMemberTarget(player, this);
            }

            else
            {
                player.SendMessage("You do not have a high enough rank in this guild to recruit new members.");
                return;
            }
        }
Ejemplo n.º 2
0
        public bool AddMember(PlayerMobile player)
        {
            if (player == null)
            {
                return(false);
            }

            if (m_Candidates.Contains(player))
            {
                m_Candidates.Remove(player);
            }

            if (IsMember(player))
            {
                return(false);
            }

            GuildMemberEntry entry = new GuildMemberEntry(player, GuildMemberRank.Recruit, DateTime.UtcNow, m_Guildmaster);

            player.Guild = this;
            player.m_GuildMemberEntry = entry;

            m_Members.Add(entry);

            return(true);
        }
Ejemplo n.º 3
0
        public void DismissMember(PlayerMobile player, bool forced, bool announce)
        {
            if (!IsMember(player))
            {
                return;
            }

            GuildMemberEntry entry = GetGuildMemberEntry(player);

            if (entry == null)
            {
                return;
            }

            bool wasGuildmaster = (entry.m_Rank == GuildMemberRank.Guildmaster);

            if (m_Members.Contains(entry))
            {
                m_Members.Remove(entry);
            }

            string guildText = Name + " [" + m_Abbreviation + "]";

            if (player != null)
            {
                player.Guild = null;
                player.m_GuildMemberEntry = null;

                if (forced)
                {
                    player.SendMessage(Guilds.GuildTextHue, "You have been removed from " + guildText + ".");
                }

                else
                {
                    player.SendMessage(Guilds.GuildTextHue, "You leave the guild.");
                }

                if (announce)
                {
                    if (forced)
                    {
                        GuildAnnouncement(player.RawName + " has been removed from the guild.", new List <PlayerMobile> {
                        }, GuildMemberRank.Recruit);
                    }

                    else
                    {
                        GuildAnnouncement(player.RawName + " has left the guild.", new List <PlayerMobile> {
                        }, GuildMemberRank.Recruit);
                    }
                }
            }

            if (wasGuildmaster)
            {
                AssignNewGuildmaster(player);
            }
        }
Ejemplo n.º 4
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (m_Player == null)
                {
                    return;
                }
                if (m_Player.Deleted)
                {
                    return;
                }

                if (m_Guild == null)
                {
                    m_Player.SendMessage("That guild no longer exists.");
                    return;
                }

                if (!m_Guild.IsMember(m_Player))
                {
                    m_Player.SendMessage("You are not a member of this guild.");
                    return;
                }

                GuildMemberEntry playerEntry = m_Guild.GetGuildMemberEntry(m_Player);

                if (playerEntry == null)
                {
                    return;
                }

                bool canImmediatelyAdd = m_Guild.CanAddCandidates(playerEntry.m_Rank);

                PlayerMobile playerTarget = target as PlayerMobile;

                if (playerTarget == null)
                {
                    m_Player.SendMessage("That is not a player.");
                    return;
                }

                if (Utility.GetDistance(m_Player.Location, playerTarget.Location) > 20)
                {
                    m_Player.SendMessage("That player is too far away.");
                    return;
                }

                if (playerTarget.Guild != null)
                {
                    m_Player.SendMessage("That player is already in a guild.");
                    return;
                }

                if (canImmediatelyAdd)
                {
                    if (m_Guild.AddMember(playerTarget))
                    {
                        string guildText = m_Guild.Name + " [" + m_Guild.m_Abbreviation + "]";

                        m_Guild.GuildAnnouncement(playerTarget.RawName + " has been made a member of the guild.", new List <PlayerMobile>()
                        {
                            playerTarget
                        }, GuildMemberRank.Recruit);

                        playerTarget.SendMessage(Guilds.GuildTextHue, "You have been made a guild member of " + guildText + ".");

                        return;
                    }

                    else
                    {
                        m_Player.SendMessage("That player is already a member of this guild or unable to join a guild at this time.");

                        return;
                    }
                }

                else
                {
                    if (m_Guild.m_Candidates.Contains(playerTarget))
                    {
                        m_Player.SendMessage("That player is already a candidate for membership in this guild.");
                        return;
                    }

                    else
                    {
                        m_Guild.m_Candidates.Add(playerTarget);

                        m_Player.SendMessage(Guilds.GuildTextHue, playerTarget.RawName + " has been made a candidate for guild membership.");
                        playerTarget.SendMessage(Guilds.GuildTextHue, "You have been made a candidate for guild membership.");

                        string message = playerTarget.RawName + " has been made a candidate for membership in the guild.";

                        m_Guild.GuildAnnouncement(message, new List <PlayerMobile>()
                        {
                            m_Player, playerTarget
                        }, GuildMemberRank.Officer);

                        return;
                    }
                }
            }
Ejemplo n.º 5
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            //Version 0
            if (version >= 0)
            {
                m_Guildmaster  = (PlayerMobile)reader.ReadMobile();
                m_Abbreviation = reader.ReadString();
                m_CreationTime = reader.ReadDateTime();
                m_Icon         = reader.ReadInt();
                m_IconHue      = reader.ReadInt();
                m_Website      = reader.ReadString();
                m_Guildhouse   = reader.ReadItem() as BaseHouse;
                m_Faction      = reader.ReadItem() as Faction;

                //Rank Names
                int rankNamesCount = reader.ReadInt();
                for (int a = 0; a < rankNamesCount; a++)
                {
                    m_RankNames[a] = reader.ReadString();
                }

                //Members
                int membersCount = reader.ReadInt();
                for (int a = 0; a < membersCount; a++)
                {
                    PlayerMobile    player       = reader.ReadMobile() as PlayerMobile;
                    GuildMemberRank rank         = (GuildMemberRank)reader.ReadInt();
                    DateTime        joinDate     = reader.ReadDateTime();
                    PlayerMobile    fealtyPlayer = reader.ReadMobile() as PlayerMobile;

                    if (player != null)
                    {
                        if (!player.Deleted)
                        {
                            GuildMemberEntry guildMemberEntry = new GuildMemberEntry(player, rank, joinDate, fealtyPlayer);

                            m_Members.Add(guildMemberEntry);
                        }
                    }
                }

                //Lists
                int alliesCount = reader.ReadInt();
                for (int a = 0; a < alliesCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_Allies.Add(entry);
                        }
                    }
                }

                int alliesRequestsSentCount = reader.ReadInt();
                for (int a = 0; a < alliesRequestsSentCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_AlliesRequestsSent.Add(entry);
                        }
                    }
                }

                int alliesRequestsReceivedCount = reader.ReadInt();
                for (int a = 0; a < alliesRequestsReceivedCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_AlliesRequestsReceived.Add(entry);
                        }
                    }
                }

                int enemiesCount = reader.ReadInt();
                for (int a = 0; a < enemiesCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_Enemies.Add(entry);
                        }
                    }
                }

                int enemiesRequestsSentCount = reader.ReadInt();
                for (int a = 0; a < enemiesRequestsSentCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_EnemiesRequestsSent.Add(entry);
                        }
                    }
                }

                int enemiesRequestsReceivedCount = reader.ReadInt();
                for (int a = 0; a < enemiesRequestsReceivedCount; a++)
                {
                    Guild entry = reader.ReadItem() as Guild;

                    if (entry != null)
                    {
                        if (!entry.Deleted)
                        {
                            m_EnemiesRequestsReceived.Add(entry);
                        }
                    }
                }

                int candidatesCount = reader.ReadInt();
                for (int a = 0; a < candidatesCount; a++)
                {
                    PlayerMobile candidate = reader.ReadMobile() as PlayerMobile;

                    if (candidate != null)
                    {
                        if (!candidate.Deleted)
                        {
                            m_Candidates.Add(candidate);
                        }
                    }
                }
            }

            //-----

            Guilds.m_Guilds.Add(this);

            ReapplyMemberships();

            AuditGuild();
        }
Ejemplo n.º 6
0
        public override void OnDelete()
        {
            Queue m_Queue = new Queue();

            foreach (GuildMemberEntry entry in m_Members)
            {
                if (entry.m_Player == null)
                {
                    continue;
                }

                entry.m_Player.Guild = null;
                entry.m_Player.m_GuildMemberEntry = null;

                m_Queue.Enqueue(entry);
            }

            while (m_Queue.Count > 0)
            {
                GuildMemberEntry entry = (GuildMemberEntry)m_Queue.Dequeue();

                if (m_Members.Contains(entry))
                {
                    m_Members.Remove(entry);
                }
            }

            foreach (Guild guild in Guilds.m_Guilds)
            {
                if (guild == null)
                {
                    continue;
                }
                if (guild.Deleted)
                {
                    continue;
                }

                if (guild.m_Allies.Contains(this))
                {
                    guild.m_Allies.Remove(this);
                }

                if (guild.m_AlliesRequestsSent.Contains(this))
                {
                    guild.m_AlliesRequestsSent.Remove(this);
                }

                if (guild.m_AlliesRequestsReceived.Contains(this))
                {
                    guild.m_AlliesRequestsReceived.Remove(this);
                }

                if (guild.m_Enemies.Contains(this))
                {
                    guild.m_Enemies.Remove(this);
                }

                if (guild.m_EnemiesRequestsSent.Contains(this))
                {
                    guild.m_EnemiesRequestsSent.Remove(this);
                }

                if (guild.m_EnemiesRequestsReceived.Contains(this))
                {
                    guild.m_EnemiesRequestsReceived.Remove(this);
                }
            }

            if (Guilds.m_Guilds.Contains(this))
            {
                Guilds.m_Guilds.Remove(this);
            }

            base.OnDelete();
        }