Class: Pokemongodb::MoveSet
- Inherits:
-
Pokemongodb
- Object
- Pokemongodb
- Pokemongodb::MoveSet
- Defined in:
- lib/pokemongodb/move_set.rb
Instance Attribute Summary collapse
-
#charge_move ⇒ Object
readonly
Returns the value of attribute charge_move.
-
#fast_move ⇒ Object
readonly
Returns the value of attribute fast_move.
Class Method Summary collapse
-
.from_pokemon(pokemon) ⇒ Object
Returns all available MoveSets for Pokemon.
Instance Method Summary collapse
- #dps ⇒ Object
-
#initialize(fast_move, charge_move, pokemon) ⇒ MoveSet
constructor
A new instance of MoveSet.
Methods inherited from Pokemongodb
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_move ⇒ Object (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_move ⇒ Object (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
#dps ⇒ Object
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 |