class Pokemongodb::Pokemon

Public Class Methods

all() click to toggle source

Returns array of all moves

Example:

>> Pokemongodb::Pokemon.all
=> [Pokemongodb::Pokemon::Abra, Pokemongodb::Pokemon::Aerodactyl, ...]
# File lib/pokemongodb/pokemon.rb, line 13
def self.all
  [ Pokemongodb::Pokemon::Abra, Pokemongodb::Pokemon::Aerodactyl, Pokemongodb::Pokemon::Alakazam, Pokemongodb::Pokemon::Arbok, Pokemongodb::Pokemon::Arcanine, Pokemongodb::Pokemon::Articuno, Pokemongodb::Pokemon::Beedrill, Pokemongodb::Pokemon::Bellsprout, Pokemongodb::Pokemon::Blastoise, Pokemongodb::Pokemon::Bulbasaur, Pokemongodb::Pokemon::Butterfree, Pokemongodb::Pokemon::Caterpie, Pokemongodb::Pokemon::Chansey, Pokemongodb::Pokemon::Charizard, Pokemongodb::Pokemon::Charmander, Pokemongodb::Pokemon::Charmeleon, Pokemongodb::Pokemon::Clefable, Pokemongodb::Pokemon::Clefairy, Pokemongodb::Pokemon::Cloyster, Pokemongodb::Pokemon::Cubone, Pokemongodb::Pokemon::Dewgong, Pokemongodb::Pokemon::Diglett, Pokemongodb::Pokemon::Ditto, Pokemongodb::Pokemon::Dodrio, Pokemongodb::Pokemon::Doduo, Pokemongodb::Pokemon::Dragonair, Pokemongodb::Pokemon::Dragonite, Pokemongodb::Pokemon::Dratini, Pokemongodb::Pokemon::Drowzee, Pokemongodb::Pokemon::Dugtrio, Pokemongodb::Pokemon::Eevee, Pokemongodb::Pokemon::Ekans, Pokemongodb::Pokemon::Electabuzz, Pokemongodb::Pokemon::Electrode, Pokemongodb::Pokemon::Exeggcute, Pokemongodb::Pokemon::Exeggutor, Pokemongodb::Pokemon::Farfetchd, Pokemongodb::Pokemon::Fearow, Pokemongodb::Pokemon::Flareon, Pokemongodb::Pokemon::Gastly, Pokemongodb::Pokemon::Gengar, Pokemongodb::Pokemon::Geodude, Pokemongodb::Pokemon::Gloom, Pokemongodb::Pokemon::Golbat, Pokemongodb::Pokemon::Goldeen, Pokemongodb::Pokemon::Golduck, Pokemongodb::Pokemon::Golem, Pokemongodb::Pokemon::Graveler, Pokemongodb::Pokemon::Grimer, Pokemongodb::Pokemon::Growlithe, Pokemongodb::Pokemon::Gyarados, Pokemongodb::Pokemon::Haunter, Pokemongodb::Pokemon::Hitmonchan, Pokemongodb::Pokemon::Hitmonlee, Pokemongodb::Pokemon::Horsea, Pokemongodb::Pokemon::Hypno, Pokemongodb::Pokemon::Ivysaur, Pokemongodb::Pokemon::Jigglypuff, Pokemongodb::Pokemon::Jolteon, Pokemongodb::Pokemon::Jynx, Pokemongodb::Pokemon::Kabuto, Pokemongodb::Pokemon::Kabutops, Pokemongodb::Pokemon::Kadabra, Pokemongodb::Pokemon::Kakuna, Pokemongodb::Pokemon::Kangaskhan, Pokemongodb::Pokemon::Kingler, Pokemongodb::Pokemon::Koffing, Pokemongodb::Pokemon::Krabby, Pokemongodb::Pokemon::Lapras, Pokemongodb::Pokemon::Lickitung, Pokemongodb::Pokemon::Machamp, Pokemongodb::Pokemon::Machoke, Pokemongodb::Pokemon::Machop, Pokemongodb::Pokemon::Magikarp, Pokemongodb::Pokemon::Magmar, Pokemongodb::Pokemon::Magnemite, Pokemongodb::Pokemon::Magneton, Pokemongodb::Pokemon::Mankey, Pokemongodb::Pokemon::Marowak, Pokemongodb::Pokemon::Meowth, Pokemongodb::Pokemon::Metapod, Pokemongodb::Pokemon::Mew, Pokemongodb::Pokemon::Mewtwo, Pokemongodb::Pokemon::Moltres, Pokemongodb::Pokemon::MrMime, Pokemongodb::Pokemon::Muk, Pokemongodb::Pokemon::Nidoking, Pokemongodb::Pokemon::Nidoqueen, Pokemongodb::Pokemon::NidoranF, Pokemongodb::Pokemon::NidoranM, Pokemongodb::Pokemon::Nidorina, Pokemongodb::Pokemon::Nidorino, Pokemongodb::Pokemon::Ninetales, Pokemongodb::Pokemon::Oddish, Pokemongodb::Pokemon::Omanyte, Pokemongodb::Pokemon::Omastar, Pokemongodb::Pokemon::Onix, Pokemongodb::Pokemon::Paras, Pokemongodb::Pokemon::Parasect, Pokemongodb::Pokemon::Persian, Pokemongodb::Pokemon::Pidgeot, Pokemongodb::Pokemon::Pidgeotto, Pokemongodb::Pokemon::Pidgey, Pokemongodb::Pokemon::Pikachu, Pokemongodb::Pokemon::Pinsir, Pokemongodb::Pokemon::Poliwag, Pokemongodb::Pokemon::Poliwhirl, Pokemongodb::Pokemon::Poliwrath, Pokemongodb::Pokemon::Ponyta, Pokemongodb::Pokemon::Porygon, Pokemongodb::Pokemon::Primeape, Pokemongodb::Pokemon::Psyduck, Pokemongodb::Pokemon::Raichu, Pokemongodb::Pokemon::Rapidash, Pokemongodb::Pokemon::Raticate, Pokemongodb::Pokemon::Rattata, Pokemongodb::Pokemon::Rhydon, Pokemongodb::Pokemon::Rhyhorn, Pokemongodb::Pokemon::Sandshrew, Pokemongodb::Pokemon::Sandslash, Pokemongodb::Pokemon::Scyther, Pokemongodb::Pokemon::Seadra, Pokemongodb::Pokemon::Seaking, Pokemongodb::Pokemon::Seel, Pokemongodb::Pokemon::Shellder, Pokemongodb::Pokemon::Slowbro, Pokemongodb::Pokemon::Slowpoke, Pokemongodb::Pokemon::Snorlax, Pokemongodb::Pokemon::Spearow, Pokemongodb::Pokemon::Squirtle, Pokemongodb::Pokemon::Starmie, Pokemongodb::Pokemon::Staryu, Pokemongodb::Pokemon::Tangela, Pokemongodb::Pokemon::Tauros, Pokemongodb::Pokemon::Tentacool, Pokemongodb::Pokemon::Tentacruel, Pokemongodb::Pokemon::Vaporeon, Pokemongodb::Pokemon::Venomoth, Pokemongodb::Pokemon::Venonat, Pokemongodb::Pokemon::Venusaur, Pokemongodb::Pokemon::Victreebel, Pokemongodb::Pokemon::Vileplume, Pokemongodb::Pokemon::Voltorb, Pokemongodb::Pokemon::Vulpix, Pokemongodb::Pokemon::Wartortle, Pokemongodb::Pokemon::Weedle, Pokemongodb::Pokemon::Weepinbell, Pokemongodb::Pokemon::Weezing, Pokemongodb::Pokemon::Wigglytuff, Pokemongodb::Pokemon::Zapdos, Pokemongodb::Pokemon::Zubat ]
