Пример #1
0
        public SecurityCheckResult CheckDetailed(PlayerInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerListCollection listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(SecurityCheckResult.BlackListed);
                }
            }

            if (info.Rank >= MinRank /*&& player.info.rank <= maxRank*/)  // TODO: implement maxrank
            {
                return(SecurityCheckResult.Allowed);
            }

            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(SecurityCheckResult.WhiteListed);
                }
            }

            return(SecurityCheckResult.RankTooLow);
        }
Пример #2
0
        public bool Check(PlayerInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            PlayerListCollection listCache = ExceptionList;

            for (int i = 0; i < listCache.Excluded.Length; i++)
            {
                if (listCache.Excluded[i] == info)
                {
                    return(false);
                }
            }

            if (info.Rank >= MinRank /*&& player.info.rank <= maxRank*/)
            {
                return(true);                                                          // TODO: implement maxrank
            }
            for (int i = 0; i < listCache.Included.Length; i++)
            {
                if (listCache.Included[i] == info)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
 public void UpdatePlayerListCache() {
     lock( playerPermissionListLock ) {
         ExceptionList = new PlayerListCollection {
             Included = includedPlayers.Values.ToArray(),
             Excluded = excludedPlayers.Values.ToArray()
         };
     }
 }
Пример #4
0
 public void UpdatePlayerListCache()
 {
     lock ( playerPermissionListLock ) {
         ExceptionList = new PlayerListCollection {
             Included = includedPlayers.Values.ToArray(),
             Excluded = excludedPlayers.Values.ToArray()
         };
     }
 }
Пример #5
0
 public PlayerListCollection(PlayerListCollection other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     Included = (PlayerInfo[])other.Included.Clone();
     Excluded = (PlayerInfo[])other.Excluded.Clone();
 }
Пример #6
0
        public void PrintDescription(Player player, IClassy target, string noun, string verb)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (noun == null)
            {
                throw new ArgumentNullException("noun");
            }
            if (verb == null)
            {
                throw new ArgumentNullException("verb");
            }
            PlayerListCollection list = ExceptionList;

            noun = Char.ToUpper(noun[0]) + noun.Substring(1);     // capitalize first letter

            StringBuilder message = new StringBuilder();

            if (NoRankRestriction)
            {
                message.AppendFormat("{0} {1}&S can be {2} by anyone",
                                     noun, target.GetClassyName(), verb);
            }
            else
            {
                message.AppendFormat("{0} {1}&S can only be {2} by {3}+&S",
                                     noun, target.GetClassyName(),
                                     verb, MinRank.GetClassyName());
            }

            if (list.Included.Length > 0)
            {
                message.AppendFormat(" and {0}&S", list.Included.JoinToClassyString());
            }

            if (list.Excluded.Length > 0)
            {
                message.AppendFormat(", except {0}", list.Excluded.JoinToClassyString());
            }

            message.Append('.');
            player.Message(message.ToString());
        }
Пример #7
0
 public PlayerListCollection( PlayerListCollection other ) {
     if( other == null ) throw new ArgumentNullException( "other" );
     Included = (PlayerInfo[])other.Included.Clone();
     Excluded = (PlayerInfo[])other.Excluded.Clone();
 }