From 65b7f432a9bb69f98754c4635f252dfa0f60384f Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 9 Mar 2013 12:03:38 -0500 Subject: [PATCH] get the pets working for the avatar box, with consistent names (need to manually apply with model.set for now) --- public/img/sprites/pet_sprites.css | 2 +- src/app/items.coffee | 56 +++++++++++------------------- src/app/pets.coffee | 18 ++++++++++ styles/app/index.styl | 1 + views/app/avatar.html | 4 ++- 5 files changed, 43 insertions(+), 38 deletions(-) diff --git a/public/img/sprites/pet_sprites.css b/public/img/sprites/pet_sprites.css index 6ff97ca445..b13ae3206c 100644 --- a/public/img/sprites/pet_sprites.css +++ b/public/img/sprites/pet_sprites.css @@ -1,4 +1,4 @@ -.Pet-Wolf-Zombie, .Pet-Wolf-White, .Pet-Wolf-Veteran, .Pet-Wolf-Skeleton, .Pet-Wolf-Shade, .Pet-Wolf-Red, .Pet-Wolf-Golden, .Pet-Wolf-Desert, .Pet-Wolf-CottonCandyPink, .Pet-Wolf-CottonCandyBlue, .Pet-TigerCub-Zombie, .Pet-TigerCub-White, .Pet-TigerCub-Skeleton, .Pet-TigerCub-Shade, .Pet-TigerCub-Red, .Pet-TigerCub-Golden, .Pet-TigerCub-Desert, .Pet-TigerCub-CottonCandyPink, .Pet-TigerCub-CottonCandyBlue, .Pet-TigerCub-Base, .Pet-PolarBearCub-Base, .Pet-PandaCub-Zombie, .Pet-PandaCub-White, .Pet-PandaCub-Skeleton, .Pet-PandaCub-Shade, .Pet-PandaCub-Red, .Pet-PandaCub-Golden, .Pet-PandaCub-Desert, .Pet-PandaCub-CottonCandyPink, .Pet-PandaCub-CottonCandyBlue, .Pet-PandaCub-Base, .Pet-LionCub-Zombie, .Pet-LionCub-White, .Pet-LionCub-Skeleton, .Pet-LionCub-Shade, .Pet-LionCub-Red, .Pet-LionCub-Golden, .Pet-LionCub-Desert, .Pet-LionCub-CottonCandyPink, .Pet-LionCub-CottonCandyBlue, .Pet-LionCub-Base, .Pet-Fox-Zombie, .Pet-Fox-White, .Pet-Fox-Skeleton, .Pet-Fox-Shade, .Pet-Fox-Red, .Pet-Fox-Golden, .Pet-Fox-Desert, .Pet-Fox-CottonCandyPink, .Pet-Fox-CottonCandyBlue, .Pet-Fox-Base, .Pet-FlyingPig-Zombie, .Pet-FlyingPig-White, .Pet-FlyingPig-Skeleton, .Pet-FlyingPig-Shade, .Pet-FlyingPig-Red, .Pet-FlyingPig-Golden, .Pet-FlyingPig-Desert, .Pet-FlyingPig-CottonCandyPink, .Pet-FlyingPig-CottonCandyBlue, .Pet-FlyingPig-Base, .Pet-Dragon-Zombie, .Pet-Dragon-White, .Pet-Dragon-Skeleton, .Pet-Dragon-Shade, .Pet-Dragon-Red, .Pet-Dragon-Golden, .Pet-Dragon-Desert, .Pet-Dragon-CottonCandyPink, .Pet-Dragon-CottonCandyBlue, .Pet-Dragon-Base, .Pet-Cactus-SugarCube, .Pet-Cactus-Strawberry, .Pet-Cactus-Rotten, .Pet-Cactus-Licorice, .Pet-Cactus-Golden, .Pet-Cactus-Cream, .Pet-Cactus-CottonCandyPink, .Pet-Cactus-CottonCandyBlue, .Pet-Cactus-Chocolate, .Pet-Cactus-Base, .Pet-BearCub-Zombie, .Pet-BearCub-White, .Pet-BearCub-Skeleton, .Pet-BearCub-Shade, .Pet-BearCub-Red, .Pet-BearCub-Golden, .Pet-BearCub-Desert, .Pet-BearCub-CottonCandyPink, .Pet-BearCub-CottonCandyBlue, .Pet-BearCub-Base {background: url(pet_sprites.png) no-repeat} +.Pet-Wolf-Zombie, .Pet-Wolf-White, .Pet-Wolf-Veteran, .Pet-Wolf-Skeleton, .Pet-Wolf-Shade, .Pet-Wolf-Red, .Pet-Wolf-Golden, .Pet-Wolf-Desert, .Pet-Wolf-CottonCandyPink, .Pet-Wolf-CottonCandyBlue, .Pet-TigerCub-Zombie, .Pet-TigerCub-White, .Pet-TigerCub-Skeleton, .Pet-TigerCub-Shade, .Pet-TigerCub-Red, .Pet-TigerCub-Golden, .Pet-TigerCub-Desert, .Pet-TigerCub-CottonCandyPink, .Pet-TigerCub-CottonCandyBlue, .Pet-TigerCub-Base, .Pet-PolarBearCub-Base, .Pet-PandaCub-Zombie, .Pet-PandaCub-White, .Pet-PandaCub-Skeleton, .Pet-PandaCub-Shade, .Pet-PandaCub-Red, .Pet-PandaCub-Golden, .Pet-PandaCub-Desert, .Pet-PandaCub-CottonCandyPink, .Pet-PandaCub-CottonCandyBlue, .Pet-PandaCub-Base, .Pet-LionCub-Zombie, .Pet-LionCub-White, .Pet-LionCub-Skeleton, .Pet-LionCub-Shade, .Pet-LionCub-Red, .Pet-LionCub-Golden, .Pet-LionCub-Desert, .Pet-LionCub-CottonCandyPink, .Pet-LionCub-CottonCandyBlue, .Pet-LionCub-Base, .Pet-Fox-Zombie, .Pet-Fox-White, .Pet-Fox-Skeleton, .Pet-Fox-Shade, .Pet-Fox-Red, .Pet-Fox-Golden, .Pet-Fox-Desert, .Pet-Fox-CottonCandyPink, .Pet-Fox-CottonCandyBlue, .Pet-Fox-Base, .Pet-FlyingPig-Zombie, .Pet-FlyingPig-White, .Pet-FlyingPig-Skeleton, .Pet-FlyingPig-Shade, .Pet-FlyingPig-Red, .Pet-FlyingPig-Golden, .Pet-FlyingPig-Desert, .Pet-FlyingPig-CottonCandyPink, .Pet-FlyingPig-CottonCandyBlue, .Pet-FlyingPig-Base, .Pet-Dragon-Zombie, .Pet-Dragon-White, .Pet-Dragon-Skeleton, .Pet-Dragon-Shade, .Pet-Dragon-Red, .Pet-Dragon-Golden, .Pet-Dragon-Desert, .Pet-Dragon-CottonCandyPink, .Pet-Dragon-CottonCandyBlue, .Pet-Dragon-Base, .Pet-Cactus-SugarCube, .Pet-Cactus-Strawberry, .Pet-Cactus-Rotten, .Pet-Cactus-Licorice, .Pet-Cactus-Golden, .Pet-Cactus-Cream, .Pet-Cactus-CottonCandyPink, .Pet-Cactus-CottonCandyBlue, .Pet-Cactus-Chocolate, .Pet-Cactus-Base, .Pet-BearCub-Zombie, .Pet-BearCub-White, .Pet-BearCub-Skeleton, .Pet-BearCub-Shade, .Pet-BearCub-Red, .Pet-BearCub-Golden, .Pet-BearCub-Desert, .Pet-BearCub-CottonCandyPink, .Pet-BearCub-CottonCandyBlue, .Pet-BearCub-Base {background: url("/img/sprites/pet_sprites.png") no-repeat} .Pet-Wolf-Zombie {background-position: 0 0; width: 81px; height: 99px} .Pet-Wolf-White {background-position: -81px 0; width: 81px; height: 99px} .Pet-Wolf-Veteran {background-position: -162px 0; width: 81px; height: 99px} diff --git a/src/app/items.coffee b/src/app/items.coffee index 064ea226f6..62963d7d6a 100644 --- a/src/app/items.coffee +++ b/src/app/items.coffee @@ -38,29 +38,29 @@ items = module.exports.items = reroll: {type: 'reroll', text: "Re-Roll", classes: 'reroll', notes: "Resets your tasks. When you're struggling and everything's red, use for a clean slate.", value:0 } pets: [ - {text: 'Wolf', classes: 'Wolf', value: 3} - {text: 'Tiger Cub', classes: 'TigerCub', value: 3} - #{text: 'Polar Bear Cub', classes: 'PolarBearCub', value: 3} #commented out because there are no polarbear modifiers yet, special drop? - {text: 'Panda Cub', classes: 'PandaCub', value: 3} - {text: 'Lion Cub', classes: 'LionCub', value: 3} - {text: 'Fox', classes: 'Fox', value: 3} - {text: 'Flying Pig', classes: 'FlyingPig', value: 3} - {text: 'Dragon', classes: 'Dragon', value: 3} - {text: 'Cactus', classes: 'Cactus', value: 3} - {text: 'Bear Cub', classes: 'BearCub', value: 3} + {text: 'Wolf', name: 'Wolf', value: 3} + {text: 'Tiger Cub', name: 'TigerCub', value: 3} + #{text: 'Polar Bear Cub', name: 'PolarBearCub', value: 3} #commented out because there are no polarbear modifiers yet, special drop? + {text: 'Panda Cub', name: 'PandaCub', value: 3} + {text: 'Lion Cub', id: 'LionCub', value: 3} + {text: 'Fox', name: 'Fox', value: 3} + {text: 'Flying Pig', name: 'FlyingPig', value: 3} + {text: 'Dragon', name: 'Dragon', value: 3} + {text: 'Cactus', name: 'Cactus', value: 3} + {text: 'Bear Cub', name: 'BearCub', value: 3} ] food: [ - {text: 'Zombie', classes: 'Zombie', notes: 'Turns your animal into a Zombie.', value: 3} - {text: 'White', classes: 'White', notes: 'Turns your animal into a White.', value: 3} - {text: 'Veteran', classes: 'Veteran', notes: 'Turns your animal into a Veteran.', value: 3} - {text: 'Skeleton', classes: 'Skeleton', notes: 'Turns your animal into a Skeleton.', value: 3} - {text: 'Shade', classes: 'Shade', notes: 'Turns your animal into a Shade.', value: 3} - {text: 'Red', classes: 'Red', notes: 'Turns your animal into a Red.', value: 3} - {text: 'Golden', classes: 'Golden', notes: 'Turns your animal into a Golden.', value: 3} - {text: 'Desert', classes: 'Desert', notes: 'Turns your animal into a Desert.', value: 3} - {text: 'CottonCandyPink', classes: 'CottonCandyPink', notes: 'Turns your animal into a CottonCandyPink.', value: 3} - {text: 'CottonCandyBlue', classes: 'CottonCandyBlue', notes: 'Turns your animal into a CottonCandyBlue.', value: 3} + {text: 'Zombie', name: 'Zombie', notes: 'Turns your animal into a Zombie.', value: 3} + {text: 'White', name: 'White', notes: 'Turns your animal into a White.', value: 3} + {text: 'Veteran', name: 'Veteran', notes: 'Turns your animal into a Veteran.', value: 3} + {text: 'Skeleton', name: 'Skeleton', notes: 'Turns your animal into a Skeleton.', value: 3} + {text: 'Shade', name: 'Shade', notes: 'Turns your animal into a Shade.', value: 3} + {text: 'Red', name: 'Red', notes: 'Turns your animal into a Red.', value: 3} + {text: 'Golden', name: 'Golden', notes: 'Turns your animal into a Golden.', value: 3} + {text: 'Desert', name: 'Desert', notes: 'Turns your animal into a Desert.', value: 3} + {text: 'CottonCandyPink', name: 'CottonCandyPink', notes: 'Turns your animal into a CottonCandyPink.', value: 3} + {text: 'CottonCandyBlue', name: 'CottonCandyBlue', notes: 'Turns your animal into a CottonCandyBlue.', value: 3} ] # add "type" to each item, so we can reference that as "weapon" or "armor" in the html @@ -147,22 +147,6 @@ module.exports.app = (appExports, model) -> hp = 50 if hp > 50 user.set 'stats.hp', hp - appExports.selectPet = (e, el) -> - name = $(el).attr('data-pet') - pet = _.find items.pets, (p) -> p.name == name - debugger - if user.get "items.pets.#{name}" - user.set 'items.pet', pet - else - tokens = user.get('balance')*4 - if tokens > pet.value - r = confirm("Buy this pet with #{pet.value} of your #{tokens} tokens?"); - if r - user.set "items.pets.#{name}", true - user.set 'items.pet', pet - user.set 'balance', (tokens-pet.value)/4 - else - $('#more-tokens-modal').modal('show') appExports.activateRewardsTab = -> model.set '_view.activeTabRewards', true diff --git a/src/app/pets.coffee b/src/app/pets.coffee index a7860ea057..c36c7943d6 100644 --- a/src/app/pets.coffee +++ b/src/app/pets.coffee @@ -17,3 +17,21 @@ module.exports.app = (appExports, model) -> # do drops enabled stuff $('#dropsEnabled-modal').show() + + + appExports.selectPet = (e, el) -> + name = $(el).attr('data-pet') + pet = _.findWhere pets, {name:name} + ownsThisPet = user.get('items.pets').indexOf(name) + if ownsThisPet != -1 + user.set 'items.currentPet', pet + else + tokens = user.get('balance')*4 + if tokens > pet.value + r = confirm("Buy this pet with #{pet.value} of your #{tokens} tokens?"); + if r + user.push "items.pets", name + user.set 'items.currentPet', pet + user.set 'balance', (tokens - pet.value)/4 + else + $('#more-tokens-modal').modal('show') diff --git a/styles/app/index.styl b/styles/app/index.styl index 406f26d74e..0bac051f6f 100644 --- a/styles/app/index.styl +++ b/styles/app/index.styl @@ -7,6 +7,7 @@ @import "./customizer.styl"; @import "./items.styl"; @import "./alerts.styl"; +@import "../../public/img/sprites/pet_sprites.css"; @import "../../public/vendor/bootstrap-datepicker/css/datepicker.css"; diff --git a/views/app/avatar.html b/views/app/avatar.html index 87c08073ff..6c52c7dfa7 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -32,8 +32,10 @@
- {#unless @minimal}{#if @profile.items.pet}{/}{/}
+ {#unless @minimal}{#if @profile.items.currentPet} + + {/}{/} {#with @profile.preferences as :p}