end
candy_to_evolve() click to toggle source

Returns number of candies to evolve, or nil if no evolution

Example:

>> Pokemongodb::Pokemon::Bulbasaur.candy_to_evolve
=> 25

>> Pokemongodb::Pokemon::Ivysaur.candy_to_evolve
=> 100

>> Pokemongodb::Pokemon::Venusaur.candy_to_evolve
=> nil
# File lib/pokemongodb/pokemon.rb, line 28
def self.candy_to_evolve
  nil
end
charge_move_types() click to toggle source

Returns array of possible charge move types

Example:

>> Pokemongodb::Pokemon::Bulbasaur.charge_move_types
=> [Pokemongodb::Type::Poison, Pokemongodb::Type::Grass]
# File lib/pokemongodb/pokemon.rb, line 37
def self.charge_move_types
  charge_moves.map(&:type).uniq
end
charge_moves() click to toggle source

Returns array of possible charge moves

Example:

>> Pokemongodb::Pokemon::Bulbasaur.charge_moves
=> [Pokemongodb::Move::PowerWhip, Pokemongodb::Move::SeedBomb, Pokemongodb::Move::SludgeBomb]
# File lib/pokemongodb/pokemon.rb, line 46
def self.charge_moves
  moves.select { |move| move.category == Pokemongodb::Move::Category::CHARGE }
