Class: Oakdex::Pokemon::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/oakdex/pokemon/stat.rb

Overview

Calculates Pokemon Stats

Class Method Summary collapse

Class Method Details

.exp_by_level(leveling_rate, level) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/oakdex/pokemon/stat.rb', line 21

def exp_by_level(leveling_rate, level)
  case leveling_rate
  when 'Fast' then ((4.0 * level**3) / 5).to_i
  when 'Slow' then ((5.0 * level**3) / 4).to_i
  when 'Medium Slow' then medium_slow_exp(level)
  when 'Fluctuating' then fluctuating_exp(level)
  else level**3
  end
end

.initial_stat(stat, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/oakdex/pokemon/stat.rb', line 6

def initial_stat(stat, options = {})
  first_part = initial_stat_first_part(stat, options)
  (
    if stat == :hp
      first_part + options[:level] + 10
    elsif stat.to_s == options[:nature].increased_stat
      (first_part + 5) * 1.1
    elsif stat.to_s == options[:nature].decreased_stat
      (first_part + 5) * 0.9
    else
      first_part + 5
    end
  ).to_i
end

.level_by_exp(leveling_rate, exp) ⇒ Object



31
32
33
34
35
# File 'lib/oakdex/pokemon/stat.rb', line 31

def level_by_exp(leveling_rate, exp)
  level = 2
  level += 1 while exp_by_level(leveling_rate, level) <= exp
  level - 1
end