示例#1
0
        /// <summary>
        /// Checks if the village matches the current search criteria
        /// </summary>
        public bool Match(Village village)
        {
            if (SearchStrategy == FinderOptionsEnum.Nobled)
            {
                if (!village.HasPlayer || village.PreviousVillageDetails == null || village.Player.Equals(village.PreviousVillageDetails.Player))
                {
                    return(false);
                }

                if (Tribe != null &&
                    (
                        (!village.HasTribe || !Tribe.Equals(village.Player.Tribe))
                        &&
                        (!village.PreviousVillageDetails.HasTribe || !Tribe.Equals(village.PreviousVillageDetails.Player.Tribe))
                    )
                    )
                {
                    return(false);
                }
            }
            else
            {
                if (Tribe != null && (!village.HasTribe || !Tribe.Equals(village.Player.Tribe)))
                {
                    return(false);
                }

                switch (SearchStrategy)
                {
                case FinderOptionsEnum.NewInactives:
                    if (village.HasPlayer || village.PreviousVillageDetails == null || !village.PreviousVillageDetails.HasPlayer)
                    {
                        return(false);
                    }
                    break;

                case FinderOptionsEnum.LostPoints:
                    if (village.PreviousVillageDetails == null || village.Points >= village.PreviousVillageDetails.Points)
                    {
                        return(false);
                    }
                    break;
                }
            }

            if (!string.IsNullOrEmpty(Text) && !village.ToString().ToUpper(CultureInfo.InvariantCulture).Contains(Text))
            {
                return(false);
            }

            if (village.Points < PointsBetweenStart || (PointsBetweenEnd > 0 && village.Points > PointsBetweenEnd))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Checks if the player matches the current search criteria
        /// </summary>
        public bool Match(Player ply)
        {
            if (Tribe != null && !Tribe.Equals(ply.Tribe))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(Text) && !ply.Name.ToUpper(CultureInfo.InvariantCulture).Contains(Text))
            {
                return(false);
            }
            switch (SearchStrategy)
            {
            case FinderOptionsEnum.Inactives:
                if (ply.PreviousPlayerDetails == null)
                {
                    return(false);
                }
                if (ply.Any(village => village.PreviousVillageDetails == null || village.Points > village.PreviousVillageDetails.Points))
                {
                    return(false);
                }
                break;

            case FinderOptionsEnum.LostPoints:
                if (ply.PreviousPlayerDetails == null || ply.Points >= ply.PreviousPlayerDetails.Points)
                {
                    return(false);
                }
                break;

            case FinderOptionsEnum.TribeChange:
                if (!ply.TribeChange)
                {
                    return(false);
                }
                break;
            }


            if (ply.Points < PointsBetweenStart || (PointsBetweenEnd > 0 && ply.Points > PointsBetweenEnd))
            {
                return(false);
            }

            return(true);
        }