forked from OpenNeo/impress
support special colors in the infinite closet
This commit is contained in:
parent
d565fd6587
commit
648649f5cc
8 changed files with 322 additions and 131 deletions
|
@ -1,11 +1,16 @@
|
|||
class SwfAssetsController < ApplicationController
|
||||
def index
|
||||
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]
|
||||
@swf_assets = @swf_assets.fitting_body_id(params[:body_id])
|
||||
else
|
||||
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)
|
||||
end
|
||||
elsif params[:body_id] && params[:item_ids]
|
||||
|
@ -26,3 +31,4 @@ class SwfAssetsController < ApplicationController
|
|||
render :json => json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ module ItemsHelper
|
|||
end
|
||||
|
||||
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)
|
||||
query = "species:#{pet_type.species.name}"
|
||||
link_to(image, items_path(:q => query))
|
||||
end
|
||||
end
|
||||
|
||||
def standard_species_images(species)
|
||||
build_on_random_standard_pet_types(species) do |pet_type|
|
||||
def standard_species_images_for(item)
|
||||
build_on_pet_types(item.supported_species, item.special_color) do |pet_type|
|
||||
image = pet_type_image(pet_type, :happy, :face)
|
||||
attributes = {
|
||||
'data-id' => pet_type.id,
|
||||
|
@ -62,8 +62,12 @@ module ItemsHelper
|
|||
|
||||
private
|
||||
|
||||
def build_on_random_standard_pet_types(species, &block)
|
||||
raw(PetType.random_basic_per_species(species.map(&:id)).map(&block).join)
|
||||
def build_on_pet_types(species, special_color=nil, &block)
|
||||
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
|
||||
|
||||
def pet_type_image(pet_type, emotion, size)
|
||||
|
@ -74,3 +78,4 @@ module ItemsHelper
|
|||
image_tag(src, :alt => human_name, :title => human_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,11 @@ class Item < ActiveRecord::Base
|
|||
attr_writer :current_body_id
|
||||
|
||||
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_inheritance_column 'inheritance_type' # PHP Impress used "type" to describe category
|
||||
|
@ -75,6 +79,26 @@ class Item < ActiveRecord::Base
|
|||
restricted_zones + occupied_zones
|
||||
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
|
||||
@species_support_ids_array ||= read_attribute('species_support_ids').split(',').map(&:to_i) rescue nil
|
||||
end
|
||||
|
@ -601,7 +625,7 @@ class Item < ActiveRecord::Base
|
|||
|
||||
ADJECTIVE_FILTERS = {
|
||||
'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|
|
||||
filter = ADJECTIVE_FILTERS[adjective]
|
||||
|
@ -713,3 +737,4 @@ class Item < ActiveRecord::Base
|
|||
end
|
||||
|
||||
require 'item_sweeper'
|
||||
|
||||
|
|
|
@ -157,3 +157,4 @@ class PetType < ActiveRecord::Base
|
|||
|
||||
class DownloadError < Exception;end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@ class SwfAsset < ActiveRecord::Base
|
|||
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 :object_assets, where(arel_table[:type].eq(Item::SwfAssetType))
|
||||
scope :for_item_ids, lambda { |item_ids|
|
||||
|
@ -124,3 +129,4 @@ class SwfAsset < ActiveRecord::Base
|
|||
File.join(relevant_pieces)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
%a#customize-more.button{:href => '/'} Customize more
|
||||
|
||||
#item-preview
|
||||
#item-preview-species= standard_species_images(@item.supported_species)
|
||||
#item-preview-species= standard_species_images_for(@item)
|
||||
#item-preview-error
|
||||
#item-preview-swf
|
||||
Javascript and Flash are required to preview wearables. Sorry!
|
||||
|
@ -36,3 +36,4 @@
|
|||
|
||||
= include_javascript_libraries :jquery, :swfobject
|
||||
= javascript_include_tag 'items/show'
|
||||
|
||||
|
|
|
@ -1,270 +1,412 @@
|
|||
---
|
||||
acara:
|
||||
blue: mnbztxxn
|
||||
green: obxdjm88
|
||||
red: 7njwqlq8
|
||||
yellow: o3wj6s77
|
||||
baby: sk5z9r4n
|
||||
maraquan: ntvxx7xc
|
||||
mutant: zmofvhdx
|
||||
aisha:
|
||||
blue: n9ozx4z5
|
||||
green: vw3j5rnt
|
||||
red: r27dkxdc
|
||||
yellow: t4osnjxq
|
||||
baby: bon8m2o4
|
||||
maraquan: 37wgjb6s
|
||||
mutant: c4wrb4vd
|
||||
blumaroo:
|
||||
blue: 8dng4bvh
|
||||
green: xmqmg3m9
|
||||
red: j77lzlmx
|
||||
yellow: kfonqhdc
|
||||
baby: md7bjrss
|
||||
maraquan: 82fzq4kh
|
||||
mutant: jcxf8fwx
|
||||
bori:
|
||||
blue: cdtgf7jo
|
||||
green: 6c8dvw76
|
||||
red: tg7hx55j
|
||||
yellow: sc2hhvhn
|
||||
baby: fofhnsqj
|
||||
maraquan: rln8zot7
|
||||
mutant: 7lqvol7n
|
||||
bruce:
|
||||
blue: w3hljbx7
|
||||
green: gwgc67tt
|
||||
red: 72d26x2b
|
||||
yellow: wqz8xn4t
|
||||
baby: kkkqd9hd
|
||||
maraquan: oddhtbgs
|
||||
mutant: b3jrdol9
|
||||
buzz:
|
||||
blue: rkvgtzv3
|
||||
green: schfx5c4
|
||||
red: gddkkb5j
|
||||
yellow: jc9klfxm
|
||||
baby: kvxjk22f
|
||||
maraquan: cm66xwqk
|
||||
mutant: j9brxg4n
|
||||
chia:
|
||||
blue: d65mc9gf
|
||||
green: 8d4949sr
|
||||
red: 4lrb4n3f
|
||||
yellow: oqs3kzmf
|
||||
baby: kvm8jr9k
|
||||
mutant: mnf38rsr
|
||||
chomby:
|
||||
blue: h3qctoxg
|
||||
green: 552mzx7r
|
||||
red: 9swsd8ln
|
||||
yellow: bdml26md
|
||||
baby: v2l4d2nf
|
||||
8-bit: 96lgkwnj
|
||||
maraquan: v5x466sl
|
||||
cybunny:
|
||||
blue: v8shwcoq
|
||||
green: xl6msllv
|
||||
red: lfkscvgd
|
||||
yellow: cwlv6zz9
|
||||
baby: h3lx4sw2
|
||||
maraquan: 6zlzft6t
|
||||
mutant: zzsonrg8
|
||||
draik:
|
||||
blue: 2g4jtrfh
|
||||
green: 438o4dv5
|
||||
red: vd2joxxq
|
||||
yellow: bob39shq
|
||||
baby: h7g2lzvw
|
||||
maraquan: mtxqzrjz
|
||||
mutant: gq3dmvcf
|
||||
elephante:
|
||||
blue: 4ckkjxjj
|
||||
green: r22hl9oh
|
||||
red: jhhhbrww
|
||||
yellow: jf9ww4om
|
||||
baby: gvj8c7rn
|
||||
maraquan: gh3bofrd
|
||||
mutant: fsvsz87k
|
||||
eyrie:
|
||||
blue: m5mvxv23
|
||||
green: s42o6oon
|
||||
red: 6kngmhvs
|
||||
yellow: d6b8fqnm
|
||||
baby: gqxnnsc4
|
||||
maraquan: 4qxob8gs
|
||||
mutant: dvxtocr7
|
||||
flotsam:
|
||||
blue: hwdo7rlb
|
||||
green: 47vt32x2
|
||||
red: xhob45wn
|
||||
yellow: r8r7jmvr
|
||||
baby: 84jvz79s
|
||||
mutant: wj83k9kh
|
||||
gelert:
|
||||
blue: 4g7n9mh5
|
||||
green: jfmwlmk8
|
||||
red: l95vq4w2
|
||||
yellow: 5nrd2lvd
|
||||
baby: c473f4o7
|
||||
maraquan: 3dzw2l8c
|
||||
mutant: 9ldnhtw5
|
||||
gnorbu:
|
||||
blue: 6c275jcg
|
||||
green: ghfgo5tn
|
||||
red: qozzjgmg
|
||||
yellow: 5lrvftfb
|
||||
baby: fzjt34mc
|
||||
mutant: bqgwjvq2
|
||||
grarrl:
|
||||
blue: j7q65fv4
|
||||
green: t3mstkl6
|
||||
red: r946sq53
|
||||
yellow: jtg67z98
|
||||
baby: g66gs7m7
|
||||
maraquan: 3dldqlj2
|
||||
mutant: 8jtbfojx
|
||||
grundo:
|
||||
blue: nwx8v2rb
|
||||
green: 5xn4kjf8
|
||||
red: qjcb6t8x
|
||||
yellow: n2g9d94f
|
||||
baby: 4sqhoksn
|
||||
maraquan: 8coxbn7v
|
||||
mutant: 9tfsvdk7
|
||||
hissi:
|
||||
blue: 7ls55f33
|
||||
green: dz5dwsbx
|
||||
red: jsfvcqwt
|
||||
yellow: z24m7h7l
|
||||
baby: fwd63758
|
||||
maraquan: z5dw7ln7
|
||||
mutant: xx8g8jjb
|
||||
ixi:
|
||||
blue: ro3qcd6s
|
||||
green: w32r74vo
|
||||
red: zs2m6862
|
||||
yellow: oggkzvq7
|
||||
baby: r6djxvxw
|
||||
maraquan: xd73hdoz
|
||||
mutant: scd2f73q
|
||||
jetsam:
|
||||
blue: w3rl2k9n
|
||||
green: cwss4w3s
|
||||
red: ghddf93g
|
||||
yellow: kz43rnld
|
||||
baby: zhz7wlxg
|
||||
mutant: m8n64bsr
|
||||
jubjub:
|
||||
blue: 8mf5gzov
|
||||
green: m267j935
|
||||
red: szckt2tj
|
||||
yellow: 78hdsnmw
|
||||
baby: 92x2bdtq
|
||||
maraquan: gj7dmvsd
|
||||
mutant: 783vj5nt
|
||||
kacheek:
|
||||
blue: tvnq2l5s
|
||||
green: fkzfcb47
|
||||
red: 9hbtocjh
|
||||
yellow: 4gsrb59g
|
||||
baby: nw424vgn
|
||||
mutant: fq6nnvwh
|
||||
kau:
|
||||
blue: ktlxmrtr
|
||||
green: x9ww69qo
|
||||
red: mrdtwkto
|
||||
yellow: 78w49w7x
|
||||
baby: qtxmt64l
|
||||
maraquan: r5fzvmtd
|
||||
mutant: 39thxh84
|
||||
kiko:
|
||||
blue: 2qlfqqnd
|
||||
green: 42j5q3zx
|
||||
red: mcodrwlt
|
||||
yellow: 86b5xdn6
|
||||
baby: d54hfwc7
|
||||
mutant: wdqnjz2z
|
||||
koi:
|
||||
blue: tjvv5cq8
|
||||
green: ncfn87wk
|
||||
red: f3wvzz6r
|
||||
yellow: 4f6cvzgh
|
||||
baby: 59lh68wg
|
||||
mutant: zoc4ntrg
|
||||
korbat:
|
||||
blue: 4qxwv7w7
|
||||
green: d2ow9co8
|
||||
red: omx9c876
|
||||
yellow: nsxodd8z
|
||||
baby: kgmnvlx8
|
||||
maraquan: 6g73dr7l
|
||||
mutant: lf98r4sb
|
||||
kougra:
|
||||
blue: rfsbh59t
|
||||
green: otvq569n
|
||||
red: x8hsckbh
|
||||
yellow: x7bbg59h
|
||||
baby: 45dwtg2f
|
||||
8-bit: 5g6fj4g8
|
||||
maraquan: 4snffcf5
|
||||
mutant: 5qt72kjo
|
||||
krawk:
|
||||
blue: hxgsm5d4
|
||||
green: 7ngw8z4f
|
||||
red: kzwxb3dn
|
||||
yellow: m2gq59r5
|
||||
baby: zgscmthd
|
||||
maraquan: kbmht6zh
|
||||
mutant: 8m94bk5w
|
||||
kyrii:
|
||||
blue: ojmo7qgg
|
||||
green: t3b8s9nz
|
||||
red: 6fvg9ngs
|
||||
yellow: blxmjgbk
|
||||
baby: 42fokwff
|
||||
maraquan: s2do4jhq
|
||||
mutant: x25ml223
|
||||
lenny:
|
||||
blue: jfc75n44
|
||||
green: 242k4kdq
|
||||
red: kc4w238d
|
||||
yellow: 8r94jhfq
|
||||
baby: k2qnttxo
|
||||
mutant: 89zgj87k
|
||||
lupe:
|
||||
blue: r552fqj8
|
||||
green: ohmx4lc9
|
||||
red: 6jwlghsg
|
||||
yellow: z42535zh
|
||||
baby: b4xfn6xv
|
||||
maraquan: fhlqw4bf
|
||||
mutant: 7ggn4k6x
|
||||
lutari:
|
||||
blue: qgg6z8s7
|
||||
green: wtjv7hw4
|
||||
red: lgws33oo
|
||||
yellow: 8x37fgjf
|
||||
baby: jnbjxvf5
|
||||
meerca:
|
||||
blue: wwwhjf88
|
||||
green: lg9bb6tf
|
||||
red: v7g8w8w6
|
||||
yellow: kk2nn2jr
|
||||
baby: 446k2fln
|
||||
maraquan: kgw5wv42
|
||||
mutant: n4nd3c4v
|
||||
moehog:
|
||||
blue: moot839l
|
||||
green: jgkoro5z
|
||||
red: dk47mfk8
|
||||
yellow: g84ovct7
|
||||
baby: 5r3oq2k4
|
||||
maraquan: 5cgov2km
|
||||
mutant: wdc9gwtq
|
||||
mynci:
|
||||
blue: xwlo9657
|
||||
green: s33qzokw
|
||||
red: f828tkrc
|
||||
yellow: tdfhsndr
|
||||
baby: 9d354534
|
||||
maraquan: 7d2ll99r
|
||||
mutant: bqtb9hsz
|
||||
nimmo:
|
||||
blue: bx7fho8x
|
||||
green: mb4mcwj5
|
||||
red: mok2fcl4
|
||||
yellow: 9559onds
|
||||
baby: nwq55xx5
|
||||
ogrin:
|
||||
blue: 26v2sx49
|
||||
green: lg5bzqkq
|
||||
red: 3xgoz429
|
||||
yellow: rjzmx24v
|
||||
baby: bfrh323n
|
||||
mutant: t6s8hrzx
|
||||
peophin:
|
||||
blue: 996t7zfg
|
||||
green: c9qo7zzt
|
||||
red: kokc52kh
|
||||
yellow: 4khvfnwl
|
||||
baby: 4jbvhghx
|
||||
mutant: bjdggzwd
|
||||
poogle:
|
||||
blue: 5n2vx7v2
|
||||
green: fw6lvf3c
|
||||
red: xhcwbdd5
|
||||
yellow: xozlhd68
|
||||
baby: b2467jkz
|
||||
maraquan: z44rk3xg
|
||||
pteri:
|
||||
blue: 82d369sm
|
||||
green: slqmqr78
|
||||
red: tjhwbro3
|
||||
yellow: 4gkkb57f
|
||||
baby: snd77sqq
|
||||
maraquan: sktvv8t7
|
||||
mutant: 57tg8jb8
|
||||
quiggle:
|
||||
blue: 4zs6b32m
|
||||
green: vbrsgqrl
|
||||
red: xrmt72wr
|
||||
yellow: jdto7mj4
|
||||
baby: 2k7wm6dx
|
||||
mutant: bv9htk44
|
||||
ruki:
|
||||
blue: qsgbm5f6
|
||||
green: vgml65cz
|
||||
red: sm55zs3q
|
||||
yellow: n43szv42
|
||||
baby: grbwvh54
|
||||
maraquan: kjx2jjcg
|
||||
mutant: hsls3rd8
|
||||
scorchio:
|
||||
blue: ohb3b486
|
||||
green: kmb82xw8
|
||||
red: hkjoncsx
|
||||
yellow: hgfofbl2
|
||||
baby: n443j7hn
|
||||
maraquan: bm9b2b73
|
||||
mutant: 3mfckmq4
|
||||
shoyru:
|
||||
blue: dj7n2zk8
|
||||
green: 3qwwn4n2
|
||||
red: 3zb2s2zw
|
||||
yellow: mmvn4tkg
|
||||
baby: xvvxvvjt
|
||||
maraquan: f57glqj6
|
||||
mutant: 49tjr4vf
|
||||
skeith:
|
||||
blue: 7c847jkn
|
||||
green: qdgwwz6c
|
||||
red: fc4cxk3t
|
||||
yellow: 533nc7rj
|
||||
baby: tjjsn83l
|
||||
maraquan: o65f8j4f
|
||||
mutant: jb8jhqqr
|
||||
techo:
|
||||
blue: vl8qro4r
|
||||
green: 2zc3vd47
|
||||
red: zgl2gjjn
|
||||
yellow: 84gvowmj
|
||||
baby: ng83vkg7
|
||||
maraquan: ln8lcbvh
|
||||
mutant: tkqgzsv3
|
||||
tonu:
|
||||
blue: jd433863
|
||||
green: 6mcv27mn
|
||||
red: oskw3hqd
|
||||
yellow: 5bhqs7sv
|
||||
baby: h6jd7kw8
|
||||
mutant: 59kr9c96
|
||||
tuskaninny:
|
||||
blue: jj6t6cqd
|
||||
green: stl4mm78
|
||||
red: 48z4o75j
|
||||
yellow: q39wn6vq
|
||||
baby: c3vhmr2m
|
||||
mutant: j2hob2sj
|
||||
uni:
|
||||
blue: 74xvb24d
|
||||
green: njzvoflw
|
||||
red: jzfbdomk
|
||||
yellow: 5qdfrtcq
|
||||
baby: st84z8xf
|
||||
maraquan: 3f3nzsjf
|
||||
mutant: qw3gsfbb
|
||||
usul:
|
||||
blue: xff976n8
|
||||
green: 5245lzmh
|
||||
red: rox4mgh5
|
||||
yellow: vxn8b4vr
|
||||
baby: 39vzk6nc
|
||||
maraquan: 8sfjr77d
|
||||
mutant: 3dgowzld
|
||||
wocky:
|
||||
blue: xonntr5f
|
||||
green: 4ssorlcs
|
||||
red: 743smd5v
|
||||
yellow: dnr2kj4b
|
||||
baby: s7tld393
|
||||
xweetok:
|
||||
blue: ddhdrt2o
|
||||
green: thzwbqsq
|
||||
red: tdkqr2b6
|
||||
yellow: o36btnbf
|
||||
baby: wwh2wvkn
|
||||
mutant: qs53ohzt
|
||||
yurble:
|
||||
blue: nhn5lxb4
|
||||
green: mjgbr7vb
|
||||
red: h95cs547
|
||||
yellow: vfqkbvv6
|
||||
baby: 8b8fvxo2
|
||||
mutant: 5o5t2j3s
|
||||
zafara:
|
||||
blue: x8c57g2l
|
||||
green: tq56zj3x
|
||||
red: n32sgrvm
|
||||
yellow: onxr95x6
|
||||
baby: 93c22wgn
|
||||
maraquan: b2gxlo5h
|
||||
mutant: 9c9frk9g
|
||||
|
|
5
config/colors_with_unique_bodies.txt
Normal file
5
config/colors_with_unique_bodies.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
8-Bit
|
||||
Baby
|
||||
Maraquan
|
||||
Mutant
|
||||
|
Loading…
Reference in a new issue