Compare commits
No commits in common. "43d650a5d484ef3791c0f2c8e382aabd5be06b00" and "e511bdc5e2dca96c8daa4acd35aaac7a80a7d540" have entirely different histories.
43d650a5d4
...
e511bdc5e2
11 changed files with 14 additions and 88 deletions
|
@ -1,11 +0,0 @@
|
|||
body.alt_styles-index
|
||||
.alt-styles-list
|
||||
list-style: none
|
||||
display: flex
|
||||
justify-content: center
|
||||
flex-wrap: wrap
|
||||
gap: 1.5em
|
||||
|
||||
.alt-style
|
||||
text-align: center
|
||||
width: 80px
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
@import partials/jquery.jgrowl
|
||||
|
||||
@import alt_styles/index
|
||||
@import campaigns/show
|
||||
@import closet_hangers/index
|
||||
@import closet_hangers/petpage
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
class AltStylesController < ApplicationController
|
||||
def index
|
||||
@alt_styles = AltStyle.includes(:species, :color, :swf_assets).
|
||||
order(:species_id, :color_id).all
|
||||
end
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module AltStylesHelper
|
||||
end
|
|
@ -43,7 +43,13 @@ module ContributionHelper
|
|||
span = content_tag(:span, alt_style.name, class: 'contributed-name')
|
||||
output = translate("contributions.contributed_description.main.alt_style_html",
|
||||
alt_style_name: span)
|
||||
output << image_tag(alt_style.thumbnail_url) if show_image
|
||||
# HACK: Just assume this is a Nostalgic Alt Style, and that the thumbnail
|
||||
# is named reliably!
|
||||
if show_image
|
||||
thumbnail_url = "https://images.neopets.com/items/nostalgic_" +
|
||||
"#{alt_style.color.name.downcase}_#{alt_style.species.name.downcase}.gif"
|
||||
output << image_tag(thumbnail_url)
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
|
|
|
@ -11,28 +11,6 @@ class AltStyle < ApplicationRecord
|
|||
species_human_name: species.human_name)
|
||||
end
|
||||
|
||||
def thumbnail_url
|
||||
# HACK: Just assume this is a Nostalgic Alt Style, and that the thumbnail
|
||||
# is named reliably!
|
||||
"https://images.neopets.com/items/nostalgic_" +
|
||||
"#{color.name.downcase}_#{species.name.downcase}.gif"
|
||||
end
|
||||
|
||||
MANIFEST_PATTERN = %r{^https://images.neopets.com/(?<prefix>.+)/(?<id>[0-9]+)(?<hash_part>_[^/]+)?/manifest\.json}
|
||||
def preview_image_url
|
||||
swf_asset = swf_assets.first
|
||||
return nil if swf_asset.nil?
|
||||
|
||||
# HACK: Just assuming all of these were well-formed by the same process,
|
||||
# and infer the image URL from the manifest URL! But strictly speaking we
|
||||
# should be reading the manifest to check!
|
||||
match = swf_asset.manifest_url.match(MANIFEST_PATTERN)
|
||||
return nil if match.nil?
|
||||
|
||||
"https://images.neopets.com/#{match[:prefix]}/" +
|
||||
"#{match[:id]}#{match[:hash_part]}/#{match[:id]}.png"
|
||||
end
|
||||
|
||||
def biology=(biology)
|
||||
# TODO: This is very similar to what `PetState` does, but like… much much
|
||||
# more compact? Idk if I'm missing something, or if I was just that much
|
||||
|
@ -41,11 +19,4 @@ class AltStyle < ApplicationRecord
|
|||
SwfAsset.from_biology_data(self.body_id, asset_data)
|
||||
end
|
||||
end
|
||||
|
||||
# For convenience in the console!
|
||||
def self.find_by_name(color_name, species_name)
|
||||
color = Color.find_by_name(color_name)
|
||||
species = Species.find_by_name(species_name)
|
||||
where(color_id: color, species_id: species).first
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,35 +37,20 @@ class Pet < ApplicationRecord
|
|||
raise UnexpectedDataFormat unless pet_data[:color_id]
|
||||
raise UnexpectedDataFormat unless pet_data[:body_id]
|
||||
|
||||
has_alt_style = pet_data[:alt_style].present?
|
||||
|
||||
self.pet_type = PetType.find_or_initialize_by(
|
||||
species_id: pet_data[:species_id].to_i,
|
||||
color_id: pet_data[:color_id].to_i
|
||||
)
|
||||
self.pet_type.body_id = pet_data[:body_id]
|
||||
self.pet_type.origin_pet = self
|
||||
|
||||
# With an alt style, `body_id` in the biology data refers to the body ID of
|
||||
# the *alt* style, not the usual pet type. (We have `original_biology` for
|
||||
# *some* of the pet type's situation, but not it's body ID!)
|
||||
#
|
||||
# So, in the alt style case, don't update `body_id` - but if this is our
|
||||
# first time seeing this pet type and it doesn't *have* a `body_id` yet,
|
||||
# let's not be creating it without one. We'll need to model it without the
|
||||
# alt style first. (I don't bother with a clear error message though 😅)
|
||||
self.pet_type.body_id = pet_data[:body_id] unless has_alt_style
|
||||
if self.pet_type.body_id.nil?
|
||||
raise UnexpectedDataFormat,
|
||||
"can't process alt style on first occurrence of pet type"
|
||||
end
|
||||
|
||||
pet_state_biology = has_alt_style ? pet_data[:original_biology] :
|
||||
pet_data[:biology_by_zone]
|
||||
pet_state_biology = pet_data[:alt_style] ?
|
||||
pet_data[:original_biology] : pet_data[:biology_by_zone]
|
||||
raise UnexpectedDataFormat if pet_state_biology.empty?
|
||||
pet_state_biology[0] = nil # remove effects if present
|
||||
@pet_state = self.pet_type.add_pet_state_from_biology! pet_state_biology
|
||||
|
||||
if has_alt_style
|
||||
if pet_data[:alt_style]
|
||||
raise UnexpectedDataFormat unless pet_data[:alt_color]
|
||||
raise UnexpectedDataFormat if pet_data[:biology_by_zone].empty?
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
%li.alt-style
|
||||
= link_to alt_style.preview_image_url do
|
||||
= image_tag alt_style.thumbnail_url, class: 'alt-style-thumbnail'
|
||||
.alt-style-name= alt_style.name
|
|
@ -1,11 +0,0 @@
|
|||
- title "Styling Studio"
|
||||
|
||||
%p
|
||||
We're getting set up with the new NC Pet Styles! They're not ready in the app
|
||||
yet, but here's what we have so far!
|
||||
|
||||
%p
|
||||
If you have one we don't, please model it by entering your pet's name on the
|
||||
homepage! Thank you! 💖
|
||||
|
||||
%ul.alt-styles-list= render partial: "alt_style", collection: @alt_styles
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
.notice
|
||||
%strong Happy NC UC day!
|
||||
We're working on Styling Studio support,
|
||||
= link_to("here's what we have so far", alt_styles_path) + "!"
|
||||
We're still working on Alt Styles support, but other pets can be loaded as
|
||||
usual!
|
||||
%br
|
||||
Thank you for helping us model the new styles, we appreciate it lots!!! 💖
|
||||
Excited to have them for you soon!
|
||||
|
||||
%p#pet-not-found.alert= t 'pets.load.not_found'
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ OpenneoImpressItems::Application.routes.draw do
|
|||
resources :colors, only: [] do
|
||||
resources :pet_types, only: [:index]
|
||||
end
|
||||
resources :alt_styles, path: 'alt-styles', only: [:index]
|
||||
|
||||
# Loading and modeling pets!
|
||||
post '/pets/load' => 'pets#load', :as => :load_pet
|
||||
|
|
Loading…
Reference in a new issue