diff --git a/migrations/20130327_apply_tokens.js b/migrations/20130327_apply_tokens.js new file mode 100644 index 0000000000..5f62f55ac3 --- /dev/null +++ b/migrations/20130327_apply_tokens.js @@ -0,0 +1,72 @@ +/** + * Applies backer tokens & items (this file will be updated periodically + */ + +// mongo habitrpg ./node_modules/underscore/underscore.js migrations/20130327_apply_tokens.js + +var mapping = [ + { // $1 + tokens: 0, + users: [] + }, + { // $5 + tokens: 20, + users: ['9'] + }, + { // $10 + tokens: 50, + users: [] + }, + { // $15 + tokens: 100, + users: [] + }, + { // $30 + tokens: 150, + users: [] + }, + { // $45 + tokens: 170, + users: [] + }, + { // $60 + tokens: 200, + users: [] + }, + { // $70 + tokens: 240, + users: [] + }, + { // $80 + tokens: 240, + users: [] + }, + { // $90 + tokens: 280, + users: [] + }, + { // $300 + tokens: 500, + users: [] + }, + { // $800 + tokens: 500, + users: [] + } +]; + +_.each(mapping, function(tier){ + db.users.update( + { + _id: { $in: tier.users }, + 'backer.tokensApplied': { $exists: false } + }, + + { + $set: { 'backer.tokensApplied': true, 'flags.ads': 'hide' }, + $inc: { balance: (tier.tokens/4) } + }, + + { multi: true} + ) +}) diff --git a/package.json b/package.json index 40f0d85c07..742fab8c50 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "moment": "*", "stripe": "*", "async": "*", - "lodash": "*", + "lodash": "1.0.x", "coffee-script": "1.4.x", "underscore": "*", "mongoskin": "*", diff --git a/public/img/sprites/PetEggs.css b/public/img/sprites/PetEggs.css index 818752b301..9927bb3531 100644 --- a/public/img/sprites/PetEggs.css +++ b/public/img/sprites/PetEggs.css @@ -1,4 +1,4 @@ -.Pet_Egg_Wolf, .Pet_Egg_TigerCub, .Pet_Egg_PolarBear, .Pet_Egg_PandaCub, .Pet_Egg_LionCub, .Pet_Egg_Fox, .Pet_Egg_FlyingPig, .Pet_Egg_Dragon, .Pet_Egg_Cactus, .Pet_Egg_BearCub, .Item_HatchingPotion_Basic, .Item_HatchingPotion_White, .Item_HatchingPotion_Desert, .Item_HatchingPotion_Red, .Item_HatchingPotion_Shade, .Item_HatchingPotion_Skeleton {background: url("/img/sprites/Egg_Sprite_Sheet.png") no-repeat} +.Pet_Egg_Wolf, .Pet_Egg_TigerCub, .Pet_Egg_PolarBear, .Pet_Egg_PandaCub, .Pet_Egg_LionCub, .Pet_Egg_Fox, .Pet_Egg_FlyingPig, .Pet_Egg_Dragon, .Pet_Egg_Cactus, .Pet_Egg_BearCub, .Pet_HatchingPotion_Base, .Pet_HatchingPotion_White, .Pet_HatchingPotion_Desert, .Pet_HatchingPotion_Red, .Pet_HatchingPotion_Shade, .Pet_HatchingPotion_Skeleton, .Pet_HatchingPotion_Zombie, .Pet_HatchingPotion_CottonCandyPink, .Pet_HatchingPotion_CottonCandyBlue, .Pet_HatchingPotion_Golden {background: url("/img/sprites/Egg_Sprite_Sheet.png") no-repeat} .Pet_Egg_Wolf {background-position: 0px 0px; width: 48px; height: 51px} .Pet_Egg_TigerCub {background-position: 0px -51px; width: 48px; height: 51px} .Pet_Egg_PolarBear {background-position: 0px -102px; width: 48px; height: 51px} @@ -9,9 +9,25 @@ .Pet_Egg_Dragon {background-position: 0px -357px; width: 48px; height: 51px} .Pet_Egg_Cactus {background-position: 0px -408px; width: 48px; height: 51px} .Pet_Egg_BearCub {background-position: 0px -459px; width: 48px; height: 51px} -.Item_HatchingPotion_Basic {background-position: -48px -0px; width: 48px; height: 51px} -.Item_HatchingPotion_White {background-position: -48px -51px; width: 48px; height: 51px} -.Item_HatchingPotion_Desert {background-position: -48px -102px; width: 48px; height: 51px} -.Item_HatchingPotion_Red {background-position: -48px -153px; width: 48px; height: 51px} -.Item_HatchingPotion_Shade {background-position: -48px -204px; width: 48px; height: 51px} -.Item_HatchingPotion_Skeleton {background-position: -48px -255px; width: 48px; height: 51px} + +.Pet_HatchingPotion_Base {background-position: -48px -0px; width: 48px; height: 51px} +.Pet_HatchingPotion_White {background-position: -48px -51px; width: 48px; height: 51px} +.Pet_HatchingPotion_Desert {background-position: -48px -102px; width: 48px; height: 51px} +.Pet_HatchingPotion_Red {background-position: -48px -153px; width: 48px; height: 51px} +.Pet_HatchingPotion_Shade {background-position: -48px -204px; width: 48px; height: 51px} +.Pet_HatchingPotion_Skeleton {background-position: -48px -255px; width: 48px; height: 51px} + +/* Temporary until we get the other hatching potions */ +.Pet_HatchingPotion_Zombie, .Pet_HatchingPotion_CottonCandyPink, .Pet_HatchingPotion_CottonCandyBlue, .Pet_HatchingPotion_Golden {background-position: -48px -0px; width: 48px; height: 51px} +.Pet_HatchingPotion_Zombie { + -webkit-filter: invert(1); +} +.Pet_HatchingPotion_CottonCandyPink { + -webkit-filter: hue-rotate(120deg); +} +.Pet_HatchingPotion_CottonCandyBlue { + -webkit-filter: saturate(3); +} +.Pet_HatchingPotion_Golden { + -webkit-filter: hue-rotate(220deg); +} diff --git a/src/app/items.coffee b/src/app/items.coffee index 0a0ee7aa70..9f15bb3908 100644 --- a/src/app/items.coffee +++ b/src/app/items.coffee @@ -38,19 +38,19 @@ items = module.exports.items = reroll: {type: 'reroll', text: "Re-Roll", classes: 'reroll', notes: "Resets your task values back to 0 (yellow). Useful when everything's red and it's hard to stay alive.", value:0 } pets: [ - {text: 'Wolf', name: 'Wolf', value: 2} - {text: 'Tiger Cub', name: 'TigerCub', value: 2} + {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: 2} - {text: 'Lion Cub', name: 'LionCub', value: 2} - {text: 'Fox', name: 'Fox', value: 2} - {text: 'Flying Pig', name: 'FlyingPig', value: 2} - {text: 'Dragon', name: 'Dragon', value: 2} - {text: 'Cactus', name: 'Cactus', value: 2} - {text: 'Bear Cub', name: 'BearCub', value: 2} + {text: 'Panda Cub', name: 'PandaCub', value: 3} + {text: 'Lion Cub', name: '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: [ + hatchingPotions: [ {text: 'Common', name: 'Base', notes: "Hatches your pet in it's base form.", value: 1} {text: 'White', name: 'White', notes: 'Turns your animal into a White pet.', value: 2} {text: 'Desert', name: 'Desert', notes: 'Turns your animal into a Desert pet.', value: 2} @@ -67,8 +67,8 @@ items = module.exports.items = _.each ['weapon', 'armor', 'head', 'shield'], (key) -> _.each items[key], (item) -> item.type = key -_.each items.pets, (pet) -> pet.notes = 'Find some Hatching Powder to sprinkle on this egg, and one day it will hatch into a loyal pet.' -_.each items.food, (food) -> food.notes = "Sprinkle this on an egg, and it will hatch as a #{food.text} pet." +_.each items.pets, (pet) -> pet.notes = 'Find a hatching potion to pour on this egg, and one day it will hatch into a loyal pet.' +_.each items.hatchingPotions, (hatchingPotion) -> hatchingPotion.notes = "Pour this on an egg, and it will hatch as a #{hatchingPotion.text} pet." ### view exports @@ -204,7 +204,7 @@ module.exports.updateStore = updateStore = (model) -> model.set '_view.items.potion', items.potion model.set '_view.items.reroll', items.reroll model.set '_view.items.pets', items.pets - model.set '_view.items.food', items.food + model.set '_view.items.hatchingPotions', items.hatchingPotions diff --git a/src/app/pets.coffee b/src/app/pets.coffee index 5e46067536..93d11d703e 100644 --- a/src/app/pets.coffee +++ b/src/app/pets.coffee @@ -1,6 +1,6 @@ _ = require 'underscore' { randomVal } = require './helpers' -{ pets, food } = require('./items').items +{ pets, hatchingPotions } = require('./items').items ### app exports @@ -22,33 +22,33 @@ module.exports.app = (appExports, model) -> $('#drops-enabled-modal').modal 'show' appExports.chooseEgg = (e, el) -> - model.ref '_feedEgg', e.at() + model.ref '_hatchEgg', e.at() - appExports.feedEgg = (e, el) -> - foodName = $(el).children('select').val() - myFood = user.get 'items.food' - egg = model.get '_feedEgg' + appExports.hatchEgg = (e, el) -> + hatchingPotionName = $(el).children('select').val() + myHatchingPotion = user.get 'items.hatchingPotions' + egg = model.get '_hatchEgg' eggs = user.get 'items.eggs' myPets = user.get 'items.pets' - foodIdx = myFood.indexOf foodName + hatchingPotionIdx = myHatchingPotion.indexOf hatchingPotionName eggIdx = eggs.indexOf egg - return alert "You don't own that food :\\" if foodIdx is -1 - return alert "You don't own that egg :\\" if eggIdx is -1 - return alert "You already have that pet." if myPets and myPets.indexOf("#{egg.name}-#{foodName}") != -1 + return alert "You don't own that hatching potion yet, complete more tasks!" if hatchingPotionIdx is -1 + return alert "You don't own that egg yet, complete more tasks!" if eggIdx is -1 + return alert "You already have that pet, hatch a different combo." if myPets and myPets.indexOf("#{egg.name}-#{hatchingPotionName}") != -1 - user.push 'items.pets', egg.name + '-' + foodName + user.push 'items.pets', egg.name + '-' + hatchingPotionName eggs.splice eggIdx, 1 - myFood.splice foodIdx, 1 + myHatchingPotion.splice hatchingPotionIdx, 1 user.set 'items.eggs', eggs - user.set 'items.food', myFood + user.set 'items.hatchingPotions', myHatchingPotion alert 'Your egg hatched! Visit your stable to equip your pet.' #FIXME Bug: this removes from the array properly in the browser, but on refresh is has removed all items from the arrays -# user.remove 'items.food', foodIdx, 1 +# user.remove 'items.hatchingPotions', hatchingPotionIdx, 1 # user.remove 'items.eggs', eggIdx, 1 appExports.choosePet = (e, el) -> @@ -63,14 +63,14 @@ module.exports.app = (appExports, model) -> pet = {} if user.get('items.currentPet.str') is petStr user.set 'items.currentPet', pet - appExports.buyFood = (e, el) -> - name = $(el).attr 'data-food' - newFood = _.findWhere food, name: name + appExports.buyHatchingPotion = (e, el) -> + name = $(el).attr 'data-hatchingPotion' + newHatchingPotion = _.findWhere hatchingPotions, name: name tokens = user.get('balance') * 4 - if tokens > newFood.value - if confirm "Buy this food with #{newFood.value} of your #{tokens} tokens?" - user.push 'items.food', newFood.name - user.set 'balance', (tokens - newFood.value) / 4 + if tokens > newHatchingPotion.value + if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{tokens} tokens?" + user.push 'items.hatchingPotions', newHatchingPotion.name + user.set 'balance', (tokens - newHatchingPotion.value) / 4 else $('#more-tokens-modal').modal 'show' diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 1877f34266..6c6d481893 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' browser = require './browser' character = require './character' items = require './items' -{ pets, food } = items.items +{ pets, hatchingPotions } = items.items algos = require './algos' MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this mechanism will change) @@ -29,7 +29,7 @@ randomDrop = (model, delta) -> chanceMultiplier *= Math.abs(delta) # multiply chance by reddness if user.get('flags.dropsEnabled') and Math.random() < (.01 * chanceMultiplier) # current breakdown - 3% (adjustable) chance on drop - # If they got a drop: 50% chance of egg, 50% Food. If food, broken down further even further + # If they got a drop: 50% chance of egg, 50% Hatching Potion. If hatchingPotion, broken down further even further rarity = Math.random() # Egg, 40% chance @@ -39,7 +39,7 @@ randomDrop = (model, delta) -> drop.type = 'Egg' drop.dialog = "You've found a #{drop.text} Egg! #{drop.notes}" - # Food, 60% chance - break down by rarity even more. FIXME this may not be the best method, so revisit + # Hatching Potion, 60% chance - break down by rarity even more. FIXME this may not be the best method, so revisit else acceptableDrops = [] @@ -62,11 +62,11 @@ randomDrop = (model, delta) -> else acceptableDrops = ['Base'] - acceptableDrops = _.filter(food, (foodItem) -> foodItem.name in acceptableDrops) + acceptableDrops = _.filter(hatchingPotions, (hatchingPotion) -> hatchingPotion.name in acceptableDrops) drop = randomVal acceptableDrops - user.push 'items.food', drop.name - drop.type = 'Food' - drop.dialog = "You've found #{drop.text} Hatching Powder! #{drop.notes}" + user.push 'items.hatchingPotions', drop.name + drop.type = 'HatchingPotion' + drop.dialog = "You've found a #{drop.text} Hatching Potion! #{drop.notes}" model.set '_drop', drop $('#item-dropped-modal').modal 'show' diff --git a/styles/app/inventory.styl b/styles/app/inventory.styl index a3a6d03f2f..4ae647a728 100644 --- a/styles/app/inventory.styl +++ b/styles/app/inventory.styl @@ -46,5 +46,5 @@ clear:both .pets-menu > div float:left -.food-menu > div +.hatchingPotions-menu > div float:left diff --git a/views/app/avatar.html b/views/app/avatar.html index 0755694ff2..82a98b407a 100644 --- a/views/app/avatar.html +++ b/views/app/avatar.html @@ -249,24 +249,24 @@ {/} -