end
egg_hatch_distance() click to toggle source

returns integer of distance to hatch an egg, or nil if not hatchable from egg

Example:

>> Pokemongodb::Pokemon::Bulbasaur.egg_hatch_distance
=> 2

>> Pokemongodb::Pokemon::Vulpix.egg_hatch_distance
=> 5

>> Pokemongodb::Pokemon::Venusaur.egg_hatch_distance
=> nil
# File lib/pokemongodb/pokemon.rb, line 61
def self.egg_hatch_distance
  nil
end
evolves_from() click to toggle source

Returns evolution precursor or nil

Example:

>> Pokemongodb::Pokemon::Bulbasaur.evolves_from
=> nil

>> Pokemongodb::Pokemon::Ivysaur.evolves_from
=> Pokemongodb::Type::Bulbasaur
# File lib/pokemongodb/pokemon.rb, line 138
def self.evolves_from
  all.detect { |type| type.evolves_into == self }
end
evolves_into() click to toggle source

returns the pokemon it evolves into, or nil if no further evolution

Example:

>> Pokemongodb::Pokemon::Bulbasaur.evolves_into
=> Pokemongodb::Pokemon::Ivysaur

>> Pokemongodb::Pokemon::Ivysaur.evolves_into
=> Pokemongodb::Pokemon::Venusayr

>> Pokemongodb::Pokemon::Venusaur.evolves_into
=> nil
# File lib/pokemongodb/pokemon.rb, line 76
def self.evolves_into
  nil
end
fast_move_types() click to toggle source

Returns array of possible move types

Example:

>> Pokemongodb::Pokemon::Bulbasaur.fast_move_types
=> [Pokemongodb::Type::Normal, Pokemongodb::Type::Grass]
# File lib/pokemongodb/pokemon.rb, line 85
def self.fast_move_types
  fast_moves.map(&:type).uniq
end
fast_moves() click to toggle source

Returns array of possible charge moves

Example:

>> Pokemongodb::Pokemon::Bulbasaur.fast_moves
=> [Pokemongodb::Move::Tackle, Pokemongodb::Move::VineWhip]
# File lib/pokemongodb/pokemon.rb, line 94
def self.fast_moves
  moves.select { |move| move.category == Pokemongodb::Move::Category::FAST }
end
find(query) click to toggle source

Returns pokemon by id, string, or symbol

Example:

>> Pokemongodb::Pokemon.find(1)
=> Pokemongodb::Pokemon::Bulbasaur

>> Pokemongodb::Pokemon.find('ivysaur')
=> Pokemongodb::Pokemon::Ivysaur

