Class: Pokemongodb::MoveSet

Inherits:
Pokemongodb show all
Defined in:
lib/pokemongodb/move_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pokemongodb

to_s

Constructor Details

#initialize(fast_move, charge_move, pokemon) ⇒ MoveSet

Returns a new instance of MoveSet.



21
22
23
24
25
26
# File 'lib/pokemongodb/move_set.rb', line 21

def initialize(fast_move, charge_move, pokemon)
  @fast_move = fast_move
  @charge_move = charge_move
  @pokemon = pokemon
  @dps = dps
end

Instance Attribute Details

#charge_moveObject (readonly)

Returns the value of attribute charge_move.



4
5
6
# File 'lib/pokemongodb/move_set.rb', line 4

def charge_move
  @charge_move
end

#fast_moveObject (readonly)

Returns the value of attribute fast_move.



3
4
5
# File 'lib/pokemongodb/move_set.rb', line 3

def fast_move
  @fast_move
end

Class Method Details

.from_pokemon(pokemon) ⇒ Object

Returns all available MoveSets for Pokemon

Example:

>> Pokemongodb::MoveSet.from_pokemon(Pokemongodb::Pokemon::Bulbasaur)
=> [#<Pokemongodb::MoveSet:0xXXXXXX @fast_move=Pokemongodb::Move::VineWhip, @charge_move=Pokemongodb::Move::SludgeBomb, @dps=18.76>, ...]


11
12
13
14
15
16
17
18
19
# File 'lib/pokemongodb/move_set.rb', line 11

def self.from_pokemon(pokemon)
  sets = []
  pokemon.fast_moves.each do |fast_move|
    pokemon.charge_moves.each do |charge_move|
      sets << Pokemongodb::MoveSet.new(fast_move, charge_move, pokemon)
    end
  end
  sets.sort_by { |set| set.dps }.reverse
end

Instance Method Details

#dpsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pokemongodb/move_set.rb', line 28

def dps
  timer = 90.0
  damage = 0
  energy = 0.0

  until timer <= 0
    move = energy >= @charge_move.energy.abs ? @charge_move : @fast_move
    timer -= move.cooldown
    damage += calculated_power(move)
    energy += calculated_energy(move)
  end

  return (damage / 90.0).round(2)
end