From 389b5b370a7502b90087910725a92bd3792434b6 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 21 Sep 2015 17:12:23 -0400 Subject: [PATCH] feat(pets): Magic Hatching Potions WIP --- common/locales/en/content.json | 1 + common/script/content/index.coffee | 17 +++++++++++------ common/script/index.coffee | 2 +- test/common/count.js | 21 ++++++++++++++++++++- test/spec/services/statServicesSpec.js | 14 +++++++++----- website/views/options/inventory/drops.jade | 2 +- website/views/options/inventory/mounts.jade | 7 +++---- website/views/options/inventory/pets.jade | 6 +++--- 8 files changed, 49 insertions(+), 21 deletions(-) diff --git a/common/locales/en/content.json b/common/locales/en/content.json index 279c7b5562..4220c77ddc 100644 --- a/common/locales/en/content.json +++ b/common/locales/en/content.json @@ -114,6 +114,7 @@ "hatchingPotionCottonCandyPink": "Cotton Candy Pink", "hatchingPotionCottonCandyBlue": "Cotton Candy Blue", "hatchingPotionGolden": "Golden", + "hatchingPotionSpooky": "Spooky", "hatchingPotionNotes": "Pour this on an egg, and it will hatch as a <%= potText(locale) %> pet.", diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index b2ef3a9798..fb3eded07b 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -1165,25 +1165,30 @@ api.hatchingPotions = CottonCandyPink: value: 4, text: t('hatchingPotionCottonCandyPink') CottonCandyBlue: value: 4, text: t('hatchingPotionCottonCandyBlue') Golden: value: 5, text: t('hatchingPotionGolden') + Spooky: value: 3, text: t('hatchingPotionSpooky'), premium: true + _.each api.hatchingPotions, (pot,key) -> - _.defaults pot, {key, value: 2, notes: t('hatchingPotionNotes', {potText: pot.text})} + _.defaults pot, {key, value: 2, notes: t('hatchingPotionNotes', {potText: pot.text}), premium: false, canBuy: true} api.pets = _.transform api.dropEggs, (m, egg) -> _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true + if not pot.premium + m2[egg.key + "-" + pot.key] = true api.questPets = _.transform api.questEggs, (m, egg) -> _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true + if not pot.premium + m2[egg.key + "-" + pot.key] = true -## added for mountmaster -- yes, the transforms are correct, since the same strings are used for both pets and mounts api.mounts = _.transform api.dropEggs, (m, egg) -> _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true + if not pot.premium + m2[egg.key + "-" + pot.key] = true api.questMounts = _.transform api.questEggs, (m, egg) -> _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> - m2[egg.key + "-" + pot.key] = true + if not pot.premium + m2[egg.key + "-" + pot.key] = true api.food = # Base diff --git a/common/script/index.coffee b/common/script/index.coffee index d59b5a9828..3672e584e1 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -766,7 +766,7 @@ api.wrap = (user, main=true) -> if food.key is 'Saddle' evolve() else - if food.target is potion + if food.target is potion or content.hatchingPotions[potion].premium userPets[pet] += 5 message = i18n.t('messageLikesFood', {egg: petDisplayName, foodText: food.text(req.language)}, req.language) else diff --git a/test/common/count.js b/test/common/count.js index ddf45faae9..fc4fac6dca 100644 --- a/test/common/count.js +++ b/test/common/count.js @@ -6,7 +6,7 @@ var expect = chai.expect require('coffee-script'); var count = require('../../common/script/count'); -describe('count', function() { +describe.only('count', function() { describe('beastMasterProgress', function() { it('returns 0 if no pets', function() { var pets = {}; @@ -26,6 +26,16 @@ describe('count', function() { expect(beastMasterTotal).to.eql(1); }); + it('does not count pets hatched with premium potions', function() { + var pets = { + "Wolf-Spooky": 5, + "Dragon-Spooky": 5, + "FlyingPig-Base": 5 + } + var beastMasterTotal = count.beastMasterProgress(pets); + expect(beastMasterTotal).to.eql(1); + }); + it('does not count special pets', function() { var pets = { "Wolf-Base": 2, @@ -65,6 +75,15 @@ describe('count', function() { expect(mountMasterTotal).to.eql(2); }); + it('does not count premium mounts', function() { + var mounts = { + "Dragon-Red": true, + "FlyingPig-Spooky": true + } + var mountMasterTotal = count.mountMasterProgress(mounts); + expect(mountMasterTotal).to.eql(1); + }); + it('does not count quest mounts', function() { var mounts = { "Dragon-Red": true, "Gryphon-Base": true }; var mountMasterTotal = count.mountMasterProgress(mounts); diff --git a/test/spec/services/statServicesSpec.js b/test/spec/services/statServicesSpec.js index 8a1694b16a..d688be23fb 100644 --- a/test/spec/services/statServicesSpec.js +++ b/test/spec/services/statServicesSpec.js @@ -24,7 +24,8 @@ describe('Stats Service', function() { "Deer-Golden" : 5, "Deer-Red" : 5, "Egg-Desert" : 5, - "MantisShrimp-Base" : 5 + "MantisShrimp-Base" : 5, + "Wolf-Spooky": 5 } var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets); @@ -38,9 +39,10 @@ describe('Stats Service', function() { "BearCub-CottonCandyBlue" : -1, "Cactus-Zombie" : 5, "Deer-Golden" : 5, - "Deer-Red" : 5, + "Deer-Red" : -1, "Egg-Desert" : 5, - "MantisShrimp-Base" : 5 + "MantisShrimp-Base" : 5, + "Wolf-Spooky": -1 } var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets); @@ -221,7 +223,8 @@ describe('Stats Service', function() { "Wolf-Golden" : true, "Owl-CottonCandyBlue" : true, "Mammoth-Base" : true, - "Bunny-Skeleton" : true + "Bunny-Skeleton" : true, + "Tiger-Spooky": true } var mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts); @@ -237,7 +240,8 @@ describe('Stats Service', function() { "Wolf-Golden" : false, "Owl-CottonCandyBlue" : true, "Mammoth-Base" : true, - "Bunny-Skeleton" : true + "Bunny-Skeleton" : true, + "Tiger-Spooky": true } var mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts); diff --git a/website/views/options/inventory/drops.jade b/website/views/options/inventory/drops.jade index 86b10aedee..7812aece22 100644 --- a/website/views/options/inventory/drops.jade +++ b/website/views/options/inventory/drops.jade @@ -134,7 +134,7 @@ li.customize-menu menu.pets-menu(label=env.t('hatchingPotions')) p.muted!=env.t('dropsExplanation') - div(ng-repeat='pot in Content.hatchingPotions') + div(ng-repeat='pot in Content.hatchingPotions', ng-if='pot.canBuy') button.customize-option(class='Pet_HatchingPotion_{{::pot.key}}', popover='{{::pot.notes()}}', popover-append-to-body='true', popover-title!=env.t("potion", {potionType: "{{::pot.text()}}"}), diff --git a/website/views/options/inventory/mounts.jade b/website/views/options/inventory/mounts.jade index 2db2b8aa12..c5b3f3f273 100644 --- a/website/views/options/inventory/mounts.jade +++ b/website/views/options/inventory/mounts.jade @@ -1,4 +1,4 @@ -mixin mountList(source) +mixin mountList(source,showPremium) menu.pets(type='list') each egg in source -if(!egg.noMount) { @@ -6,9 +6,8 @@ mixin mountList(source) menu each potion in env.Content.hatchingPotions - mount = egg.key+"-"+potion.key - div(popover-trigger='mouseenter', popover=env.t('mountName', {potion: potion.text(env.language.code), mount: egg.mountText(env.language.code)}), popover-placement='bottom') + div(popover-trigger='mouseenter', popover=env.t('mountName', {potion: potion.text(env.language.code), mount: egg.mountText(env.language.code)}), popover-placement='bottom', ng-hide='#{potion.premium} && #{!showPremium}') button(class="pet-button Mount_Head_#{mount}", ng-show='user.items.mounts["#{mount}"]', ng-class='{active: user.items.currentMount == "#{mount}"}', ng-click='chooseMount("#{egg.key}", "#{potion.key}")') - //div(class='Mount_Head_{{mount}}') button(class="pet-button mount-not-owned", ng-hide='user.items.mounts["#{mount}"]') .PixelPaw -} @@ -24,7 +23,7 @@ mixin mountList(source) p=env.t('mattShall', {name: "{{user.profile.name}}"}) h4 {{:: env.t('stableMountMasterProgress', { number: mountMasterProgress }) }} .row: .col-md-12 - +mountList(env.Content.dropEggs) + +mountList(env.Content.dropEggs,true) .row: .col-md-12 h4=env.t('questMounts') +mountList(env.Content.questEggs) diff --git a/website/views/options/inventory/pets.jade b/website/views/options/inventory/pets.jade index 6fbe1f5fcd..86879215ba 100644 --- a/website/views/options/inventory/pets.jade +++ b/website/views/options/inventory/pets.jade @@ -1,11 +1,11 @@ -mixin petList(source) +mixin petList(source,showPremium) menu.pets(type='list') each egg in source li.customize-menu menu each potion in env.Content.hatchingPotions - pet = egg.key+"-"+potion.key - div(popover-trigger='mouseenter', popover=env.t('petName', {potion: potion.text(env.language.code), egg: egg.text(env.language.code)}), popover-placement='bottom') + div(popover-trigger='mouseenter', popover=env.t('petName', {potion: potion.text(env.language.code), egg: egg.text(env.language.code)}), popover-placement='bottom', ng-hide='#{potion.premium} && #{!showPremium}') button(class="pet-button Pet-#{pet}", ng-if='user.items.pets["#{pet}"]>0', ng-class='{active: user.items.currentPet == "#{pet}", selectableInventory: #{!egg.noMount} && selectedFood && !user.items.mounts["#{pet}"]}', ng-click='choosePet("#{egg.key}", "#{potion.key}")') .progress(ng-show='!user.items.mounts["#{pet}"]') .progress-bar.progress-bar-success(ng-style='{width: user.items.pets["#{pet}"]/.5 + "%"}') @@ -24,7 +24,7 @@ mixin petList(source) p=env.t('mattBochText1') h4 {{:: env.t('stableBeastMasterProgress', { number: beastMasterProgress }) }} .row: .col-md-12 - +petList(env.Content.dropEggs) + +petList(env.Content.dropEggs,true) .row: .col-md-12 h4=env.t('questPets') +petList(env.Content.questEggs)