From c39d2a8a1384cb1c608cb7069cfa9cb4712174d6 Mon Sep 17 00:00:00 2001 From: Lorian Date: Sat, 8 Feb 2014 16:56:07 -0800 Subject: [PATCH 1/4] Separated stable into dropped pets, quest pets, and rare pets, and made countPets only count the former. Made countMounts only count dropped and quest-hatched mounts, not rare mounts. --- dist/habitrpg-shared.js | 101 +++++++++++++++++++++++++++++++++++++++- locales/en/pets.json | 3 ++ script/content.coffee | 40 +++++++++++++++- script/index.coffee | 12 ++++- 4 files changed, 152 insertions(+), 4 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index c6813c3569..14127db8a2 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -10606,6 +10606,77 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? }); }); + api.dropEggs = { + Wolf: { + text: 'Wolf', + adjective: 'loyal' + }, + TigerCub: { + text: 'Tiger Cub', + mountText: 'Tiger', + adjective: 'fierce' + }, + PandaCub: { + text: 'Panda Cub', + mountText: 'Panda', + adjective: 'gentle' + }, + LionCub: { + text: 'Lion Cub', + mountText: 'Lion', + adjective: 'regal' + }, + Fox: { + text: 'Fox', + adjective: 'wily' + }, + FlyingPig: { + text: 'Flying Pig', + adjective: 'whimsical' + }, + Dragon: { + text: 'Dragon', + adjective: 'mighty' + }, + Cactus: { + text: 'Cactus', + adjective: 'prickly' + }, + BearCub: { + text: 'Bear Cub', + mountText: 'Bear', + adjective: 'cuddly' + } + }; + + _.each(api.dropEggs, function(egg, key) { + return _.defaults(egg, { + canBuy: true, + value: 3, + key: key, + notes: "Find a hatching potion to pour on this egg, and it will hatch into a " + egg.adjective + " " + egg.text + ".", + mountText: egg.text + }); + }); + + api.questEggs = { + Gryphon: { + text: 'Gryphon', + adjective: 'regal', + canBuy: false + } + }; + + _.each(api.questEggs, function(egg, key) { + return _.defaults(egg, { + canBuy: false, + value: 3, + key: key, + notes: "Find a hatching potion to pour on this egg, and it will hatch into a " + egg.adjective + " " + egg.text + ".", + mountText: egg.text + }); + }); + api.specialPets = { 'Wolf-Veteran': true, 'Wolf-Cerberus': true, @@ -10614,6 +10685,11 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? 'BearCub-Polar': true }; + api.specialMounts = { + 'BearCub-Polar': true, + 'LionCub-Ethereal': true + }; + api.hatchingPotions = { Base: { value: 2, @@ -10665,7 +10741,13 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? }); }); - api.pets = _.transform(api.eggs, function(m, egg) { + api.pets = _.transform(api.dropEggs, function(m, egg) { + return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { + return m2[egg.key + "-" + pot.key] = true; + })); + }); + + api.questPets = _.transform(api.questEggs, function(m, egg) { return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { return m2[egg.key + "-" + pot.key] = true; })); @@ -11601,6 +11683,11 @@ var process=require("__browserify_process");(function() { var count, pet; count = originalCount != null ? originalCount : _.size(pets); + for (pet in content.questPets) { + if (pets[pet]) { + count--; + } + } for (pet in content.specialPets) { if (pets[pet]) { count--; @@ -11609,6 +11696,18 @@ var process=require("__browserify_process");(function() { return count; }; + api.countMounts = function(originalCount, mounts) { + var count, mount; + + count = originalCount != null ? originalCount : _.size(mounts); + for (mount in content.specialMounts) { + if (mounts[mount]) { + count--; + } + } + return count; + }; + /* ------------------------------------------------------ User (prototype wrapper to give it ops, helper funcs, and virtuals diff --git a/locales/en/pets.json b/locales/en/pets.json index e2de37d9ed..2ad4afc86c 100644 --- a/locales/en/pets.json +++ b/locales/en/pets.json @@ -4,8 +4,11 @@ "pets" : "Pets", "petsFound":"Pets Found", "rarePets": "Rare Pets", + "questPets": "Quest Pets", + "beastmasterProgress": "Beastmaster Progress", "mounts" : "Mounts", "mountsTamed" : "Mounts Tamed", + "questMounts" : "Quest Mounts", "rareMounts" : "Rare Mounts", "etherealLion" : "Ethereal Lion", "petsFound" : "Pets Found", diff --git a/script/content.coffee b/script/content.coffee index 2b30d70e40..ee02a58c67 100644 --- a/script/content.coffee +++ b/script/content.coffee @@ -506,6 +506,36 @@ _.each api.eggs, (egg,key) -> notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}." mountText: egg.text +api.dropEggs = + # value & other defaults set below + Wolf: text: 'Wolf', adjective: 'loyal' + TigerCub: text: 'Tiger Cub', mountText: 'Tiger', adjective: 'fierce' + PandaCub: text: 'Panda Cub', mountText: 'Panda', adjective: 'gentle' + LionCub: text: 'Lion Cub', mountText: 'Lion', adjective: 'regal' + Fox: text: 'Fox', adjective: 'wily' + FlyingPig: text: 'Flying Pig', adjective: 'whimsical' + Dragon: text: 'Dragon', adjective: 'mighty' + Cactus: text: 'Cactus', adjective: 'prickly' + BearCub: text: 'Bear Cub', mountText: 'Bear', adjective: 'cuddly' +_.each api.dropEggs, (egg,key) -> + _.defaults egg, + canBuy:true + value: 3 + key: key + notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}." + mountText: egg.text + +api.questEggs = + # value & other defaults set below + Gryphon: text: 'Gryphon', adjective: 'regal', canBuy: false +_.each api.questEggs, (egg,key) -> + _.defaults egg, + canBuy:false + value: 3 + key: key + notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}." + mountText: egg.text + api.specialPets = 'Wolf-Veteran': true 'Wolf-Cerberus': true @@ -513,6 +543,10 @@ api.specialPets = 'Turkey-Base': true 'BearCub-Polar': true +api.specialMounts = + 'BearCub-Polar': true + 'LionCub-Ethereal': true + api.hatchingPotions = Base: value: 2, text: 'Base' White: value: 2, text: 'White' @@ -527,7 +561,11 @@ api.hatchingPotions = _.each api.hatchingPotions, (pot,key) -> _.defaults pot, {key, value: 2, notes: "Pour this on an egg, and it will hatch as a #{pot.text} pet."} -api.pets = _.transform api.eggs, (m, egg) -> +api.pets = _.transform api.dropEggs, (m, egg) -> + _.defaults m, _.transform api.hatchingPotions, (m2, pot) -> + 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 diff --git a/script/index.coffee b/script/index.coffee index 44636c1be5..1b5b8e7c01 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -301,10 +301,18 @@ api.appliedTags = (userTags, taskTags) -> api.countPets = (originalCount, pets) -> count = if originalCount? then originalCount else _.size(pets) + for pet of content.questPets + count-- if pets[pet] for pet of content.specialPets count-- if pets[pet] count +api.countMounts= (originalCount, mounts) -> + count = if originalCount? then originalCount else _.size(mounts) + for mount of content.specialMounts + count-- if mounts[mount] + count + ### ------------------------------------------------------ User (prototype wrapper to give it ops, helper funcs, and virtuals @@ -1177,8 +1185,8 @@ api.wrap = (user, main=true) -> {id, type, completed, repeat} = task return if (type is 'daily') && !completed && user.stats.buffs.stealth && user.stats.buffs.stealth-- # User "evades" a certain number of uncompleted dailies - - + + # Deduct experience for missed Daily tasks, but not for Todos (just increase todo's value) unless completed scheduleMisses = daysMissed From 04b73c4058b7ab6f571fbb004c18fd6914966ae0 Mon Sep 17 00:00:00 2001 From: Lorian Date: Sat, 8 Feb 2014 17:24:04 -0800 Subject: [PATCH 2/4] Added unit tests for proper mount counting and beastmaster achievement, and extended unit tests for proper pet counting. --- tests/algos.mocha.coffee | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/algos.mocha.coffee b/tests/algos.mocha.coffee index 9ce582fb60..680cd6b534 100644 --- a/tests/algos.mocha.coffee +++ b/tests/algos.mocha.coffee @@ -1,3 +1,8 @@ +### Must install: ### +### sudo npm install -g mocha ### +### npm install sinon ### +### Run with mocha algos.mocha.coffee --compilers coffee:coffee-script ### + _ = require 'lodash' expect = require 'expect.js' sinon = require 'sinon' @@ -321,6 +326,33 @@ describe 'User', -> it 'gets ultimateGear ' + klass, -> expect(user.achievements.ultimateGear).to.be.ok + it 'doesnt get beastmaster', -> + user = newUser() + user.items.pets = {'Wolf-White': 1, 'Wolf-Desert': 1, 'Wolf-Red': 1, 'Wolf-Shade': 1, 'Wolf-Skeleton': 1, 'Wolf-Zombie': 1, 'Wolf-CottonCandyPink': 1, 'Wolf-CottonCandyBlue': 1, 'Wolf-Golden': 1, 'TigerCub-Base': 1, 'TigerCub-White': 1, 'TigerCub-Desert': 1, 'TigerCub-Red': 1, 'TigerCub-Shade': 1, 'TigerCub-Skeleton': 1, 'TigerCub-Zombie': 1, 'TigerCub-CottonCandyPink': 1, 'TigerCub-CottonCandyBlue': 1, 'TigerCub-Golden': 1, 'PandaCub-Base': 1, 'PandaCub-White': 1, 'PandaCub-Desert': 1, 'PandaCub-Red': 1, 'PandaCub-Shade': 1, 'PandaCub-Skeleton': 1, 'PandaCub-Zombie': 1, 'PandaCub-CottonCandyPink': 1, 'PandaCub-CottonCandyBlue': 1, 'PandaCub-Golden': 1, 'LionCub-Base': 1, 'LionCub-White': 1, 'LionCub-Desert': 1, 'LionCub-Red': 1, 'LionCub-Shade': 1, 'LionCub-Skeleton': 1, 'LionCub-Zombie': 1, 'LionCub-CottonCandyPink': 1, 'LionCub-CottonCandyBlue': 1, 'LionCub-Golden': 1, 'Fox-Base': 1, 'Fox-White': 1, 'Fox-Desert': 1, 'Fox-Red': 1, 'Fox-Shade': 1, 'Fox-Skeleton': 1, 'Fox-Zombie': 1, 'Fox-CottonCandyPink': 1, 'Fox-CottonCandyBlue': 1, 'Fox-Golden': 1, 'FlyingPig-Base': 1, 'FlyingPig-White': 1, 'FlyingPig-Desert': 1, 'FlyingPig-Red': 1, 'FlyingPig-Shade': 1, 'FlyingPig-Skeleton': 1, 'FlyingPig-Zombie': 1, 'FlyingPig-CottonCandyPink': 1, 'FlyingPig-CottonCandyBlue': 1, 'FlyingPig-Golden': 1, 'Dragon-Base': 1, 'Dragon-White': 1, 'Dragon-Desert': 1, 'Dragon-Red': 1, 'Dragon-Shade': 1, 'Dragon-Skeleton': 1, 'Dragon-Zombie': 1, 'Dragon-CottonCandyPink': 1, 'Dragon-CottonCandyBlue': 1, 'Dragon-Golden': 1, 'Cactus-Base': 1, 'Cactus-White': 1, 'Cactus-Desert': 1, 'Cactus-Red': 1, 'Cactus-Shade': 1, 'Cactus-Skeleton': 1, 'Cactus-Zombie': 1, 'Cactus-CottonCandyPink': 1, 'Cactus-CottonCandyBlue': 1, 'Cactus-Golden': 1, 'BearCub-Base': 1, 'BearCub-White': 1, 'BearCub-Desert': 1, 'BearCub-Red': 1, 'BearCub-Shade': 1, 'BearCub-Skeleton': 1, 'BearCub-Zombie': 1, 'BearCub-CottonCandyPink': 1, 'BearCub-CottonCandyBlue': 1, 'BearCub-Golden': 1 } + expect(shared.countPets(null,user.items.pets)).to.eql 89 + expect(shared.countPets(_.size(user.items.pets), user.items.pets)).to.eql 89 + expect(user.achievements.beastMaster).to.not.be.ok + + it 'doesnt get beastmaster with gryphons', -> + user = newUser() + user.items.pets = {'Gryphon-Base': 1, 'Wolf-White': 1, 'Wolf-Desert': 1, 'Wolf-Red': 1, 'Wolf-Shade': 1, 'Wolf-Skeleton': 1, 'Wolf-Zombie': 1, 'Wolf-CottonCandyPink': 1, 'Wolf-CottonCandyBlue': 1, 'Wolf-Golden': 1, 'TigerCub-Base': 1, 'TigerCub-White': 1, 'TigerCub-Desert': 1, 'TigerCub-Red': 1, 'TigerCub-Shade': 1, 'TigerCub-Skeleton': 1, 'TigerCub-Zombie': 1, 'TigerCub-CottonCandyPink': 1, 'TigerCub-CottonCandyBlue': 1, 'TigerCub-Golden': 1, 'PandaCub-Base': 1, 'PandaCub-White': 1, 'PandaCub-Desert': 1, 'PandaCub-Red': 1, 'PandaCub-Shade': 1, 'PandaCub-Skeleton': 1, 'PandaCub-Zombie': 1, 'PandaCub-CottonCandyPink': 1, 'PandaCub-CottonCandyBlue': 1, 'PandaCub-Golden': 1, 'LionCub-Base': 1, 'LionCub-White': 1, 'LionCub-Desert': 1, 'LionCub-Red': 1, 'LionCub-Shade': 1, 'LionCub-Skeleton': 1, 'LionCub-Zombie': 1, 'LionCub-CottonCandyPink': 1, 'LionCub-CottonCandyBlue': 1, 'LionCub-Golden': 1, 'Fox-Base': 1, 'Fox-White': 1, 'Fox-Desert': 1, 'Fox-Red': 1, 'Fox-Shade': 1, 'Fox-Skeleton': 1, 'Fox-Zombie': 1, 'Fox-CottonCandyPink': 1, 'Fox-CottonCandyBlue': 1, 'Fox-Golden': 1, 'FlyingPig-Base': 1, 'FlyingPig-White': 1, 'FlyingPig-Desert': 1, 'FlyingPig-Red': 1, 'FlyingPig-Shade': 1, 'FlyingPig-Skeleton': 1, 'FlyingPig-Zombie': 1, 'FlyingPig-CottonCandyPink': 1, 'FlyingPig-CottonCandyBlue': 1, 'FlyingPig-Golden': 1, 'Dragon-Base': 1, 'Dragon-White': 1, 'Dragon-Desert': 1, 'Dragon-Red': 1, 'Dragon-Shade': 1, 'Dragon-Skeleton': 1, 'Dragon-Zombie': 1, 'Dragon-CottonCandyPink': 1, 'Dragon-CottonCandyBlue': 1, 'Dragon-Golden': 1, 'Cactus-Base': 1, 'Cactus-White': 1, 'Cactus-Desert': 1, 'Cactus-Red': 1, 'Cactus-Shade': 1, 'Cactus-Skeleton': 1, 'Cactus-Zombie': 1, 'Cactus-CottonCandyPink': 1, 'Cactus-CottonCandyBlue': 1, 'Cactus-Golden': 1, 'BearCub-Base': 1, 'BearCub-White': 1, 'BearCub-Desert': 1, 'BearCub-Red': 1, 'BearCub-Shade': 1, 'BearCub-Skeleton': 1, 'BearCub-Zombie': 1, 'BearCub-CottonCandyPink': 1, 'BearCub-CottonCandyBlue': 1, 'BearCub-Golden': 1 } + expect(shared.countPets(null,user.items.pets)).to.eql 89 + expect(shared.countPets(_.size(user.items.pets), user.items.pets)).to.eql 89 + expect(user.achievements.beastMaster).to.not.be.ok + + it 'doesnt get beastmaster with hydra', -> + user = newUser() + user.items.pets = {'Dragon-Hydra': 1, 'Wolf-White': 1, 'Wolf-Desert': 1, 'Wolf-Red': 1, 'Wolf-Shade': 1, 'Wolf-Skeleton': 1, 'Wolf-Zombie': 1, 'Wolf-CottonCandyPink': 1, 'Wolf-CottonCandyBlue': 1, 'Wolf-Golden': 1, 'TigerCub-Base': 1, 'TigerCub-White': 1, 'TigerCub-Desert': 1, 'TigerCub-Red': 1, 'TigerCub-Shade': 1, 'TigerCub-Skeleton': 1, 'TigerCub-Zombie': 1, 'TigerCub-CottonCandyPink': 1, 'TigerCub-CottonCandyBlue': 1, 'TigerCub-Golden': 1, 'PandaCub-Base': 1, 'PandaCub-White': 1, 'PandaCub-Desert': 1, 'PandaCub-Red': 1, 'PandaCub-Shade': 1, 'PandaCub-Skeleton': 1, 'PandaCub-Zombie': 1, 'PandaCub-CottonCandyPink': 1, 'PandaCub-CottonCandyBlue': 1, 'PandaCub-Golden': 1, 'LionCub-Base': 1, 'LionCub-White': 1, 'LionCub-Desert': 1, 'LionCub-Red': 1, 'LionCub-Shade': 1, 'LionCub-Skeleton': 1, 'LionCub-Zombie': 1, 'LionCub-CottonCandyPink': 1, 'LionCub-CottonCandyBlue': 1, 'LionCub-Golden': 1, 'Fox-Base': 1, 'Fox-White': 1, 'Fox-Desert': 1, 'Fox-Red': 1, 'Fox-Shade': 1, 'Fox-Skeleton': 1, 'Fox-Zombie': 1, 'Fox-CottonCandyPink': 1, 'Fox-CottonCandyBlue': 1, 'Fox-Golden': 1, 'FlyingPig-Base': 1, 'FlyingPig-White': 1, 'FlyingPig-Desert': 1, 'FlyingPig-Red': 1, 'FlyingPig-Shade': 1, 'FlyingPig-Skeleton': 1, 'FlyingPig-Zombie': 1, 'FlyingPig-CottonCandyPink': 1, 'FlyingPig-CottonCandyBlue': 1, 'FlyingPig-Golden': 1, 'Dragon-Base': 1, 'Dragon-White': 1, 'Dragon-Desert': 1, 'Dragon-Red': 1, 'Dragon-Shade': 1, 'Dragon-Skeleton': 1, 'Dragon-Zombie': 1, 'Dragon-CottonCandyPink': 1, 'Dragon-CottonCandyBlue': 1, 'Dragon-Golden': 1, 'Cactus-Base': 1, 'Cactus-White': 1, 'Cactus-Desert': 1, 'Cactus-Red': 1, 'Cactus-Shade': 1, 'Cactus-Skeleton': 1, 'Cactus-Zombie': 1, 'Cactus-CottonCandyPink': 1, 'Cactus-CottonCandyBlue': 1, 'Cactus-Golden': 1, 'BearCub-Base': 1, 'BearCub-White': 1, 'BearCub-Desert': 1, 'BearCub-Red': 1, 'BearCub-Shade': 1, 'BearCub-Skeleton': 1, 'BearCub-Zombie': 1, 'BearCub-CottonCandyPink': 1, 'BearCub-CottonCandyBlue': 1, 'BearCub-Golden': 1 } + expect(shared.countPets(null,user.items.pets)).to.eql 89 + expect(shared.countPets(_.size(user.items.pets), user.items.pets)).to.eql 89 + expect(user.achievements.beastMaster).to.not.be.ok + + it 'does get beastmaster', -> + user = newUser() + user.items.pets = {'Wolf-Base': 1, 'Wolf-White': 1, 'Wolf-Desert': 1, 'Wolf-Red': 1, 'Wolf-Shade': 1, 'Wolf-Skeleton': 1, 'Wolf-Zombie': 1, 'Wolf-CottonCandyPink': 1, 'Wolf-CottonCandyBlue': 1, 'Wolf-Golden': 1, 'TigerCub-Base': 1, 'TigerCub-White': 1, 'TigerCub-Desert': 1, 'TigerCub-Red': 1, 'TigerCub-Shade': 1, 'TigerCub-Skeleton': 1, 'TigerCub-Zombie': 1, 'TigerCub-CottonCandyPink': 1, 'TigerCub-CottonCandyBlue': 1, 'TigerCub-Golden': 1, 'PandaCub-Base': 1, 'PandaCub-White': 1, 'PandaCub-Desert': 1, 'PandaCub-Red': 1, 'PandaCub-Shade': 1, 'PandaCub-Skeleton': 1, 'PandaCub-Zombie': 1, 'PandaCub-CottonCandyPink': 1, 'PandaCub-CottonCandyBlue': 1, 'PandaCub-Golden': 1, 'LionCub-Base': 1, 'LionCub-White': 1, 'LionCub-Desert': 1, 'LionCub-Red': 1, 'LionCub-Shade': 1, 'LionCub-Skeleton': 1, 'LionCub-Zombie': 1, 'LionCub-CottonCandyPink': 1, 'LionCub-CottonCandyBlue': 1, 'LionCub-Golden': 1, 'Fox-Base': 1, 'Fox-White': 1, 'Fox-Desert': 1, 'Fox-Red': 1, 'Fox-Shade': 1, 'Fox-Skeleton': 1, 'Fox-Zombie': 1, 'Fox-CottonCandyPink': 1, 'Fox-CottonCandyBlue': 1, 'Fox-Golden': 1, 'FlyingPig-Base': 1, 'FlyingPig-White': 1, 'FlyingPig-Desert': 1, 'FlyingPig-Red': 1, 'FlyingPig-Shade': 1, 'FlyingPig-Skeleton': 1, 'FlyingPig-Zombie': 1, 'FlyingPig-CottonCandyPink': 1, 'FlyingPig-CottonCandyBlue': 1, 'FlyingPig-Golden': 1, 'Dragon-Base': 1, 'Dragon-White': 1, 'Dragon-Desert': 1, 'Dragon-Red': 1, 'Dragon-Shade': 1, 'Dragon-Skeleton': 1, 'Dragon-Zombie': 1, 'Dragon-CottonCandyPink': 1, 'Dragon-CottonCandyBlue': 1, 'Dragon-Golden': 1, 'Cactus-Base': 1, 'Cactus-White': 1, 'Cactus-Desert': 1, 'Cactus-Red': 1, 'Cactus-Shade': 1, 'Cactus-Skeleton': 1, 'Cactus-Zombie': 1, 'Cactus-CottonCandyPink': 1, 'Cactus-CottonCandyBlue': 1, 'Cactus-Golden': 1, 'BearCub-Base': 1, 'BearCub-White': 1, 'BearCub-Desert': 1, 'BearCub-Red': 1, 'BearCub-Shade': 1, 'BearCub-Skeleton': 1, 'BearCub-Zombie': 1, 'BearCub-CottonCandyPink': 1, 'BearCub-CottonCandyBlue': 1, 'BearCub-Golden': 1 } + expect(shared.countPets(null,user.items.pets)).to.eql 90 + expect(shared.countPets(_.size(user.items.pets), user.items.pets)).to.eql 90 + expect(user.achievements.beastMaster).to.be.ok describe 'Simple Scoring', -> beforeEach -> @@ -570,6 +602,27 @@ describe 'Helper', -> expect(shared.countPets(null, pets)).to.eql 2 expect(shared.countPets(2, pets)).to.eql 2 + pets = { "Dragon-Red": 1, "Gryphon-Base": 1 } + expect(shared.countPets(null, pets)).to.eql 1 + expect(shared.countPets(_.size(pets), pets)).to.eql 1 + pets = { "Wolf-Base": 2, "Wolf-Veteran": 1, "Wolf-Cerberus": 1, "Dragon-Hydra": 1} expect(shared.countPets(null, pets)).to.eql 1 expect(shared.countPets(_.size(pets), pets)).to.eql 1 + + it 'counts mounts', -> + mounts = {} + expect(shared.countMounts(null, mounts)).to.eql 0 + expect(shared.countMounts(1, mounts)).to.eql 1 + + mounts = { "Dragon-Red": 1, "Wolf-Base": 2 } + expect(shared.countMounts(null, mounts)).to.eql 2 + expect(shared.countMounts(2, mounts)).to.eql 2 + + mounts = { "Dragon-Red": 1, "Gryphon-Base": 1 } + expect(shared.countMounts(null, mounts)).to.eql 2 + expect(shared.countMounts(_.size(mounts), mounts)).to.eql 2 + + mounts = { "Wolf-Base": 2, "BearCub-Polar": 1} + expect(shared.countMounts(null, mounts)).to.eql 1 + expect(shared.countMounts(_.size(mounts), mounts)).to.eql 1 From 82b58a7435adb442c55221ff42a32a909ca53a60 Mon Sep 17 00:00:00 2001 From: Lorian Date: Sat, 8 Feb 2014 20:14:50 -0800 Subject: [PATCH 3/4] dropEggs and questEggs now automatically make the full content.eggs list; no manual duplication required. --- dist/habitrpg-shared.js | 60 ++--------------------------------------- script/content.coffee | 22 ++------------- 2 files changed, 4 insertions(+), 78 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 14127db8a2..718657fb8a 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -10548,64 +10548,6 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? */ - api.eggs = { - Wolf: { - text: 'Wolf', - adjective: 'loyal' - }, - TigerCub: { - text: 'Tiger Cub', - mountText: 'Tiger', - adjective: 'fierce' - }, - PandaCub: { - text: 'Panda Cub', - mountText: 'Panda', - adjective: 'gentle' - }, - LionCub: { - text: 'Lion Cub', - mountText: 'Lion', - adjective: 'regal' - }, - Fox: { - text: 'Fox', - adjective: 'wily' - }, - FlyingPig: { - text: 'Flying Pig', - adjective: 'whimsical' - }, - Dragon: { - text: 'Dragon', - adjective: 'mighty' - }, - Cactus: { - text: 'Cactus', - adjective: 'prickly' - }, - BearCub: { - text: 'Bear Cub', - mountText: 'Bear', - adjective: 'cuddly' - }, - Gryphon: { - text: 'Gryphon', - adjective: 'regal', - canBuy: false - } - }; - - _.each(api.eggs, function(egg, key) { - return _.defaults(egg, { - canBuy: true, - value: 3, - key: key, - notes: "Find a hatching potion to pour on this egg, and it will hatch into a " + egg.adjective + " " + egg.text + ".", - mountText: egg.text - }); - }); - api.dropEggs = { Wolf: { text: 'Wolf', @@ -10677,6 +10619,8 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? }); }); + api.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs); + api.specialPets = { 'Wolf-Veteran': true, 'Wolf-Cerberus': true, diff --git a/script/content.coffee b/script/content.coffee index ee02a58c67..028f330be8 100644 --- a/script/content.coffee +++ b/script/content.coffee @@ -486,26 +486,6 @@ api.special = api.spells.special --------------------------------------------------------------- ### -api.eggs = - # value & other defaults set below - Wolf: text: 'Wolf', adjective: 'loyal' - TigerCub: text: 'Tiger Cub', mountText: 'Tiger', adjective: 'fierce' - PandaCub: text: 'Panda Cub', mountText: 'Panda', adjective: 'gentle' - LionCub: text: 'Lion Cub', mountText: 'Lion', adjective: 'regal' - Fox: text: 'Fox', adjective: 'wily' - FlyingPig: text: 'Flying Pig', adjective: 'whimsical' - Dragon: text: 'Dragon', adjective: 'mighty' - Cactus: text: 'Cactus', adjective: 'prickly' - BearCub: text: 'Bear Cub', mountText: 'Bear', adjective: 'cuddly' - Gryphon: text: 'Gryphon', adjective: 'regal', canBuy: false -_.each api.eggs, (egg,key) -> - _.defaults egg, - canBuy:true - value: 3 - key: key - notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}." - mountText: egg.text - api.dropEggs = # value & other defaults set below Wolf: text: 'Wolf', adjective: 'loyal' @@ -536,6 +516,8 @@ _.each api.questEggs, (egg,key) -> notes: "Find a hatching potion to pour on this egg, and it will hatch into a #{egg.adjective} #{egg.text}." mountText: egg.text +api.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs) + api.specialPets = 'Wolf-Veteran': true 'Wolf-Cerberus': true From 914400e1595e97a46869abe7f1cb1161a43394ee Mon Sep 17 00:00:00 2001 From: Lorian Date: Sat, 8 Feb 2014 20:19:01 -0800 Subject: [PATCH 4/4] Simplified run instructions for mocha test. --- tests/algos.mocha.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/algos.mocha.coffee b/tests/algos.mocha.coffee index 680cd6b534..76d34c674c 100644 --- a/tests/algos.mocha.coffee +++ b/tests/algos.mocha.coffee @@ -1,7 +1,5 @@ -### Must install: ### -### sudo npm install -g mocha ### -### npm install sinon ### -### Run with mocha algos.mocha.coffee --compilers coffee:coffee-script ### +### Install: npm install --dev ### +### Run: npm test ### _ = require 'lodash' expect = require 'expect.js'