public Club_Comp Convert(byte[] source) { var comp = new Club_Comp(); comp.Id = ByteHandler.GetIntFromBytes(source, 0); comp.LongName = ByteHandler.GetStringFromBytes(source, 4, 50); comp.Name = ByteHandler.GetStringFromBytes(source, 56, 25); //comp.Reputation = ByteHandler.GetByteFromBytes(source, 82); comp.NationId = ByteHandler.GetIntFromBytes(source, 92); comp.Abbreviation = ByteHandler.GetStringFromBytes(source, 83, 3); return(comp); }
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; } } }