Closed vinnydiehl closed 1 year ago
Used this to get the data:
DATA_FILE = "data/species.yml"
# First 7 gens are easy
gens = [151, 251, 386, 493, 649, 721, 809].map { |n| (1..n).to_a }
puts "Fetching API data..."
# Get all the dexes from the PokeApi. Gen 8 has 3, gen 9 is just 1 for now
[[27, 28, 29], [31]].each do |dexes|
gens << dexes.map do |dex|
PokeApi.get(pokedex: dex).pokemon_entries.map do |entry|
entry.pokemon_species.url.match(/\d+(?=\/$)/).to_s.to_i
end
end.flatten
end
# BD/SP
gens[7] += gens[3]
gens.map! &:uniq
data = YAML.unsafe_load_file DATA_FILE
data.each { |entry| entry[:generations] = [] }
gens.each_with_index do |ids, gen|
puts "Processing Gen #{gen += 1}: #{ids.size} Pokémon found"
ids.each do |id|
# Use int_id on the species model to locate the proper ID
Species.all.select { |sp| sp.int_id == id }.each do |species|
data.find { |e| e[:id] == species.id }[:generations] << gen
end
end
end
File.open(DATA_FILE, "w") { |f| f.write data.to_yaml }
Would like to be able to filter search results by generation. Also, generation affects the behavior of some items, as well as the EV system in general.
Here is the business logic for the feature and their test implementation status:
data/species.yml
First task is gathering data on the availability of each species throughout the generations so that I may apply a search filter. I'm thinking about putting the feature right on the filters page, but I'm not 100% sure about that; this is intended to be a persistent setting so that might not be appropriate.