Class: Smogon::Type::Pokemon

Inherits:
Object
  • Object
show all
Defined in:
lib/botemon/smogon/pokemon.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abilitiesObject

Returns the value of attribute abilities.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def abilities
  @abilities
end

#base_statsObject

Returns the value of attribute base_stats.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def base_stats
  @base_stats
end

#movesObject

Returns the value of attribute moves.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def moves
  @moves
end

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def name
  @name
end

#tierObject

Returns the value of attribute tier.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def tier
  @tier
end

#typesObject

Returns the value of attribute types.



23
24
25
# File 'lib/botemon/smogon/pokemon.rb', line 23

def types
  @types
end

Class Method Details

.to_pokemon(ary) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/botemon/smogon/pokemon.rb', line 29

def self.to_pokemon(ary)
  Pokemon.new.tap do |pokemon|
    pokemon.name       = ary['name'      ]
    pokemon.types      = ary['types'     ]
    pokemon.tier       = ary['tier'      ]
    pokemon.abilities  = ary['abilities' ]
    pokemon.base_stats = ary['base_stats']
    pokemon.moves      = ary['moves'     ]
  end
end

Instance Method Details

#cluesObject



25
26
27
# File 'lib/botemon/smogon/pokemon.rb', line 25

def clues
  "Ability: #{abilities.join(', ')}\nType: #{types.join(?/)}\nBase stats: #{base_stats.join(?/)}"
end

#stats(level, nature, evs, ivs) ⇒ Object



51
52
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
# File 'lib/botemon/smogon/pokemon.rb', line 51

def stats(level, nature, evs, ivs)
  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]
  ivs        = Hash[fields.zip ivs]
  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_aryObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/botemon/smogon/pokemon.rb', line 40

def to_ary
  {
    'name'       => @name,
    'types'      => @types,
    'tier'       => @tier,
    'abilities'  => @abilities,
    'base_stats' => @base_stats,
    'moves'      => @moves
  }
end