1
0
Fork 0
forked from OpenNeo/impress

support special colors in the infinite closet

This commit is contained in:
Emi Matchu 2011-05-02 18:07:56 -04:00
parent d565fd6587
commit 648649f5cc
8 changed files with 322 additions and 131 deletions

View file

@ -1,11 +1,16 @@
class SwfAssetsController < ApplicationController class SwfAssetsController < ApplicationController
def index def index
if params[:item_id] if params[:item_id]
@swf_assets = Item.find(params[:item_id]).swf_assets item = Item.find(params[:item_id])
@swf_assets = item.swf_assets
if params[:body_id] if params[:body_id]
@swf_assets = @swf_assets.fitting_body_id(params[:body_id]) @swf_assets = @swf_assets.fitting_body_id(params[:body_id])
else else
@swf_assets = @swf_assets.fitting_standard_body_ids if item.special_color
@swf_assets = @swf_assets.fitting_color(item.special_color)
else
@swf_assets = @swf_assets.fitting_standard_body_ids
end
json = @swf_assets.all.group_by(&:body_id) json = @swf_assets.all.group_by(&:body_id)
end end
elsif params[:body_id] && params[:item_ids] elsif params[:body_id] && params[:item_ids]
@ -26,3 +31,4 @@ class SwfAssetsController < ApplicationController
render :json => json render :json => json
end end
end end

View file

