Exemplo n.º 1
0
        private GuildResultInfo GuildOperationTaxUpdate(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (member.Rank.Index > 0)
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo result = GetResult();

            if (result.Result == GuildResult.Success)
            {
                if (Convert.ToBoolean(operation.Data))
                {
                    SetFlag(GuildFlag.Taxes);
                }
                else
                {
                    RemoveFlag(GuildFlag.Taxes);
                }

                SendToOnlineUsers(new ServerGuildFlagUpdate
                {
                    RealmId = WorldServer.RealmId,
                    GuildId = Id,
                    Value   = (uint)Flags
                });
            }

            return(result);
        }
Exemplo n.º 2
0
        private GuildResultInfo GuildOperationAdditionalInfo(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (member.Rank.Index > 0)
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildName))
                {
                    return(new GuildResultInfo(GuildResult.InvalidGuildInfo));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo result = GetResult();

            if (result.Result == GuildResult.Success)
            {
                AdditionalInfo = operation.TextValue;

                SendToOnlineUsers(new ServerGuildInfoMessageUpdate
                {
                    RealmId        = WorldServer.RealmId,
                    GuildId        = Id,
                    AdditionalInfo = AdditionalInfo
                });
            }

            return(result);
        }
Exemplo n.º 3
0
        private GuildResultInfo GuildOperationMessageOfTheDay(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.MessageOfTheDay))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildMessageOfTheDay))
                {
                    return(new GuildResultInfo(GuildResult.InvalidMessageOfTheDay));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo result = GetResult();

            if (result.Result == GuildResult.Success)
            {
                MessageOfTheDay = operation.TextValue;

                SendToOnlineUsers(new ServerGuildMotdUpdate
                {
                    RealmId         = WorldServer.RealmId,
                    GuildId         = Id,
                    MessageOfTheDay = MessageOfTheDay
                });
            }

            return(result);
        }
Exemplo n.º 4
0
        private GuildResultInfo GuildOperationMemberInvite(GuildMember member, Player player, ClientGuildOperation operation)
        {
            Player target = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.Invite))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                target = CharacterManager.Instance.GetPlayer(operation.TextValue);
                if (target == null)
                {
                    return(new GuildResultInfo(GuildResult.UnknownCharacter, referenceString: operation.TextValue));
                }

                return(target.GuildManager.CanInviteToGuild(Id));
            }

            GuildResultInfo info = GetResult();

            if (info.Result != GuildResult.Success)
            {
                return(info);
            }

            target.GuildManager.InviteToGuild(Id, player);
            return(new GuildResultInfo(GuildResult.InviteSent, referenceString: operation.TextValue));
        }
Exemplo n.º 5
0
        private GuildResultInfo GuildOperationMemberQuit(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo info = CanLeaveGuild(member);

            if (info.Result == GuildResult.Success)
            {
                player.GuildManager.LeaveGuild(Id, GuildResult.YouQuit);
                AnnounceGuildResult(GuildResult.MemberQuit, referenceText: player.Name);
            }

            return(info);
        }
Exemplo n.º 6
0
        private GuildResultInfo GuildOperationRankRename(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildRank rank = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.RenameRank))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksRankRenamePermission));
                }

                rank = GetRank((byte)operation.Rank);
                if (rank == null)
                {
                    return(new GuildResultInfo(GuildResult.InvalidRank, operation.Rank, operation.TextValue));
                }

                if (member.Rank.Index >= operation.Rank)
                {
                    return(new GuildResultInfo(GuildResult.CanOnlyModifyLowerRanks));
                }

                if (RankExists(operation.TextValue))
                {
                    return(new GuildResultInfo(GuildResult.DuplicateRankName, referenceString: operation.TextValue));
                }

                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildRankName))
                {
                    return(new GuildResultInfo(GuildResult.InvalidRankName, referenceString: operation.TextValue));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                rank.Name = operation.TextValue;
                AnnounceGuildRankChange();
                AnnounceGuildResult(GuildResult.RankRenamed, operation.Rank, operation.TextValue);
            }

            return(info);
        }
Exemplo n.º 7
0
        private GuildResultInfo GuildOperationRankDelete(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildRank rank = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.CreateAndRemoveRank))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksRankRenamePermission));
                }

                rank = GetRank((byte)operation.Rank);
                if (rank == null)
                {
                    return(new GuildResultInfo(GuildResult.InvalidRank, operation.Rank, operation.TextValue));
                }

                if (member.Rank.Index >= operation.Rank)
                {
                    return(new GuildResultInfo(GuildResult.CanOnlyModifyLowerRanks));
                }

                if (operation.Rank < 2 || operation.Rank > 8)
                {
                    return(new GuildResultInfo(GuildResult.CannotDeleteDefaultRanks, referenceId: operation.Rank));
                }

                if (rank.Any())
                {
                    return(new GuildResultInfo(GuildResult.CanOnlyDeleteEmptyRanks));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                RemoveRank((byte)operation.Rank);
                AnnounceGuildRankChange();
                AnnounceGuildResult(GuildResult.RankDeleted, referenceText: operation.TextValue);
            }

            return(info);
        }
