示例#1
0
 public GuildMember(Entities.GameClient client)
 {
     Rank = Enums.GuildRank.Member;
     DatabaseUID = client.DatabaseUID;
     Client = client;
     Name = client.Name;
 }
示例#2
0
        public void UpdateMember(int index, Enums.GuildRank rank)
        {
            Color color;

            switch (rank)
            {
            case Enums.GuildRank.Member:
                color = Color.LightSkyBlue;
                break;

            case Enums.GuildRank.Admin:
                color = Color.Yellow;
                break;

            case Enums.GuildRank.Founder:
                color = Color.LawnGreen;
                break;

            default:
                color = Color.Red;
                break;
            }
            string          name    = ((ListBoxTextItem)lbxMembers.Items[index]).Text.Split(']')[1];
            ListBoxTextItem lbiName = new ListBoxTextItem(Graphics.FontManager.LoadFont("tahoma", 10), "[" + rank + "] " + name);

            ranks[index] = rank;
            ((ListBoxTextItem)lbxMembers.Items[index]).ForeColor = color;
            ((ListBoxTextItem)lbxMembers.Items[index]).Text      = "[" + rank + "] " + name;

            Refresh();
        }
        /// <summary>
        /// Promotes/Unpromotes a member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <param name="promotionRank">The promotion rank. Member for unpromote.</param>
        /// <returns>True if the promotion or unpromotion was a success.</returns>
        public bool Promote(GuildMember member, Enums.GuildRank promotionRank)
        {
            if (promotionRank == Enums.GuildRank.None)
            {
                return(false);
            }

            if (promotionRank == Enums.GuildRank.DeputyLeader && _members.Values.Count(m => m.Rank == Enums.GuildRank.DeputyLeader) >= 5)
            {
                return(false);
            }

            var oldRank = member.Rank;

            member.Rank = promotionRank;
            member.DbGuildRank.Update();

            if (member.Online)
            {
                member.Player.UpdateClientGuild();
                member.Player.UpdateScreen(true);
            }

            if (promotionRank == Enums.GuildRank.Member)
            {
                if (member.Player != null)
                {
                    if (oldRank == Enums.GuildRank.DeputyLeader)
                    {
                        SendMessageFormat("REMOVED_DEPUTY_LEADER", Enums.GuildMessageType.Red, member.Player.Name);
                    }
                    else
                    {
                        SendMessageFormat("UNPROMOTED_MEMBER", Enums.GuildMessageType.Red, member.Player.Name, oldRank.ToString());
                    }
                }
            }
            else
            {
                if (member.Player != null)
                {
                    if (promotionRank == Enums.GuildRank.DeputyLeader)
                    {
                        SendMessageFormat("NEW_DEPUTY_LEADER", Enums.GuildMessageType.Green, member.Player.Name);
                    }
                    else
                    {
                        SendMessageFormat("PROMOTED_MEMBER", Enums.GuildMessageType.Green, member.Player.Name, promotionRank.ToString());
                    }
                }
            }

            _cachedSortedMembers = null;
            return(true);
        }