@ -19,15 +19,15 @@ module ItemsHelper
end end
def standard_species_search_links def standard_species_search_links
build_on_random_standard_pet_types(Species.all) do |pet_type| build_on_pet_types(Species.all) do |pet_type|
image = pet_type_image(pet_type, :happy, :zoom) image = pet_type_image(pet_type, :happy, :zoom)
query = "species:#{pet_type.species.name}" query = "species:#{pet_type.species.name}"
link_to(image, items_path(:q => query)) link_to(image, items_path(:q => query))
end end
end end
def standard_species_images(species) def standard_species_images_for(item)
build_on_random_standard_pet_types(species) do |pet_type| build_on_pet_types(item.supported_species, item.special_color) do |pet_type|
image = pet_type_image(pet_type, :happy, :face) image = pet_type_image(pet_type, :happy, :face)
attributes = { attributes = {
'data-id' => pet_type.id, 'data-id' => pet_type.id,
@ -62,8 +62,12 @@ module ItemsHelper
private private
def build_on_random_standard_pet_types(species, &block) def build_on_pet_types(species, special_color=nil, &block)
raw(PetType.random_basic_per_species(species.map(&:id)).map(&block).join) species_ids = species.map(&:id)
pet_types = special_color ?
PetType.where(:color_id => special_color.id, :species_id => species_ids).order(:species_id) :
PetType.random_basic_per_species(species.map(&:id))
pet_types.map(&block).join.html_safe
end end
def pet_type_image(pet_type, emotion, size) def pet_type_image(pet_type, emotion, size)
@ -74,3 +78,4 @@ module ItemsHelper
image_tag(src, :alt => human_name, :title => human_name) image_tag(src, :alt => human_name, :title => human_name)
end end
end end

View file

@ -12,7 +12,11 @@ class Item < ActiveRecord::Base
attr_writer :current_body_id attr_writer :current_body_id
NCRarities = [0, 500] NCRarities = [0, 500]
PaintbrushSetDescription = 'This item is part of a deluxe paint brush set!' PAINTBRUSH_SET_DESCRIPTION = 'This item is part of a deluxe paint brush set!'
SPECIAL_COLOR_DESCRIPTION_REGEX = /This item is only wearable by Neopets painted ([a-zA-Z]+)\./
SPECIAL_PAINTBRUSH_COLORS_PATH = Rails.root.join('config', 'colors_with_unique_bodies.txt')
SPECIAL_PAINTBRUSH_COLORS = File.read(SPECIAL_PAINTBRUSH_COLORS_PATH).split("\n").map { |name| Color.find_by_name(name) }
set_table_name 'objects' # Neo & PHP Impress call them objects, but the class name is a conflict (duh!) set_table_name 'objects' # Neo & PHP Impress call them objects, but the class name is a conflict (duh!)
set_inheritance_column 'inheritance_type' # PHP Impress used "type" to describe category set_inheritance_column 'inheritance_type' # PHP Impress used "type" to describe category
@ -75,6 +79,26 @@ class Item < ActiveRecord::Base
restricted_zones + occupied_zones restricted_zones + occupied_zones
end end
def special_color
@special_color ||= determine_special_color
end
protected
def determine_special_color
if description.include?(PAINTBRUSH_SET_DESCRIPTION)
downcased_name = name.downcase
SPECIAL_PAINTBRUSH_COLORS.each do |color|
return color if downcased_name.include?(color.name)
end
end
match = description.match(SPECIAL_COLOR_DESCRIPTION_REGEX)
if match
return Color.find_by_name(match[1].downcase)
end
end
public
def species_support_ids def species_support_ids
@species_support_ids_array ||= read_attribute('species_support_ids').split(',').map(&:to_i) rescue nil @species_support_ids_array ||= read_attribute('species_support_ids').split(',').map(&:to_i) rescue nil
end end
@ -601,7 +625,7 @@ class Item < ActiveRecord::Base
ADJECTIVE_FILTERS = { ADJECTIVE_FILTERS = {
'nc' => arel_table[:rarity_index].in(NCRarities), 'nc' => arel_table[:rarity_index].in(NCRarities),
'pb' => arel_table[:description].eq(PaintbrushSetDescription) 'pb' => arel_table[:description].eq(PAINTBRUSH_SET_DESCRIPTION)
} }
search_filter :is do |adjective| search_filter :is do |adjective|
filter = ADJECTIVE_FILTERS[adjective] filter = ADJECTIVE_FILTERS[adjective]
@ -713,3 +737,4 @@ class Item < ActiveRecord::Base
end end
require 'item_sweeper' require 'item_sweeper'

View file

@ -157,3 +157,4 @@ class PetType < ActiveRecord::Base
class DownloadError < Exception;end class DownloadError < Exception;end
end end

View file

@ -21,6 +21,11 @@ class SwfAsset < ActiveRecord::Base
where(arel_table[:body_id].in(BodyIdsFittingStandard)) where(arel_table[:body_id].in(BodyIdsFittingStandard))
} }
scope :fitting_color, lambda { |color|
body_ids = PetType.select(:body_id).where(:color_id => color.id).map(&:body_id)
where(arel_table[:body_id].in(body_ids))
}
scope :biology_assets, where(arel_table[:type].eq(PetState::SwfAssetType)) scope :biology_assets, where(arel_table[:type].eq(PetState::SwfAssetType))
scope :object_assets, where(arel_table[:type].eq(Item::SwfAssetType)) scope :object_assets, where(arel_table[:type].eq(Item::SwfAssetType))
scope :for_item_ids, lambda { |item_ids| scope :for_item_ids, lambda { |item_ids|
@ -124,3 +129,4 @@ class SwfAsset < ActiveRecord::Base
File.join(relevant_pieces) File.join(relevant_pieces)
end end
end end

View file

@ -25,7 +25,7 @@
%a#customize-more.button{:href => '/'} Customize more %a#customize-more.button{:href => '/'} Customize more
#item-preview #item-preview
#item-preview-species= standard_species_images(@item.supported_species) #item-preview-species= standard_species_images_for(@item)
#item-preview-error #item-preview-error
#item-preview-swf #item-preview-swf
Javascript and Flash are required to preview wearables. Sorry! Javascript and Flash are required to preview wearables. Sorry!
@ -36,3 +36,4 @@
= include_javascript_libraries :jquery, :swfobject = include_javascript_libraries :jquery, :swfobject
= javascript_include_tag 'items/show' = javascript_include_tag 'items/show'

View file

@ -1,270 +1,412 @@
---
acara: acara:
blue: mnbztxxn blue: mnbztxxn
green: obxdjm88 green: obxdjm88
red: 7njwqlq8 red: 7njwqlq8
yellow: o3wj6s77 yellow: o3wj6s77
baby: sk5z9r4n
maraquan: ntvxx7xc
mutant: zmofvhdx
aisha: aisha:
blue: n9ozx4z5 blue: n9ozx4z5
green: vw3j5rnt green: vw3j5rnt
red: r27dkxdc red: r27dkxdc
yellow: t4osnjxq yellow: t4osnjxq
baby: bon8m2o4
maraquan: 37wgjb6s
mutant: c4wrb4vd
blumaroo: blumaroo:
blue: 8dng4bvh blue: 8dng4bvh
green: xmqmg3m9 green: xmqmg3m9
red: j77lzlmx red: j77lzlmx
yellow: kfonqhdc yellow: kfonqhdc
baby: md7bjrss
maraquan: 82fzq4kh
mutant: jcxf8fwx
bori: bori:
blue: cdtgf7jo blue: cdtgf7jo
green: 6c8dvw76 green: 6c8dvw76
red: tg7hx55j red: tg7hx55j
yellow: sc2hhvhn yellow: sc2hhvhn
baby: fofhnsqj
maraquan: rln8zot7
mutant: 7lqvol7n
bruce: bruce:
blue: w3hljbx7 blue: w3hljbx7
green: gwgc67tt green: gwgc67tt
red: 72d26x2b red: 72d26x2b
yellow: wqz8xn4t yellow: wqz8xn4t
baby: kkkqd9hd
maraquan: oddhtbgs
mutant: b3jrdol9
buzz: buzz:
blue: rkvgtzv3 blue: rkvgtzv3
green: schfx5c4 green: schfx5c4
red: gddkkb5j red: gddkkb5j
yellow: jc9klfxm yellow: jc9klfxm
baby: kvxjk22f
maraquan: cm66xwqk
mutant: j9brxg4n
chia: chia:
blue: d65mc9gf blue: d65mc9gf
green: 8d4949sr green: 8d4949sr
red: 4lrb4n3f red: 4lrb4n3f
yellow: oqs3kzmf yellow: oqs3kzmf
baby: kvm8jr9k
mutant: mnf38rsr
chomby: chomby:
blue: h3qctoxg blue: h3qctoxg
green: 552mzx7r green: 552mzx7r
red: 9swsd8ln red: 9swsd8ln
yellow: bdml26md yellow: bdml26md
baby: v2l4d2nf
8-bit: 96lgkwnj
maraquan: v5x466sl
cybunny: cybunny:
blue: v8shwcoq blue: v8shwcoq
green: xl6msllv green: xl6msllv
red: lfkscvgd red: lfkscvgd
yellow: cwlv6zz9 yellow: cwlv6zz9
baby: h3lx4sw2
maraquan: 6zlzft6t
mutant: zzsonrg8
draik: draik:
blue: 2g4jtrfh blue: 2g4jtrfh
green: 438o4dv5 green: 438o4dv5
red: vd2joxxq red: vd2joxxq
yellow: bob39shq yellow: bob39shq
baby: h7g2lzvw
maraquan: mtxqzrjz
mutant: gq3dmvcf
elephante: elephante:
blue: 4ckkjxjj blue: 4ckkjxjj
green: r22hl9oh green: r22hl9oh
red: jhhhbrww red: jhhhbrww
yellow: jf9ww4om yellow: jf9ww4om
baby: gvj8c7rn
maraquan: gh3bofrd
mutant: fsvsz87k
eyrie: eyrie:
blue: m5mvxv23 blue: m5mvxv23
green: s42o6oon green: s42o6oon
red: 6kngmhvs red: 6kngmhvs
yellow: d6b8fqnm yellow: d6b8fqnm
baby: gqxnnsc4
maraquan: 4qxob8gs
mutant: dvxtocr7
flotsam: flotsam:
blue: hwdo7rlb blue: hwdo7rlb
green: 47vt32x2 green: 47vt32x2
red: xhob45wn red: xhob45wn
yellow: r8r7jmvr yellow: r8r7jmvr
baby: 84jvz79s
mutant: wj83k9kh
gelert: gelert:
blue: 4g7n9mh5 blue: 4g7n9mh5
green: jfmwlmk8 green: jfmwlmk8
red: l95vq4w2 red: l95vq4w2
yellow: 5nrd2lvd yellow: 5nrd2lvd
baby: c473f4o7
maraquan: 3dzw2l8c
mutant: 9ldnhtw5
gnorbu: gnorbu:
blue: 6c275jcg blue: 6c275jcg
green: ghfgo5tn green: ghfgo5tn
red: qozzjgmg red: qozzjgmg
yellow: 5lrvftfb yellow: 5lrvftfb
baby: fzjt34mc
mutant: bqgwjvq2
grarrl: grarrl:
blue: j7q65fv4 blue: j7q65fv4
green: t3mstkl6 green: t3mstkl6
red: r946sq53 red: r946sq53
yellow: jtg67z98 yellow: jtg67z98
baby: g66gs7m7
maraquan: 3dldqlj2
mutant: 8jtbfojx
grundo: grundo:
blue: nwx8v2rb blue: nwx8v2rb
green: 5xn4kjf8 green: 5xn4kjf8
red: qjcb6t8x red: qjcb6t8x
yellow: n2g9d94f yellow: n2g9d94f
baby: 4sqhoksn
maraquan: 8coxbn7v
mutant: 9tfsvdk7
hissi: hissi:
blue: 7ls55f33 blue: 7ls55f33
green: dz5dwsbx green: dz5dwsbx
red: jsfvcqwt red: jsfvcqwt
yellow: z24m7h7l yellow: z24m7h7l
baby: fwd63758
maraquan: z5dw7ln7
mutant: xx8g8jjb
ixi: ixi:
blue: ro3qcd6s blue: ro3qcd6s
green: w32r74vo green: w32r74vo
red: zs2m6862 red: zs2m6862
yellow: oggkzvq7 yellow: oggkzvq7
baby: r6djxvxw
maraquan: xd73hdoz
mutant: scd2f73q
jetsam: jetsam:
blue: w3rl2k9n blue: w3rl2k9n
green: cwss4w3s green: cwss4w3s
red: ghddf93g red: ghddf93g
yellow: kz43rnld yellow: kz43rnld
baby: zhz7wlxg
mutant: m8n64bsr
jubjub: jubjub:
blue: 8mf5gzov blue: 8mf5gzov
green: m267j935 green: m267j935
red: szckt2tj red: szckt2tj
yellow: 78hdsnmw yellow: 78hdsnmw
baby: 92x2bdtq
maraquan: gj7dmvsd
mutant: 783vj5nt
kacheek: kacheek:
blue: tvnq2l5s blue: tvnq2l5s
green: fkzfcb47 green: fkzfcb47
red: 9hbtocjh red: 9hbtocjh
yellow: 4gsrb59g yellow: 4gsrb59g
baby: nw424vgn
mutant: fq6nnvwh
kau: kau:
blue: ktlxmrtr blue: ktlxmrtr
green: x9ww69qo green: x9ww69qo
red: mrdtwkto red: mrdtwkto
yellow: 78w49w7x yellow: 78w49w7x
baby: qtxmt64l
maraquan: r5fzvmtd
mutant: 39thxh84
kiko: kiko:
blue: 2qlfqqnd blue: 2qlfqqnd
green: 42j5q3zx green: 42j5q3zx
red: mcodrwlt red: mcodrwlt
yellow: 86b5xdn6 yellow: 86b5xdn6
baby: d54hfwc7
mutant: wdqnjz2z
koi: koi:
blue: tjvv5cq8 blue: tjvv5cq8
green: ncfn87wk green: ncfn87wk
red: f3wvzz6r red: f3wvzz6r
yellow: 4f6cvzgh yellow: 4f6cvzgh
baby: 59lh68wg
mutant: zoc4ntrg
korbat: korbat:
blue: 4qxwv7w7 blue: 4qxwv7w7
green: d2ow9co8 green: d2ow9co8
red: omx9c876 red: omx9c876
yellow: nsxodd8z yellow: nsxodd8z
baby: kgmnvlx8
maraquan: 6g73dr7l
mutant: lf98r4sb
kougra: kougra:
blue: rfsbh59t blue: rfsbh59t
green: otvq569n green: otvq569n
red: x8hsckbh red: x8hsckbh
yellow: x7bbg59h yellow: x7bbg59h
baby: 45dwtg2f
8-bit: 5g6fj4g8
maraquan: 4snffcf5
mutant: 5qt72kjo
krawk: krawk:
blue: hxgsm5d4 blue: hxgsm5d4
green: 7ngw8z4f green: 7ngw8z4f
red: kzwxb3dn red: kzwxb3dn
yellow: m2gq59r5 yellow: m2gq59r5
baby: zgscmthd
maraquan: kbmht6zh
mutant: 8m94bk5w
kyrii: kyrii:
blue: ojmo7qgg blue: ojmo7qgg
green: t3b8s9nz green: t3b8s9nz
red: 6fvg9ngs red: 6fvg9ngs
yellow: blxmjgbk yellow: blxmjgbk
baby: 42fokwff
maraquan: s2do4jhq
mutant: x25ml223
lenny: lenny:
blue: jfc75n44 blue: jfc75n44
green: 242k4kdq green: 242k4kdq
red: kc4w238d red: kc4w238d
yellow: 8r94jhfq yellow: 8r94jhfq
baby: k2qnttxo
mutant: 89zgj87k
lupe: lupe:
blue: r552fqj8 blue: r552fqj8
green: ohmx4lc9 green: ohmx4lc9
red: 6jwlghsg red: 6jwlghsg
yellow: z42535zh yellow: z42535zh
baby: b4xfn6xv
maraquan: fhlqw4bf
mutant: 7ggn4k6x
lutari: lutari:
blue: qgg6z8s7 blue: qgg6z8s7
green: wtjv7hw4 green: wtjv7hw4
red: lgws33oo red: lgws33oo
yellow: 8x37fgjf yellow: 8x37fgjf
baby: jnbjxvf5
meerca: meerca:
blue: wwwhjf88 blue: wwwhjf88
green: lg9bb6tf green: lg9bb6tf
red: v7g8w8w6 red: v7g8w8w6
yellow: kk2nn2jr yellow: kk2nn2jr
baby: 446k2fln
maraquan: kgw5wv42
mutant: n4nd3c4v
moehog: moehog:
blue: moot839l blue: moot839l
green: jgkoro5z green: jgkoro5z
red: dk47mfk8 red: dk47mfk8
yellow: g84ovct7 yellow: g84ovct7
baby: 5r3oq2k4
maraquan: 5cgov2km
mutant: wdc9gwtq
mynci: mynci:
blue: xwlo9657 blue: xwlo9657
green: s33qzokw green: s33qzokw
red: f828tkrc red: f828tkrc
yellow: tdfhsndr yellow: tdfhsndr
baby: 9d354534
maraquan: 7d2ll99r
mutant: bqtb9hsz
nimmo: nimmo:
blue: bx7fho8x blue: bx7fho8x
green: mb4mcwj5 green: mb4mcwj5
red: mok2fcl4 red: mok2fcl4
yellow: 9559onds yellow: 9559onds
baby: nwq55xx5
ogrin: ogrin:
blue: 26v2sx49 blue: 26v2sx49
green: lg5bzqkq green: lg5bzqkq
red: 3xgoz429 red: 3xgoz429
yellow: rjzmx24v yellow: rjzmx24v
baby: bfrh323n
mutant: t6s8hrzx
peophin: peophin:
blue: 996t7zfg blue: 996t7zfg
green: c9qo7zzt green: c9qo7zzt
red: kokc52kh red: kokc52kh
yellow: 4khvfnwl yellow: 4khvfnwl
baby: 4jbvhghx
mutant: bjdggzwd
poogle: poogle:
blue: 5n2vx7v2 blue: 5n2vx7v2
green: fw6lvf3c green: fw6lvf3c
red: xhcwbdd5 red: xhcwbdd5
yellow: xozlhd68 yellow: xozlhd68
baby: b2467jkz
maraquan: z44rk3xg
pteri: pteri:
blue: 82d369sm blue: 82d369sm
green: slqmqr78 green: slqmqr78
red: tjhwbro3 red: tjhwbro3
yellow: 4gkkb57f yellow: 4gkkb57f
baby: snd77sqq
maraquan: sktvv8t7
mutant: 57tg8jb8
quiggle: quiggle:
blue: 4zs6b32m blue: 4zs6b32m
green: vbrsgqrl green: vbrsgqrl
red: xrmt72wr red: xrmt72wr
yellow: jdto7mj4 yellow: jdto7mj4
baby: 2k7wm6dx
mutant: bv9htk44
ruki: ruki:
blue: qsgbm5f6 blue: qsgbm5f6
green: vgml65cz green: vgml65cz
red: sm55zs3q red: sm55zs3q
yellow: n43szv42 yellow: n43szv42
baby: grbwvh54
maraquan: kjx2jjcg
mutant: hsls3rd8
scorchio: scorchio:
blue: ohb3b486 blue: ohb3b486
green: kmb82xw8 green: kmb82xw8
red: hkjoncsx red: hkjoncsx
yellow: hgfofbl2 yellow: hgfofbl2
baby: n443j7hn
maraquan: bm9b2b73
mutant: 3mfckmq4
shoyru: shoyru:
blue: dj7n2zk8 blue: dj7n2zk8
green: 3qwwn4n2 green: 3qwwn4n2
red: 3zb2s2zw red: 3zb2s2zw
yellow: mmvn4tkg yellow: mmvn4tkg
baby: xvvxvvjt
maraquan: f57glqj6
mutant: 49tjr4vf
skeith: skeith:
blue: 7c847jkn blue: 7c847jkn
green: qdgwwz6c green: qdgwwz6c
red: fc4cxk3t red: fc4cxk3t
yellow: 533nc7rj yellow: 533nc7rj
baby: tjjsn83l
maraquan: o65f8j4f
mutant: jb8jhqqr
techo: techo:
blue: vl8qro4r blue: vl8qro4r
green: 2zc3vd47 green: 2zc3vd47
red: zgl2gjjn red: zgl2gjjn
yellow: 84gvowmj yellow: 84gvowmj
baby: ng83vkg7
maraquan: ln8lcbvh
mutant: tkqgzsv3
tonu: tonu:
blue: jd433863 blue: jd433863
green: 6mcv27mn green: 6mcv27mn
red: oskw3hqd red: oskw3hqd
yellow: 5bhqs7sv yellow: 5bhqs7sv
baby: h6jd7kw8
mutant: 59kr9c96
tuskaninny: tuskaninny:
blue: jj6t6cqd blue: jj6t6cqd
green: stl4mm78 green: stl4mm78
red: 48z4o75j red: 48z4o75j
yellow: q39wn6vq yellow: q39wn6vq
baby: c3vhmr2m
mutant: j2hob2sj
uni: uni:
blue: 74xvb24d blue: 74xvb24d
green: njzvoflw green: njzvoflw
red: jzfbdomk red: jzfbdomk
yellow: 5qdfrtcq yellow: 5qdfrtcq
baby: st84z8xf
maraquan: 3f3nzsjf
mutant: qw3gsfbb
usul: usul:
blue: xff976n8 blue: xff976n8
green: 5245lzmh green: 5245lzmh
red: rox4mgh5 red: rox4mgh5
yellow: vxn8b4vr yellow: vxn8b4vr
baby: 39vzk6nc
maraquan: 8sfjr77d
mutant: 3dgowzld
wocky: wocky:
blue: xonntr5f blue: xonntr5f
green: 4ssorlcs green: 4ssorlcs
red: 743smd5v red: 743smd5v
yellow: dnr2kj4b yellow: dnr2kj4b
baby: s7tld393
xweetok: xweetok:
blue: ddhdrt2o blue: ddhdrt2o
green: thzwbqsq green: thzwbqsq
red: tdkqr2b6 red: tdkqr2b6
yellow: o36btnbf yellow: o36btnbf
baby: wwh2wvkn
mutant: qs53ohzt
yurble: yurble:
blue: nhn5lxb4 blue: nhn5lxb4
green: mjgbr7vb green: mjgbr7vb
red: h95cs547 red: h95cs547
yellow: vfqkbvv6 yellow: vfqkbvv6
baby: 8b8fvxo2
mutant: 5o5t2j3s
zafara: zafara:
blue: x8c57g2l blue: x8c57g2l
green: tq56zj3x green: tq56zj3x
red: n32sgrvm red: n32sgrvm
yellow: onxr95x6 yellow: onxr95x6
baby: 93c22wgn
maraquan: b2gxlo5h
mutant: 9c9frk9g

View file

@ -0,0 +1,5 @@
8-Bit
Baby
Maraquan
Mutant