예제 #1
0
        public void CreateContractStatusFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
        {
            if (request.ContractStatus == null || request.ContractStatus.Value < 0)
            {
                return;
            }

            Func <Player, bool> filter = x => x._staff.ContractExpiryDate <= _savegame.GameDate.AddDays(30 * request.ContractStatus.Value);

            filters.Add(filter);
        }
예제 #2
0
        public void CreateNationalityFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
        {
            if (request.Nationality == null)
            {
                return;
            }

            Func <Player, bool> filter = x => x._staff.NationId == request.Nationality;

            filters.Add(filter);
        }
예제 #3
0
        public void CreateClubFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
        {
            int?clubId = null;

            if (!string.IsNullOrWhiteSpace(request.ClubName))
            {
                clubId = _savegame.Clubs.Values.FirstOrDefault(x => x.Name.Equals(request.ClubName, StringComparison.OrdinalIgnoreCase))?.ClubId;
                if (clubId == null)
                {
                    clubId = -2;
                }
            }

            filters.Add(x => (clubId == null || x._staff.ClubId == clubId));
        }
예제 #4
0
        public void CreatePlayerBasedFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
        {
            List <int>          countryClubs = null;
            Func <Player, bool> filter       = null;

            if (request.PlaysInDivision.HasValue)
            {
                Club_Comp comp = _savegame.ClubComps.Values.FirstOrDefault(x => x.Id == request.PlaysInDivision.Value);
                if (comp != null)
                {
                    var compClubs = _savegame.Clubs.Where(x => x.Value.DivisionId == comp.Id).Select(x => x.Value).ToList();

                    filter = x => compClubs.Select(y => y.ClubId).Contains(x._staff.ClubId);
                    filters.Add(filter);
                    return;
                }
            }

            if (!string.IsNullOrWhiteSpace(request.PlaysInCountry))
            {
                int?playsInNationId = _savegame.Nations.Values.FirstOrDefault(x => x.Name.Equals(request.PlaysInCountry, StringComparison.InvariantCultureIgnoreCase))?.Id;

                if (playsInNationId != null)
                {
                    countryClubs = _savegame.Clubs.Where(x => x.Value.NationId == playsInNationId.Value).Select(x => x.Key).ToList();

                    if (countryClubs?.Count > 0)
                    {
                        filter = x => countryClubs.Contains(x._staff.ClubId) || (x._staff.ClubId == -1 && x._staff.NationId == playsInNationId.Value);
                        filters.Add(filter);
                        return;
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(request.PlaysInRegion))
            {
                List <int> regionCountryIds = SaveGameHandler.GetCountriesInRegion(_savegame.Nations, request.PlaysInRegion);
                if (regionCountryIds?.Count > 0)
                {
                    countryClubs = _savegame.Clubs.Where(x => regionCountryIds.Contains(x.Value.NationId)).Select(x => x.Key).ToList();

                    filter = x => countryClubs.Contains(x._staff.ClubId) || (x._staff.ClubId == -1 && regionCountryIds.Contains(x._staff.NationId));
                    filters.Add(filter);
                    return;
                }
            }
        }
예제 #5
0
        public List <PlayerView> GetScoutResults(ScoutingRequest request)
        {
            List <Func <Player, bool> > filters      = new List <Func <Player, bool> >();
            SearchFilterHelper          filterHelper = new SearchFilterHelper(_savegame, _rater);

            filterHelper.CreateClubFilter(request, filters);
            filterHelper.CreatePositionFilter(request, filters);
            filterHelper.CreatePlayerBasedFilter(request, filters);
            filterHelper.CreateNationalityFilter(request, filters);
            filterHelper.CreateEUNationalityFilter(request, filters);
            filterHelper.CreateValueFilter(request, filters);
            filterHelper.CreateContractStatusFilter(request, filters);
            filterHelper.CreateAgeFilter(request, filters);

            var players = _savegame.Players;

            foreach (var filter in filters)
            {
                players = players.Where(x => filter(x)).ToList();
            }

            return(ConstructPlayerByScoutingValueDesc(request.PlayerType, request.NumberOfResults, players));
        }
예제 #6
0
 public void CreatePositionFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
 {
     filters.Add(x => (request.PlayerType == null || _playerRater.PlaysPosition(request.PlayerType.Value, x._player)));
 }
예제 #7
0
 public void CreateValueFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
 {
     filters.Add(x => (request.MinValue == null || x._staff.IsOverValue(request.MinValue.Value)) && (request.MaxValue == null || x._staff.IsUnderValue(request.MaxValue.Value)));
 }
예제 #8
0
 public void CreateEUNationalityFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
 {
     filters.Add(x => !request.EUNationalityOnly || IsEUNationality(x._staff));
 }
예제 #9
0
 public void CreateAgeFilter(ScoutingRequest request, List <Func <Player, bool> > filters)
 {
     filters.Add(x => (request.MinAge == 0 || GetAge(x._staff.DOB) >= request.MinAge) && (request.MaxAge == 0 || GetAge(x._staff.DOB) <= request.MaxAge));
 }