From 2405727d7d62fce31102520167cde42ee688c198 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 24 Sep 2017 11:23:27 -0400 Subject: Started working on UI This commit imports a lot of assets from veekun, as well as a font from http://www.victoryroad.net/showthread.php?t=1507 --- app/models/pokeviewer/pokemon.rb | 46 +++++++++++++++++++++++++++++++++++++-- app/models/pokeviewer/revision.rb | 2 +- app/models/pokeviewer/trainer.rb | 3 ++- 3 files changed, 47 insertions(+), 4 deletions(-) (limited to 'app/models') diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 3b750ac..1410d37 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb @@ -15,7 +15,8 @@ module Pokeviewer numericality: { greater_than_or_equal_to: 0, only_integer: true } validates :met_level, presence: true, - numericality: { greater_than_or_equal_to: 1, only_integer: true } + numericality: { greater_than_or_equal_to: 1, only_integer: true }, + if: Proc.new { |a| a.met_type == :normal } validates :met_type, presence: true enumerize :met_type, in: [:normal, :hatched, :npc_trade, :fateful_encounter] @@ -31,12 +32,53 @@ module Pokeviewer enumerize :unown_letter, in: [:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, - :question_mark, :exclamation_mark] + :question, :exclamation] def to_param uuid end + def icon_path + "pokeviewer/icons/#{species_id}.png" + end + + def sprite_path + shininess = "normal" + if shiny + shininess = "shiny" + end + + game = "ruby-sapphire" + unless trainer.nil? + if (trainer.firered? or trainer.leafgreen?) and (species_id <= 156 or species_id == 216 or species_id == 386) + game = "firered-leafgreen" + elsif trainer.emerald? + game = "emerald" + end + end + + form = "" + if species_id == 201 + # Handle Unown forms + form = "-#{unown_letter}" + elsif species_id == 386 + # Handle Deoxys forms + if trainer.firered? + form = "-attack" + elsif trainer.leafgreen? + form = "-defense" + elsif trainer.emerald? + form = "-speed" + end + end + + if game == "emerald" + "pokeviewer/sprites/emerald/#{shininess}/#{species_id}#{form}.gif" + else + "pokeviewer/sprites/#{game}/#{shininess}/#{species_id}#{form}.png" + end + end + private def set_uuid diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 4cafd07..44388ca 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb @@ -4,7 +4,7 @@ module Pokeviewer class Revision < ApplicationRecord include ActiveRecord::Diff - diff :nickname, :experience, :level, :hp, :attack, :defense, + diff :nickname, :level, :hp, :attack, :defense, :special_attack, :special_defense, :speed, :coolness, :beauty, :cuteness, :smartness, :toughness, :sheen, :hold_item, :move_1_id, :move_2_id, :move_3_id, :move_4_id, :move_1_pp_bonuses, :move_2_pp_bonuses, diff --git a/app/models/pokeviewer/trainer.rb b/app/models/pokeviewer/trainer.rb index 1cef881..edfbd25 100644 --- a/app/models/pokeviewer/trainer.rb +++ b/app/models/pokeviewer/trainer.rb @@ -12,6 +12,7 @@ module Pokeviewer message: "and number should be pairwise unique" } validates :game, presence: true - enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald] + enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald], + predicates: true end end -- cgit 1.4.1