示例#4
0
        public void LoadGuildFromPacket(string[] parse)
        {
            ranks = new List <Enums.GuildRank>();
            lbxMembers.Items.Clear();

            int count = parse[1].ToInt();

            for (int i = 0; i < count; i++)
            {
                Enums.GuildRank rank = (Enums.GuildRank)parse[2 + i * 3 + 1].ToInt();
                Color           color;
                switch (rank)
                {
                case Enums.GuildRank.Member:
                    color = Color.LightSkyBlue;
                    break;

                case Enums.GuildRank.Admin:
                    color = Color.Yellow;
                    break;

                case Enums.GuildRank.Founder:
                    color = Color.LawnGreen;
                    break;

                default:
                    color = Color.Red;
                    break;
                }
                ListBoxTextItem lbiName = new ListBoxTextItem(Graphics.FontManager.LoadFont("tahoma", 10), "[" + rank + "] " + parse[2 + i * 3] + " (Last Login: "******")");
                ranks.Add(rank);
                lbiName.ForeColor = color;
                lbxMembers.Items.Add(lbiName);
            }
            Refresh();
        }
        /// <summary>
        /// Adds a member to the guild.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="rank">The starting rank.</param>
        /// <param name="update">A boolean determining whether the client of the player should be updated.</param>
        public void AddMember(Models.Entities.Player player, Enums.GuildRank rank, bool update = true)
        {
            var guildMember = new GuildMember(new Database.Models.DbGuildRank
            {
                GuildId        = Guild.Id,
                PlayerId       = player.DbPlayer.Id,
                PlayerName     = player.Name,
                PlayerLevel    = player.Level,
                SilverDonation = 0,
                CPDonation     = 0,
                GuildRank      = rank.ToString(),
                JoinDate       = Drivers.Time.GetTime(Drivers.Time.TimeType.Day)
            });

            if (guildMember.DbGuildRank.Create() && _members.TryAdd(player.DbPlayer.Id, guildMember))
            {
                player.AddActionLog("JoinGuild", Guild.Id);

                guildMember.Player = player;
                player.Guild       = Guild;
                player.GuildMember = guildMember;

                if (rank == Enums.GuildRank.GuildLeader)
                {
                    Guild.GuildLeader = guildMember;
                }

                if (update)
                {
                    player.UpdateClientGuild();
                    player.UpdateScreen(true);
                }
            }

            _cachedSortedMembers = null;
        }
示例#6
0
        public void UpdateOptions()
        {
            if (Players.PlayerManager.MyPlayer.GuildAccess > Enums.GuildRank.Member)
            {
                btnStepDown.Text = "Step Down";
            }
            else
            {
                btnStepDown.Text = "Leave Guild";
            }
            if (lbxMembers.SelectedIndex > -1)
            {
                Enums.GuildRank rank = ranks[lbxMembers.SelectedIndex];
                if (Players.PlayerManager.MyPlayer.GuildAccess == Enums.GuildRank.Founder)
                {
                    if (rank == Enums.GuildRank.Founder)
                    {
                        lblPromotePrice.Visible = false;
                        btnPromote.Visible      = false;
                        btnDemote.Visible       = false;
                    }
                    else if (rank == Enums.GuildRank.Admin)
                    {
                        lblPromotePrice.Visible = false;
                        btnPromote.Visible      = false;
                        btnDemote.Visible       = true;
                        btnDemote.Text          = "Demote";
                    }
                    else
                    {
                        lblPromotePrice.Visible = true;
                        btnPromote.Visible      = true;
                        btnDemote.Visible       = true;
                        btnDemote.Text          = "Remove";
                    }
                }
                else if (Players.PlayerManager.MyPlayer.GuildAccess == Enums.GuildRank.Admin)
                {
                    if (rank <= Enums.GuildRank.Member)
                    {
                        btnDemote.Visible = true;
                        btnDemote.Text    = "Remove";
                    }
                    else
                    {
                        lblPromotePrice.Visible = false;
                        btnPromote.Visible      = false;
                        btnDemote.Visible       = false;
                    }
                }
                else
                {
                    lblPromotePrice.Visible = false;
                    btnPromote.Visible      = false;
                    btnDemote.Visible       = false;
                }
            }
            else
            {
                lblPromotePrice.Visible = false;
                btnPromote.Visible      = false;
                btnDemote.Visible       = false;
            }

            if (Players.PlayerManager.MyPlayer.GuildAccess >= Enums.GuildRank.Admin)
            {
                lblName.Visible  = true;
                txtName.Visible  = true;
                btnOKAdd.Visible = true;
            }
            else
            {
                lblName.Visible  = false;
                txtName.Visible  = false;
                btnOKAdd.Visible = false;
            }
        }
示例#7
0
 public GuildMember()
 {
     Rank = Enums.GuildRank.Member;
 }
示例#8
0
 /// <summary>
 /// Creates a new guild member.
 /// </summary>
 /// <param name="dbGuildRank">The database model associated with the member.</param>
 public GuildMember(DbGuildRank dbGuildRank)
 {
     DbGuildRank = dbGuildRank;
     _rank       = dbGuildRank.GuildRank.ToEnum <Enums.GuildRank>();
 }