Exemplo n.º 8
0
        private GuildResultInfo GuildOperationMemberRemove(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildMember targetMember = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.Kick))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksRankRenamePermission));
                }

                targetMember = GetMember(operation.TextValue);
                if (targetMember == null)
                {
                    return(new GuildResultInfo(GuildResult.CharacterNotInYourGuild, referenceString: operation.TextValue));
                }

                if (member.Rank.Index >= targetMember.Rank.Index)
                {
                    return(new GuildResultInfo(GuildResult.CannotKickHigherOrEqualRankedMember));
                }

                return(CanLeaveGuild(targetMember));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                // if the player is online handle through the local manager otherwise directly in the guild
                ICharacter targetCharacter = CharacterManager.Instance.GetCharacterInfo(targetMember.CharacterId);
                if (targetCharacter is Player targetPlayer)
                {
                    targetPlayer.GuildManager.LeaveGuild(Id, GuildResult.KickedYou);
                }
                else
                {
                    LeaveGuild(targetMember);
                }

                AnnounceGuildResult(GuildResult.KickedMember, referenceText: targetCharacter.Name);
            }

            return(info);
        }
Exemplo n.º 9
0
        private GuildResultInfo GuildOperationMemberDemote(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildMember targetMember = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.ChangeMemberRank))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                targetMember = GetMember(operation.TextValue);
                if (targetMember == null)
                {
                    return(new GuildResultInfo(GuildResult.CharacterNotInYourGuild, referenceString: operation.TextValue));
                }

                if (member.Rank.Index >= targetMember.Rank.Index)
                {
                    return(new GuildResultInfo(GuildResult.CannotDemote));
                }

                if (targetMember.Rank.Index == 9)
                {
                    return(new GuildResultInfo(GuildResult.CannotDemoteLowestRank));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                GuildRank newRank = GetDemotedRank(targetMember.Rank.Index);
                MemberChangeRank(targetMember, newRank);

                AnnounceGuildMemberChange(targetMember);
                AnnounceGuildResult(GuildResult.DemotedMember, referenceText: operation.TextValue);
            }

            return(info);
        }
Exemplo n.º 10
0
        private GuildResultInfo GuildOperationRankPermissions(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildRank rank = null;

            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.EditLowerRankPermissions))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksRankRenamePermission));
                }

                rank = GetRank((byte)operation.Rank);
                if (rank == null)
                {
                    return(new GuildResultInfo(GuildResult.InvalidRank, operation.Rank, operation.TextValue));
                }

                // TODO: check if mask options are valid for this guild type

                if (member.Rank.Index >= operation.Rank)
                {
                    return(new GuildResultInfo(GuildResult.CanOnlyModifyLowerRanks));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                // TODO: research why disabled needs to be removed
                var permissions = (GuildRankPermission)operation.Data.UInt32Data & ~GuildRankPermission.Disabled;
                rank.Permissions = permissions;

                AnnounceGuildRankChange();
                AnnounceGuildResult(GuildResult.RankModified, operation.Rank, operation.TextValue);
            }

            return(info);
        }
Exemplo n.º 11
0
        private GuildResultInfo GuildOperationRankAdd(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (!member.Rank.HasPermission(GuildRankPermission.CreateAndRemoveRank))
                {
                    return(new GuildResultInfo(GuildResult.RankLacksRankRenamePermission));
                }

                if (GetRank((byte)operation.Rank) != null)
                {
                    return(new GuildResultInfo(GuildResult.InvalidRank, operation.Rank, operation.TextValue));
                }

                if (RankExists(operation.TextValue))
                {
                    return(new GuildResultInfo(GuildResult.DuplicateRankName, referenceString: operation.TextValue));
                }

                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildRankName))
                {
                    return(new GuildResultInfo(GuildResult.InvalidRankName, referenceString: operation.TextValue));
                }

                // TODO: check if mask options are valid for this guild type

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                AddRank((byte)operation.Rank, operation.TextValue, (GuildRankPermission)operation.Data.UInt32Data);
                AnnounceGuildRankChange();
                AnnounceGuildResult(GuildResult.RankCreated, operation.Rank, operation.TextValue);
            }

            return(info);
        }
Exemplo n.º 12
0
        private GuildResultInfo GuildOperationDisband(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (member.Rank.Index != 0)
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                return(CanDisbandGuild());
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                DisbandGuild();
            }

            return(info);
        }
Exemplo n.º 13
0
        private GuildResultInfo GuildOperationTaxUpdate(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (member.Rank.Index > 0)
                {
                    return(new GuildResultInfo(GuildResult.RankLacksSufficientPermissions));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo result = GetResult();

            if (result.Result == GuildResult.Success)
            {
                SetTaxes(Convert.ToBoolean(operation.Data));
            }

            return(result);
        }
Exemplo n.º 14
0
        private GuildResultInfo GuildOperationEditPlayerNote(GuildMember member, Player player, ClientGuildOperation operation)
        {
            GuildResultInfo GetResult()
            {
                if (!TextFilterManager.Instance.IsTextValid(operation.TextValue) ||
                    !TextFilterManager.Instance.IsTextValid(operation.TextValue, UserText.GuildMemberNote))
                {
                    return(new GuildResultInfo(GuildResult.InvalidMemberNote));
                }

                return(new GuildResultInfo(GuildResult.Success));
            }

            GuildResultInfo info = GetResult();

            if (info.Result == GuildResult.Success)
            {
                member.Note = operation.TextValue;
                AnnounceGuildMemberChange(member);
            }

            return(info);
        }