>> Pokemongodb::Pokemon.find(:venusaur)
=> Pokemongodb::Pokemon::Venusaur
# File lib/pokemongodb/pokemon.rb, line 109
def self.find(query)
  if query.is_a?(Integer)
    all.detect { |type| type.id == query }
  elsif query.is_a?(String)
    Pokemongodb::Pokemon.const_get(query.capitalize)
  elsif query.is_a?(Symbol)
    Pokemongodb::Pokemon.const_get(query.to_s.capitalize)
  else
    nil
  end
end
find_by_type(t) click to toggle source

Returns pokemon by type

Example:

>> Pokemongodb::Pokemon.find_by_type(Pokemongodb::Type::Water)
=> [Pokemongodb::Pokemon::Blastoise, Pokemongodb::Pokemon::Cloyster, ...]
# File lib/pokemongodb/pokemon.rb, line 126
def self.find_by_type(t)
  all.select { |pokemon| pokemon.types.include?(t) }.uniq
end
move_sets() click to toggle source

Returns all available MoveSets for Pokemon

Example:

>> Pokemongodb::Pokemon::Bulbasaur.move_sets
=> [#<Pokemongodb::MoveSet:0xXXXXXX @fast_move=Pokemongodb::Move::VineWhip, @charge_move=Pokemongodb::Move::SludgeBomb, @dps=18.76>, ...]
# File lib/pokemongodb/pokemon.rb, line 147
def self.move_sets
  Pokemongodb::MoveSet.from_pokemon(self)
end
move_types() click to toggle source

Returns array of possible move types

Example:

>> Pokemongodb::Pokemon::Bulbasaur.move_types
=> [[Pokemongodb::Type::Grass, 3]
# File lib/pokemongodb/pokemon.rb, line 156
def self.move_types
  (fast_move_types + charge_move_types).uniq
end
perfect_hatch_iv() click to toggle source

returns integer of perfect iv for hatched egg, or nil if not hatchable

Example:

>> Pokemongodb::Pokemon::Bulbasaur.perfect_hatch_iv
=> 612

>> Pokemongodb::Pokemon::Ivysaur.perfect_hatch_iv
=> nil
# File lib/pokemongodb/pokemon.rb, line 168
def self.perfect_hatch_iv
  return nil unless self.egg_hatch_distance
  ratio = 4 / 7.0
  (self.max_cp * ratio).to_i
end
role() click to toggle source

Returns pokemon by id, string, or symbol

Example:

>> bulbasaur = Pokemongodb::Pokemon.find(1)
>> bulbasaur.role
=> :defense

>> charmander = Pokemongodb::Pokemon.find(4)
>> charmander.role
=> :offense
# File lib/pokemongodb/pokemon.rb, line 184
def self.role
  self.base_attack > self.base_defense ? Role::OFFENSE : Role::DEFENSE
end
strong_against() click to toggle source

Returns array of pokemon the subject is strong against

Example:

>> Pokemongodb::Pokemon::Bulbasaur.strong_against
=> [Pokemongodb::Pokemon::Cubone, Pokemongodb::Pokemon::Diglett, ...]
# File lib/pokemongodb/pokemon.rb, line 193
def self.strong_against
  self.find_type_against(:strong_against)
end
weak_against() click to toggle source

Returns array of pokemon the subject is weak against

Example:

>> Pokemongodb::Pokemon::Bulbasaur.weak_against
=> Pokemongodb::Pokemon::Beedrill, Pokemongodb::Pokemon::Butterfree, ... ]
# File lib/pokemongodb/pokemon.rb, line 202
def self.weak_against
  self.find_type_against(:weak_against)
end

Private Class Methods

find_type_against(mapped_type) click to toggle source
# File lib/pokemongodb/pokemon.rb, line 207
def self.find_type_against(mapped_type)
  p = []
  self.types.map(&mapped_type).flatten.uniq.each do |type|
    p += Pokemongodb::Pokemon.find_by_type(type)
  end
  return p.uniq
end