Hatching Powder

- {#with _view.items.food as :food} +

Hatching Potions

+ {#with _view.items.hatchingPotions as :hatchingPotion} - {#with :food[0]}{/} - {#with :food[1]}{/} - {#with :food[2]}{/} - {#with :food[3]}{/} + {#with :hatchingPotion[0]}{/} + {#with :hatchingPotion[1]}{/} + {#with :hatchingPotion[2]}{/} + {#with :hatchingPotion[3]}{/} - {#with :food[4]}{/} - {#with :food[5]}{/} - {#with :food[6]}{/} - {#with :food[7]}{/} + {#with :hatchingPotion[4]}{/} + {#with :hatchingPotion[5]}{/} + {#with :hatchingPotion[6]}{/} + {#with :hatchingPotion[7]}{/} - {#with :food[8]}{/} - {#with :food[9]}{/} + {#with :hatchingPotion[8]}{/} + {#with :hatchingPotion[9]}{/}
{/} diff --git a/views/app/pets.html b/views/app/pets.html index 173f43c899..51e7896471 100644 --- a/views/app/pets.html +++ b/views/app/pets.html @@ -21,15 +21,15 @@ - - -
+ + +
{.text} - -
+ +
{.text} @@ -38,10 +38,10 @@
  • - {#if not(_user.items.eggs)} -

    You don't have any eggs yet.

    - {/if} + {#if not(_user.items.eggs)} +

    You don't have any eggs yet.

    + {/if} {#each _user.items.eggs as :egg}
    @@ -51,31 +51,31 @@
  • - {#if not(_user.items.food)} -

    You don't have any hatching powder yet.

    - {/if} - - {#each _user.items.food as :food} + + {#if not(_user.items.hatchingPotions)} +

    You don't have any hatching potions yet.

    + {/if} + {#each _user.items.hatchingPotions as :hatchingPotion}
    - -

    {:food}

    + +

    {:hatchingPotion}

    {/each}
  • - {#if _feedEgg} + {#if _hatchEgg}

    Hatch Your Egg

    - {#if not(_user.items.food)} -

    You don't have any hatching powder yet.

    + {#if not(_user.items.hatchingPotions)} +

    You don't have any hatching potions yet.

    {else} -

    What would you like to sprinkle on your {_feedEgg.text} egg?

    -
    +

    Which hatching potion will you pour on your {_hatchEgg.text} egg?

    +