Merge pull request #138 from lorian/beastmaster-count

Fixes beastmaster to not count gryphons
This commit is contained in:
Cole Gleason 2014-02-08 22:31:50 -06:00
commit a2d01e73aa
5 changed files with 139 additions and 14 deletions

View file

@ -10548,7 +10548,7 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
*/
api.eggs = {
api.dropEggs = {
Wolf: {
text: 'Wolf',
adjective: 'loyal'
@ -10588,15 +10588,10 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
text: 'Bear Cub',
mountText: 'Bear',
adjective: 'cuddly'
},
Gryphon: {
text: 'Gryphon',
adjective: 'regal',
canBuy: false
}
};
_.each(api.eggs, function(egg, key) {
_.each(api.dropEggs, function(egg, key) {
return _.defaults(egg, {
canBuy: true,
value: 3,
@ -10606,6 +10601,26 @@ var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ?
});
});
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.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs);
api.specialPets = {
'Wolf-Veteran': true,
'Wolf-Cerberus': true,
@ -10614,6 +10629,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 +10685,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 +11627,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 +11640,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

View file

@ -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",

View file

@ -486,7 +486,7 @@ api.special = api.spells.special
---------------------------------------------------------------
###
api.eggs =
api.dropEggs =
# value & other defaults set below
Wolf: text: 'Wolf', adjective: 'loyal'
TigerCub: text: 'Tiger Cub', mountText: 'Tiger', adjective: 'fierce'
@ -497,8 +497,7 @@ api.eggs =
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) ->
_.each api.dropEggs, (egg,key) ->
_.defaults egg,
canBuy:true
value: 3
@ -506,6 +505,19 @@ _.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.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.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs)
api.specialPets =
'Wolf-Veteran': true
'Wolf-Cerberus': true
@ -513,6 +525,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 +543,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

View file

@ -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

View file

@ -1,3 +1,6 @@
### Install: npm install --dev ###
### Run: npm test ###
_ = require 'lodash'
expect = require 'expect.js'
sinon = require 'sinon'
@ -321,6 +324,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 +600,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