Esempio n. 1
0
        /// <summary>
        /// Checks whether the given target exists in requester's guild and whether the given requestMember has needed privs
        /// Sends result of action to the requester
        /// </summary>
        /// <param name="reqChar">requester's character, can be null. If null, sending result is suppressed</param>
        /// <param name="targetName">target character's name</param>
        /// <param name="targetGM">target's GuildMember entry is returned through this</param>
        /// <param name="commandId">executed command. Used for sending result</param>
        /// <param name="reqPrivs">priviliges required for executing this action</param>
        /// <param name="canAffectSelf">can this action be executed on self?</param>
        /// <returns>result of operation</returns>
        public static GuildResult CheckAction(Character reqChar, string targetName, out GuildMember targetGM,
                                              GuildCommandId commandId, GuildPrivileges reqPrivs, bool canAffectSelf)
        {
            targetGM = (GuildMember)null;
            GuildMember guildMember = reqChar.GuildMember;
            GuildResult resultCode;

            if (guildMember == null)
            {
                resultCode = GuildResult.PLAYER_NOT_IN_GUILD;
                targetName = string.Empty;
            }
            else if ((targetGM = guildMember.Guild[targetName]) == null)
            {
                resultCode = GuildResult.PLAYER_NOT_FOUND;
            }
            else if (!canAffectSelf && guildMember == targetGM)
            {
                resultCode = GuildResult.PERMISSIONS;
            }
            else
            {
                if (guildMember.HasRight(reqPrivs))
                {
                    return(GuildResult.SUCCESS);
                }
                resultCode = GuildResult.PERMISSIONS;
                targetName = string.Empty;
            }

            GuildHandler.SendResult((IPacketReceiver)reqChar.Client, commandId, targetName, resultCode);
            return(resultCode);
        }
Esempio n. 2
0
        /// <summary>
        /// Check whether the given inviter may invite the given target
        /// Sends result to the inviter
        /// </summary>
        /// <param name="inviter">inviter's character, can be null. If null, sending result is suppressed</param>
        /// <param name="target">invitee's character, can be null</param>
        /// <param name="targetName">invitee character's name</param>
        /// <returs>result of invite</returs>
        public static GuildResult CheckInvite(Character inviter, Character target, string targetName = null)
        {
            GuildMember guildMember = inviter.GuildMember;
            GuildResult guildResult;

            if (guildMember == null)
            {
                guildResult = GuildResult.PLAYER_NOT_IN_GUILD;
            }
            else if (target == null)
            {
                guildResult = GuildResult.PLAYER_NOT_FOUND;
            }
            else if (inviter == target)
            {
                guildResult = GuildResult.PERMISSIONS;
            }
            else if (target.GuildMember != null)
            {
                guildResult = GuildResult.ALREADY_IN_GUILD;
            }
            else if (target.IsInvitedToGuild)
            {
                guildResult = GuildResult.ALREADY_INVITED_TO_GUILD;
            }
            else if ((int)inviter.Asda2FactionId != (int)target.Asda2FactionId)
            {
                guildResult = GuildResult.NOT_ALLIED;
            }
            else
            {
                if (inviter.Role.IsStaff)
                {
                    return(GuildResult.SUCCESS);
                }
                if (!guildMember.HasRight(GuildPrivileges.InviteMembers))
                {
                    guildResult = GuildResult.PERMISSIONS;
                }
                else
                {
                    if (!target.IsIgnoring((IUser)inviter))
                    {
                        return(GuildResult.SUCCESS);
                    }
                    guildResult = GuildResult.PLAYER_IGNORING_YOU;
                }
            }

            inviter.SendSystemMessage(string.Format("Unable to invite {1} cause : {0}.", (object)guildResult,
                                                    (object)targetName));
            return(guildResult);
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if given character has necessary priviliges
        /// CheckInGuild call is done automatically
        /// </summary>
        /// <param name="character">character to check. May be null</param>
        /// <param name="commandId">executed command (used for sending result)</param>
        /// <param name="reqPrivs">required privileges</param>
        /// <returns>The Character's guild if the character has required privileges within the guild, otherwise null</returns>
        public static Guild CheckPrivs(Character character, GuildCommandId commandId, GuildPrivileges reqPrivs)
        {
            GuildMember guildMember = character.GuildMember;

            if (guildMember == null)
            {
                GuildHandler.SendResult((IPacketReceiver)character, commandId, GuildResult.PLAYER_NOT_IN_GUILD);
                return((Guild)null);
            }

            if (guildMember.HasRight(reqPrivs))
            {
                return(guildMember.Guild);
            }
            Character character1 = guildMember.Character;

            if (character1 != null)
            {
                GuildHandler.SendResult((IPacketReceiver)character1, commandId, GuildResult.PERMISSIONS);
            }
            return((Guild)null);
        }