Add pages for the Rainbow Pool pet states

This commit is contained in:
Emi Matchu 2024-09-26 20:24:31 -07:00
parent 6f45cd0485
commit 75040ffbf3
8 changed files with 73 additions and 7 deletions

View file

@ -0,0 +1,5 @@
outfit-viewer
margin: 0 auto
dt
cursor: help

View file

@ -11,10 +11,14 @@
width: 200px
max-width: calc(50% - .25em)
min-width: 150px
padding: .5em
box-sizing: border-box
text-align: center
a
display: block
border-radius: 1em
padding: .5em
outfit-viewer
width: 100%
height: auto

View file

@ -0,0 +1,6 @@
class PetStatesController < ApplicationController
def show
@pet_type = PetType.matching_name_param(params[:pet_type_name]).first!
@pet_state = @pet_type.pet_states.find(params[:id])
end
end

View file

@ -110,7 +110,7 @@ class PetState < ApplicationRecord
def swf_asset_ids=(ids)
self['swf_asset_ids'] = ids
end
def handle_assets!
@parent_swf_asset_relationships_to_update.each do |rel|
rel.swf_asset.save!
@ -118,6 +118,10 @@ class PetState < ApplicationRecord
end
end
def to_param
"#{id}-#{pose.split('_').map(&:capitalize).join('-')}"
end
def self.from_pet_type_and_biology_info(pet_type, info)
swf_asset_ids = []
info.each do |zone_id, asset_info|

View file

@ -15,6 +15,10 @@ class PetType < ApplicationRecord
species = Species.find_by_name!(species_name)
where(color_id: color.id, species_id: species.id)
}
scope :matching_name_param, ->(name_param) {
color_name, _, species_name = name_param.rpartition("-")
matching_name(color_name, species_name)
}
scope :preferring_species, ->(species_id) {
joins(:species).order([Arel.sql("species_id = ? DESC"), species_id])
}
@ -108,6 +112,10 @@ class PetType < ApplicationRecord
Item.appearances_for(item, self, ...)
end
def to_param
"#{color.human_name}-#{species.human_name}"
end
def self.all_by_ids_or_children(ids, pet_states)
pet_states_by_pet_type_id = {}
pet_states.each do |pet_state|

View file

@ -1,5 +1,6 @@
%li
= outfit_viewer pet_state:
%span.name= pose_name pet_state.pose
- if pet_state.glitched?
%span.glitched{title: "Glitched"} 👾
= link_to [pet_state.pet_type, pet_state] do
= outfit_viewer pet_state:
%span.name= pose_name pet_state.pose
- if pet_state.glitched?
%span.glitched{title: "Glitched"} 👾

View file

@ -0,0 +1,36 @@
- title "#{@pet_type.human_name}: #{pose_name @pet_state.pose} [\##{@pet_state.id}]"
- use_responsive_design
= outfit_viewer pet_state: @pet_state
%dl
%dt{title: "Pose usually affects just the eyes and mouth. Neopets " +
"genders these as Male/Female, but I don't like those " +
"terms for like… it's just eyelashes! Sheesh!"}
Pose
%dd
= pose_name @pet_state.pose
- if @pet_state.pose == "UNCONVERTED"
(Retired, replaced by #{link_to "Alt Styles", alt_styles_path})
%dt{title: "This is our own internal ID number, nothing to do with " +
"Neopets's official data."}
DTI ID
%dd= @pet_state.id
%dt{title: "When we notice a form looks wrong, we mark it Glitched, to " +
"tell our systems to prefer other forms for this pose instead."}
Glitched?
%dd
- if @pet_state.glitched?
👾 Yes, it's bad news bonko'd
- else
✅ Not marked as Glitched
- content_for :stylesheets do
= stylesheet_link_tag "application/hanger-spinner"
= stylesheet_link_tag "application/outfit-viewer"
= stylesheet_link_tag "pet_states/show"
- content_for :javascripts do
= javascript_include_tag "outfit-viewer", async: true

View file

@ -37,7 +37,9 @@ OpenneoImpressItems::Application.routes.draw do
end
resources :alt_styles, path: 'alt-styles', only: [:index]
resources :swf_assets, path: 'swf-assets', only: [:show]
resources :pet_types, path: 'rainbow-pool', only: [:show], param: "name"
resources :pet_types, path: 'rainbow-pool', only: [:show], param: "name" do
resources :pet_states, only: [:show], path: "forms"
end
# Loading and modeling pets!
post '/pets/load' => 'pets#load', :as => :load_pet