Class: Smogon::Pokemon
- Inherits:
-
Object
- Object
- Smogon::Pokemon
- Defined in:
- lib/botemon/smogon/pokemon.rb
Instance Attribute Summary collapse
-
#_name ⇒ Object
Returns the value of attribute _name.
-
#abilities ⇒ Object
Returns the value of attribute abilities.
-
#base_stats ⇒ Object
Returns the value of attribute base_stats.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tier ⇒ Object
Returns the value of attribute tier.
-
#types ⇒ Object
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#_name ⇒ Object
Returns the value of attribute _name.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def _name @_name end |
#abilities ⇒ Object
Returns the value of attribute abilities.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def abilities @abilities end |
#base_stats ⇒ Object
Returns the value of attribute base_stats.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def base_stats @base_stats end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def name @name end |
#tier ⇒ Object
Returns the value of attribute tier.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def tier @tier end |
#types ⇒ Object
Returns the value of attribute types.
22 23 24 |
# File 'lib/botemon/smogon/pokemon.rb', line 22 def types @types end |
Class Method Details
.to_pokemon(ary) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/botemon/smogon/pokemon.rb', line 32 def self.to_pokemon(ary) return Pokemon.new.tap { |pokemon| pokemon.name = ary['name'] pokemon._name = ary['_name'] pokemon.types = ary['types'] pokemon.tier = ary['tier'] pokemon.abilities = ary['abilities'] pokemon.base_stats = ary['base_stats'] } end |
Instance Method Details
#clues ⇒ Object
28 29 30 |
# File 'lib/botemon/smogon/pokemon.rb', line 28 def clues "Ability: #{abilities.join(', ')}\nType: #{types.join(?/)}\nTier: #{tier}\nBase stats: #{base_stats.join(?/)}" end |
#stats(level, nature, ivs, evs) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/botemon/smogon/pokemon.rb', line 53 def stats(level, nature, ivs, evs) natures = { :jolly => { :plus => :spe, :minus => :atksp }, :rash => { :plus => :atksp, :minus => :defsp }, :hardy => { :plus => :none, :minus => :none }, :brave => { :plus => :atk, :minus => :spe }, :naughty => { :plus => :atk, :minus => :defsp }, :calm => { :plus => :defsp, :minus => :atk }, :careful => { :plus => :defsp, :minus => :atksp }, :adamant => { :plus => :atk, :minus => :atksp }, :docile => { :plus => :none, :minus => :none }, :lax => { :plus => :def, :minus => :defsp }, :quirky => { :plus => :none, :minus => :none }, :gentle => { :plus => :defsp, :minus => :def }, :naive => { :plus => :spe, :minus => :defsp }, :hasty => { :plus => :spe, :minus => :def }, :mild => { :plus => :atksp, :minus => :def }, :modest => { :plus => :atksp, :minus => :atk }, :relaxed => { :plus => :def, :minus => :spe }, :quiet => { :plus => :atksp, :minus => :spe }, :bashful => { :plus => :none, :minus => :none }, :impish => { :plus => :def, :minus => :atksp }, :lonely => { :plus => :atk, :minus => :def }, :serious => { :plus => :none, :minus => :none }, :bold => { :plus => :def, :minus => :atk }, :timid => { :plus => :spe, :minus => :atk }, :sassy => { :plus => :defsp, :minus => :spe }, } fields = [ :hp, :atk, :def, :atksp, :defsp, :spe ] evs = Hash[fields.zip evs.split(?/)] ivs = Hash[fields.zip ivs.split(?/)] base_stats = Hash[fields.zip @base_stats] nature = natures[nature.downcase.to_sym] [].tap { |stats| fields.each_with_index { |field| iv = ivs[field].to_i ev = evs[field].to_i base_stat = base_stats[field].to_i multipler = case field when nature[:plus] then 1.1 when nature[:minus] then 0.9 else 1 end if field == :hp stats << (((iv + 2 * base_stat + ev / 4) * level / 100) + 10 + level).floor else stats << ((((iv + 2 * base_stat + ev / 4) * level / 100) + 5) * multipler).floor end } } end |
#to_ary ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/botemon/smogon/pokemon.rb', line 43 def to_ary { 'name' => name, '_name' => _name, 'types' => types, 'tier' => tier, 'abilities' => abilities, 'base_stats' => base_stats } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/botemon/smogon/pokemon.rb', line 24 def to_s "Name: #{name}\nAbility: #{abilities.join(', ')}\nType: #{types.join(?/)}\nTier: #{tier}\nBase stats: #{base_stats.join(?/)}" end |