1
0
Fork 0
forked from OpenNeo/impress

Oops right, it's okay to work with an alt style we've already seen!

This commit is contained in:
Emi Matchu 2024-01-24 04:01:34 -08:00
parent 4e5023288e
commit e511bdc5e2
2 changed files with 4 additions and 4 deletions

View file

@ -15,8 +15,8 @@ class AltStyle < ApplicationRecord
# 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
# more clueless back when I wrote it, lol 😅
biology.values.each do |asset_data|
self.swf_assets << SwfAsset.from_biology_data(self.body_id, asset_data)
self.swf_assets = biology.values.map do |asset_data|
SwfAsset.from_biology_data(self.body_id, asset_data)
end
end
end

View file

@ -54,8 +54,8 @@ class Pet < ApplicationRecord
raise UnexpectedDataFormat unless pet_data[:alt_color]
raise UnexpectedDataFormat if pet_data[:biology_by_zone].empty?
@alt_style = AltStyle.new(
id: pet_data[:alt_style].to_i,
@alt_style = AltStyle.find_or_initialize_by(id: pet_data[:alt_style].to_i)
@alt_style.assign_attributes(
color_id: pet_data[:alt_color].to_i,
species_id: pet_data[:species_id].to_i,
body_id: pet_data[:body_id].to_i,