class Type
Attributes
damage_relations[RW]
data[RW]
id[RW]
moves[RW]
name[RW]
pokemon_with_type[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 25 def self.all @@all end
limit()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 33 def self.limit @@limit end
new(name, url)
click to toggle source
# File lib/dexter_plusplus/type.rb, line 9 def initialize(name, url) self.name = name self.url = url self.data = JSON.parse(RestClient.get(url)) self.moves = [] self.pokemon_with_type = [] self.damage_relations = {} self.set_attributes @@all << self end
print_all()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 112 def self.print_all self.all.each{|type| type.print_all} end
tag()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 29 def self.tag @@tag end
Public Instance Methods
add_move(move)
click to toggle source
# File lib/dexter_plusplus/type.rb, line 45 def add_move(move) if !self.moves.include?(move) self.moves << move end end
add_pokemon(pokemon)
click to toggle source
# File lib/dexter_plusplus/type.rb, line 41 def add_pokemon(pokemon) self.pokemon_with_type << pokemon end
get_double_damage_from()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 67 def get_double_damage_from output = [] types = self.data["damage_relations"]["double_damage_from"] types.each{|type| output << type["name"]} output end
get_double_damage_to()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 60 def get_double_damage_to output = [] types = self.data["damage_relations"]["double_damage_to"] types.each{|type| output << type["name"]} output end
get_half_damage_from()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 81 def get_half_damage_from output = [] types = self.data["damage_relations"]["half_damage_from"] types.each{|type| output << type["name"]} output end
get_half_damage_to()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 74 def get_half_damage_to output = [] types = self.data["damage_relations"]["half_damage_to"] types.each{|type| output << type["name"]} output end
get_no_damage_from()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 95 def get_no_damage_from output = [] types = self.data["damage_relations"]["no_damage_from"] types.each{|type| output << type["name"]} output end
get_no_damage_to()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 88 def get_no_damage_to output = [] types = self.data["damage_relations"]["no_damage_to"] types.each{|type| output << type["name"]} output end
print_all()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 102 def print_all puts "---------------------------------------------------------" puts " Dexter++ : Type ".light_magenta puts "---------------------------------------------------------" puts "Name: #{self.print_name(self.name)}" puts "" self.print_damage_relations puts "---------------------------------------------------------" end
print_damage_relations()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 163 def print_damage_relations puts "Damage Relations:" puts "\tDouble damage to:" self.damage_relations["double_damage_to"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} puts "" puts "\tDouble damage from:" self.damage_relations["double_damage_from"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} puts "" puts "\tHalf damage to:" self.damage_relations["half_damage_to"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} puts "" puts "\tHalf damage from:" self.damage_relations["half_damage_from"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} puts "" puts "\tNo damage to:" self.damage_relations["no_damage_to"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} puts "" puts "\tNo damage from:" self.damage_relations["no_damage_from"].each_with_index{|name, index| puts "\t\t\t#{index + 1}: #{self.print_name(name)}"} end
print_name(name)
click to toggle source
# File lib/dexter_plusplus/type.rb, line 116 def print_name(name) case name when "normal" name.capitalize.light_black.on_white when "fighting" name.capitalize.light_red.on_black when "flying" name.capitalize.light_white.on_magenta when "poison" name.capitalize.light_green.on_magenta when "ground" name.capitalize.yellow.on_light_white when "bug" name.capitalize.light_white.on_green when "rock" name.capitalize.red.on_yellow when "ghost" name.capitalize.black.on_light_magenta when "steel" name.capitalize.light_white.on_light_black when "fire" name.capitalize.black.on_light_red when "water" name.capitalize.blue.on_light_blue when "grass" name.capitalize.green.on_light_cyan when "electric" name.capitalize.black.on_light_yellow when "psychic" name.capitalize.light_magenta.on_magenta when "ice" name.capitalize.light_white.on_cyan when "dragon" name.capitalize.light_white.on_light_red when "dark" name.capitalize.light_white.on_black when "fairy" name.capitalize.light_magenta.on_light_white when "unkown" name.capitalize.black.on_cyan when "shadow" name.capitalize.light_magenta.on_light_black else name.capitalize end end
set_attributes()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 20 def set_attributes self.id = self.data["id"] self.set_damage_relations end
set_damage_relations()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 51 def set_damage_relations self.damage_relations["double_damage_to"] = self.get_double_damage_to self.damage_relations["double_damage_from"] = self.get_double_damage_from self.damage_relations["half_damage_to"] = self.get_half_damage_to self.damage_relations["half_damage_from"] = self.get_half_damage_from self.damage_relations["no_damage_to"] = self.get_no_damage_to self.damage_relations["no_damage_from"] = self.get_no_damage_from end
tag()
click to toggle source
# File lib/dexter_plusplus/type.rb, line 37 def tag @@tag end