Exemplo n.º 1
0
        private static List <PokemonEncounter> GetPokemonEncounters(EFLocationAreas locationArea)
        {
            return(locationArea
                   .Encounters
                   .GroupBy(x => x.PokemonId,
                            (key, group) =>
            {
                var efEncounterses = group as IList <EFEncounters> ?? group.ToList();

                var pokemon = efEncounterses
                              .FirstOrDefault()?
                              .Pokemon
                              .ToNamedApiResource();

                var versionEncounterDetails = efEncounterses
                                              .GroupBy(x2 => x2.Version.Id,
                                                       (key2, group2) =>
                {
                    var encounters = group2 as IList <EFEncounters> ?? group2.ToList();
                    return GetVersionEncounterDetails(encounters);
                })
                                              .ToList();

                return new PokemonEncounter(pokemon, versionEncounterDetails);
            })
                   .ToList());
        }
Exemplo n.º 2
0
 private static List <Name> GetNames(EFLocationAreas locationArea)
 {
     return(locationArea
            .LocationAreaProse
            .Select(x => new Name(x.Name, x.LocalLanguage.ToNamedApiResource()))
            .ToList());
 }
Exemplo n.º 3
0
 internal static NamedAPIResource ToNamedApiResource(this EFLocationAreas src)
 => src.Location == null
         ? src.ToNamedApiResource <LocationAreasController>()
         : new NamedAPIResource(
     $"{src.Location.Identifier}-{src.Identifier ?? "area"}",
     typeof(LocationAreasController).RscUrl(src.Id)
     );
Exemplo n.º 4
0
        private static List <EncounterMethodRate> GetEncounterMethodRates(EFLocationAreas locationArea)
        {
            return(locationArea
                   .LocationAreaEncounterRates
                   .GroupBy(x => x.EncounterMethodId,
                            (key, group) =>
            {
                var efLocationAreaEncounterRateses = group as IList <EFLocationAreaEncounterRates> ?? group.ToList();

                var encounterMethod = efLocationAreaEncounterRateses
                                      .FirstOrDefault()?
                                      .EncounterMethod
                                      .ToNamedApiResource();

                var encounterVersionDetails = efLocationAreaEncounterRateses
                                              .Select(g => new EncounterVersionDetails(g.Rate, g.Version.ToNamedApiResource()))
                                              .ToList();

                return new EncounterMethodRate(encounterMethod, encounterVersionDetails);
            })
                   .ToList());
        }
Exemplo n.º 5
0
 private static string GetName(EFLocationAreas locationArea)
 {
     return($"{locationArea.Location.Identifier}-{locationArea.Identifier ?? "area"}");
 }
Exemplo n.º 6
0
 private static NamedAPIResource GetLocation(EFLocationAreas locationArea)
 {
     return(locationArea
            .Location
            .ToNamedApiResource());
 }