Merge pull request #5642 from crookedneighbor/refactor_member_modal_and_stats_page
Refactor member modal and stats page
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ module.exports = function(grunt) {
|
||||
|
||||
watch: {
|
||||
dev: {
|
||||
files: ['website/public/**/*.styl', 'common/script/**/*.coffee'], // 'public/**/*.js' Not needed because not in production
|
||||
files: ['website/public/**/*.styl', 'common/script/**/*.coffee', 'common/script/**/*.js'], // 'public/**/*.js' Not needed because not in production
|
||||
tasks: [ 'build:dev' ],
|
||||
options: {
|
||||
nospawn: true
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"hauntedColors": "Haunted Colors",
|
||||
"winteryColors": "Wintery Colors",
|
||||
"equipment": "Equipment",
|
||||
"equipmentBonus": "Equipment",
|
||||
"equipmentBonusText": "Attribute bonuses provided by your equipped battle gear. See the Equipment tab under Inventory to select your battle gear.",
|
||||
"classBonus": "Class Equipment Bonus",
|
||||
"classBonusText": "Your class (Warrior, if you haven't unlocked or selected another class) uses its own equipment more effectively than gear from other classes. Equipped gear from your current class gets a 50% boost to the attribute bonus it grants.",
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
require('coffee-script');
|
||||
var _ = require('lodash');
|
||||
var content = require('./content.coffee');
|
||||
|
||||
var DROP_ANIMALS = _.keys(content.pets);
|
||||
|
||||
function beastMasterProgress(pets) {
|
||||
var count = 0;
|
||||
_(DROP_ANIMALS).each(function(animal) {
|
||||
if(pets[animal] > 0 || pets[animal] == -1)
|
||||
count++
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function dropPetsCurrentlyOwned(pets) {
|
||||
var count = 0;
|
||||
|
||||
_(DROP_ANIMALS).each(function(animal) {
|
||||
if(pets[animal] > 0)
|
||||
count++
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
function mountMasterProgress(mounts) {
|
||||
var count = 0;
|
||||
_(DROP_ANIMALS).each(function(animal) {
|
||||
if (mounts[animal])
|
||||
count++
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
function remainingGearInSet(userGear, set) {
|
||||
var gear = _.filter(content.gear.flat, function(item) {
|
||||
var setMatches = item.klass === set;
|
||||
var hasItem = _.has(userGear, item.key);
|
||||
|
||||
return setMatches && !hasItem;
|
||||
});
|
||||
|
||||
var count = _.size(gear);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beastMasterProgress: beastMasterProgress,
|
||||
dropPetsCurrentlyOwned: dropPetsCurrentlyOwned,
|
||||
mountMasterProgress: mountMasterProgress,
|
||||
remainingGearInSet: remainingGearInSet
|
||||
};
|
||||
+10
-32
@@ -88,7 +88,7 @@ api.shouldDo = (day, dailyTask, options = {}) ->
|
||||
# The time portion of the Start Date is never visible to or modifiable by the user so we must ignore it.
|
||||
# Therefore, we must also ignore the time portion of the user's day start (startOfDayWithCDSTime), otherwise the date comparison will be wrong for some times.
|
||||
# NB: The user's day start date has already been converted to the PREVIOUS day's date if the time portion was before CDS.
|
||||
taskStartDate = moment(taskStartDate).startOf('day');
|
||||
taskStartDate = moment(taskStartDate).startOf('day')
|
||||
|
||||
if taskStartDate > startOfDayWithCDSTime.startOf('day')
|
||||
return false # Daily starts in the future
|
||||
@@ -378,32 +378,10 @@ api.appliedTags = (userTags, taskTags) ->
|
||||
arr.push(t.name) if taskTags?[t.id]
|
||||
arr.join(', ')
|
||||
|
||||
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) ->
|
||||
count2 = if originalCount? then originalCount else _.size(mounts)
|
||||
for mount of content.questPets
|
||||
count2-- if mounts[mount]
|
||||
for mount of content.specialMounts
|
||||
count2-- if mounts[mount]
|
||||
count2
|
||||
|
||||
api.countTriad = (pets) ->
|
||||
count3 = 0
|
||||
for egg of content.dropEggs
|
||||
for potion of content.hatchingPotions
|
||||
if pets[egg + "-" + potion] > 0 then count3++
|
||||
count3
|
||||
|
||||
api.countArmoire = (gear) ->
|
||||
count = _.size(_.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !gear[i.key])))
|
||||
count
|
||||
###
|
||||
Various counting functions
|
||||
###
|
||||
api.count = require('./count')
|
||||
|
||||
###
|
||||
------------------------------------------------------
|
||||
@@ -512,7 +490,7 @@ api.wrap = (user, main=true) ->
|
||||
gear[type].weapon = 'weapon_base_0'
|
||||
gear[type].head = 'head_base_0'
|
||||
gear[type].shield = 'shield_base_0'
|
||||
gear.owned = {} if typeof gear.owned == 'undefined';
|
||||
gear.owned = {} if typeof gear.owned == 'undefined'
|
||||
_.each gear.owned, (v, k)-> gear.owned[k]=false if gear.owned[k];true
|
||||
gear.owned.weapon_warrior_0 = true
|
||||
user.markModified? 'items.gear.owned'
|
||||
@@ -707,7 +685,7 @@ api.wrap = (user, main=true) ->
|
||||
addPushDevice: (req, cb) ->
|
||||
user.pushDevices = [] unless user.pushDevices
|
||||
pd = user.pushDevices
|
||||
item = {regId:req.body.regId, type:req.body.type};
|
||||
item = {regId:req.body.regId, type:req.body.type}
|
||||
i = _.findIndex pd, {regId: item.regId}
|
||||
|
||||
pd.push(item) unless i != -1
|
||||
@@ -902,7 +880,7 @@ api.wrap = (user, main=true) ->
|
||||
user.items.gear.owned[drop.key] = true
|
||||
user.flags.armoireOpened = true
|
||||
message = i18n.t('armoireEquipment', {image: '<span class="shop_'+drop.key+' pull-left"></span>', dropText: drop.text(req.language)}, req.language)
|
||||
if api.countArmoire(user.items.gear.owned) is 0 then user.flags.armoireEmpty = true
|
||||
if api.count.remainingGearInSet(user.items.gear.owned, 'armoire') is 0 then user.flags.armoireEmpty = true
|
||||
else if (!_.isEmpty(eligibleEquipment) and armoireResult < .8) or armoireResult < .5
|
||||
drop = user.fns.randomVal _.where(content.food, {canDrop:true})
|
||||
user.items.food[drop.key] ?= 0
|
||||
@@ -1186,7 +1164,7 @@ api.wrap = (user, main=true) ->
|
||||
unless task.type is 'reward'
|
||||
if (user.preferences.automaticAllocation is true and user.preferences.allocationMode is 'taskbased' and !(task.type is 'todo' and direction is 'down')) then user.stats.training[task.attribute] += nextDelta
|
||||
if direction is 'up' # Make progress on quest based on STR
|
||||
user.party.quest.progress.up = user.party.quest.progress.up || 0;
|
||||
user.party.quest.progress.up = user.party.quest.progress.up || 0
|
||||
user.party.quest.progress.up += (nextDelta * (1 + (user._statsComputed.str / 200))) if task.type in ['daily','todo']
|
||||
user.party.quest.progress.up += (nextDelta * (0.5 + (user._statsComputed.str / 400))) if task.type is 'habit'
|
||||
task.value += nextDelta
|
||||
@@ -1510,7 +1488,7 @@ api.wrap = (user, main=true) ->
|
||||
user.fns.autoAllocate()
|
||||
else
|
||||
# add new allocatable points. We could do user.stats.points++, but this does a fail-safe just in case
|
||||
user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int);
|
||||
user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int)
|
||||
if user.stats.points < 0
|
||||
user.stats.points = 0
|
||||
# This happens after dropping level with Fix Character Values and perhaps from other causes.
|
||||
|
||||
@@ -55,6 +55,7 @@ module.exports = function(config) {
|
||||
"website/public/js/services/taskServices.js",
|
||||
"website/public/js/services/paymentServices.js",
|
||||
"website/public/js/services/questServices.js",
|
||||
"website/public/js/services/statServices.js",
|
||||
|
||||
"website/public/js/filters/money.js",
|
||||
"website/public/js/filters/roundLargeNumbers.js",
|
||||
@@ -72,6 +73,7 @@ module.exports = function(config) {
|
||||
"website/public/js/directives/when-scrolled.directive.js",
|
||||
|
||||
"website/public/js/controllers/authCtrl.js",
|
||||
"website/public/js/controllers/memberModalCtrl.js",
|
||||
"website/public/js/controllers/menuCtrl.js",
|
||||
"website/public/js/controllers/notificationCtrl.js",
|
||||
"website/public/js/controllers/rootCtrl.js",
|
||||
|
||||
@@ -541,7 +541,7 @@ describe 'User', ->
|
||||
|
||||
it 'counts all available equipment before any are claimed', ->
|
||||
sinon.stub(user.fns, 'predictableRandom').returns 0
|
||||
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 1)
|
||||
expect(shared.count.remainingGearInSet(user.items.gear.owned, 'armoire')).to.eql (_.size(fullArmoire) - 1)
|
||||
|
||||
it 'does not open without paying', ->
|
||||
sinon.stub(user.fns, 'predictableRandom').returns 0
|
||||
@@ -565,7 +565,7 @@ describe 'User', ->
|
||||
user.achievements.ultimateGearSets = {'healer':false,'wizard':false,'rogue':true,'warrior':false}
|
||||
user.ops.buy({params: {key: 'armoire'}})
|
||||
expect(user.items.gear.owned).to.eql {'weapon_warrior_0': true, 'shield_armoire_gladiatorShield':true}
|
||||
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 2)
|
||||
expect(shared.count.remainingGearInSet(user.items.gear.owned, 'armoire')).to.eql (_.size(fullArmoire) - 2)
|
||||
expect(user.items.food).to.eql {}
|
||||
expect(user.stats.exp).to.eql 0
|
||||
expect(user.stats.gp).to.eql 400
|
||||
@@ -590,7 +590,7 @@ describe 'User', ->
|
||||
sinon.stub(user.fns, 'predictableRandom', cycle [.5,.5])
|
||||
user.ops.buy({params: {key: 'armoire'}})
|
||||
expect(user.items.gear.owned).to.eql {'weapon_warrior_0': true, 'shield_armoire_gladiatorShield':true, 'head_armoire_blueHairbow':true}
|
||||
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 3)
|
||||
expect(shared.count.remainingGearInSet(user.items.gear.owned, 'armoire')).to.eql (_.size(fullArmoire) - 3)
|
||||
expect(user.items.food).to.eql {'Honey': 1}
|
||||
expect(user.stats.exp).to.eql 30
|
||||
expect(user.stats.gp).to.eql 100
|
||||
@@ -600,7 +600,7 @@ describe 'User', ->
|
||||
user.items.gear.owned = fullArmoire
|
||||
user.ops.buy({params: {key: 'armoire'}})
|
||||
expect(user.items.gear.owned).to.eql fullArmoire
|
||||
expect(shared.countArmoire(user.items.gear.owned)).to.eql 0
|
||||
expect(shared.count.remainingGearInSet(user.items.gear.owned, 'armoire')).to.eql 0
|
||||
expect(user.items.food).to.eql {'Honey': 1}
|
||||
expect(user.stats.exp).to.eql 60
|
||||
expect(user.stats.gp).to.eql 0
|
||||
@@ -652,62 +652,6 @@ describe 'User', ->
|
||||
user.ops.buy {params:'shield_warrior_5'}
|
||||
expect(user.achievements.ultimateGearSets).to.eql {'healer':true,'wizard':true,'rogue':true,'warrior':true}
|
||||
|
||||
it 'does not get beastMaster if user has less than 90 drop pets', ->
|
||||
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 'does not get beastMaster with 89 drop pets + 1 gryphon', ->
|
||||
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 'does not get beastMaster with 89 pets + 1 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()
|
||||
|
||||
xit '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()
|
||||
|
||||
it 'does not get mountMaster if user has less than 90 drop mounts', ->
|
||||
user = newUser()
|
||||
user.items.mounts = {'Wolf-White': true, 'Wolf-Desert': true, 'Wolf-Red': true, 'Wolf-Shade': true, 'Wolf-Skeleton': true, 'Wolf-Zombie': true, 'Wolf-CottonCandyPink': true, 'Wolf-CottonCandyBlue': true, 'Wolf-Golden': true, 'TigerCub-Base': true, 'TigerCub-White': true, 'TigerCub-Desert': true, 'TigerCub-Red': true, 'TigerCub-Shade': true, 'TigerCub-Skeleton': true, 'TigerCub-Zombie': true, 'TigerCub-CottonCandyPink': true, 'TigerCub-CottonCandyBlue': true, 'TigerCub-Golden': true, 'PandaCub-Base': true, 'PandaCub-White': true, 'PandaCub-Desert': true, 'PandaCub-Red': true, 'PandaCub-Shade': true, 'PandaCub-Skeleton': true, 'PandaCub-Zombie': true, 'PandaCub-CottonCandyPink': true, 'PandaCub-CottonCandyBlue': true, 'PandaCub-Golden': true, 'LionCub-Base': true, 'LionCub-White': true, 'LionCub-Desert': true, 'LionCub-Red': true, 'LionCub-Shade': true, 'LionCub-Skeleton': true, 'LionCub-Zombie': true, 'LionCub-CottonCandyPink': true, 'LionCub-CottonCandyBlue': true, 'LionCub-Golden': true, 'Fox-Base': true, 'Fox-White': true, 'Fox-Desert': true, 'Fox-Red': true, 'Fox-Shade': true, 'Fox-Skeleton': true, 'Fox-Zombie': true, 'Fox-CottonCandyPink': true, 'Fox-CottonCandyBlue': true, 'Fox-Golden': true, 'FlyingPig-Base': true, 'FlyingPig-White': true, 'FlyingPig-Desert': true, 'FlyingPig-Red': true, 'FlyingPig-Shade': true, 'FlyingPig-Skeleton': true, 'FlyingPig-Zombie': true, 'FlyingPig-CottonCandyPink': true, 'FlyingPig-CottonCandyBlue': true, 'FlyingPig-Golden': true, 'Dragon-Base': true, 'Dragon-White': true, 'Dragon-Desert': true, 'Dragon-Red': true, 'Dragon-Shade': true, 'Dragon-Skeleton': true, 'Dragon-Zombie': true, 'Dragon-CottonCandyPink': true, 'Dragon-CottonCandyBlue': true, 'Dragon-Golden': true, 'Cactus-Base': true, 'Cactus-White': true, 'Cactus-Desert': true, 'Cactus-Red': true, 'Cactus-Shade': true, 'Cactus-Skeleton': true, 'Cactus-Zombie': true, 'Cactus-CottonCandyPink': true, 'Cactus-CottonCandyBlue': true, 'Cactus-Golden': true, 'BearCub-Base': true, 'BearCub-White': true, 'BearCub-Desert': true, 'BearCub-Red': true, 'BearCub-Shade': true, 'BearCub-Skeleton': true, 'BearCub-Zombie': true, 'BearCub-CottonCandyPink': true, 'BearCub-CottonCandyBlue': true, 'BearCub-Golden': true }
|
||||
expect(shared.countMounts(null,user.items.mounts)).to.eql 89
|
||||
expect(shared.countMounts(_.size(user.items.mounts), user.items.mounts)).to.eql 89
|
||||
expect(user.achievements.mountMaster).to.not.be.ok()
|
||||
|
||||
it 'does not get mountMaster with 89 drop pets + 1 gryphon', ->
|
||||
user = newUser()
|
||||
user.items.mounts = {'Gryphon-Base': true, 'Wolf-White': true, 'Wolf-Desert': true, 'Wolf-Red': true, 'Wolf-Shade': true, 'Wolf-Skeleton': true, 'Wolf-Zombie': true, 'Wolf-CottonCandyPink': true, 'Wolf-CottonCandyBlue': true, 'Wolf-Golden': true, 'TigerCub-Base': true, 'TigerCub-White': true, 'TigerCub-Desert': true, 'TigerCub-Red': true, 'TigerCub-Shade': true, 'TigerCub-Skeleton': true, 'TigerCub-Zombie': true, 'TigerCub-CottonCandyPink': true, 'TigerCub-CottonCandyBlue': true, 'TigerCub-Golden': true, 'PandaCub-Base': true, 'PandaCub-White': true, 'PandaCub-Desert': true, 'PandaCub-Red': true, 'PandaCub-Shade': true, 'PandaCub-Skeleton': true, 'PandaCub-Zombie': true, 'PandaCub-CottonCandyPink': true, 'PandaCub-CottonCandyBlue': true, 'PandaCub-Golden': true, 'LionCub-Base': true, 'LionCub-White': true, 'LionCub-Desert': true, 'LionCub-Red': true, 'LionCub-Shade': true, 'LionCub-Skeleton': true, 'LionCub-Zombie': true, 'LionCub-CottonCandyPink': true, 'LionCub-CottonCandyBlue': true, 'LionCub-Golden': true, 'Fox-Base': true, 'Fox-White': true, 'Fox-Desert': true, 'Fox-Red': true, 'Fox-Shade': true, 'Fox-Skeleton': true, 'Fox-Zombie': true, 'Fox-CottonCandyPink': true, 'Fox-CottonCandyBlue': true, 'Fox-Golden': true, 'FlyingPig-Base': true, 'FlyingPig-White': true, 'FlyingPig-Desert': true, 'FlyingPig-Red': true, 'FlyingPig-Shade': true, 'FlyingPig-Skeleton': true, 'FlyingPig-Zombie': true, 'FlyingPig-CottonCandyPink': true, 'FlyingPig-CottonCandyBlue': true, 'FlyingPig-Golden': true, 'Dragon-Base': true, 'Dragon-White': true, 'Dragon-Desert': true, 'Dragon-Red': true, 'Dragon-Shade': true, 'Dragon-Skeleton': true, 'Dragon-Zombie': true, 'Dragon-CottonCandyPink': true, 'Dragon-CottonCandyBlue': true, 'Dragon-Golden': true, 'Cactus-Base': true, 'Cactus-White': true, 'Cactus-Desert': true, 'Cactus-Red': true, 'Cactus-Shade': true, 'Cactus-Skeleton': true, 'Cactus-Zombie': true, 'Cactus-CottonCandyPink': true, 'Cactus-CottonCandyBlue': true, 'Cactus-Golden': true, 'BearCub-Base': true, 'BearCub-White': true, 'BearCub-Desert': true, 'BearCub-Red': true, 'BearCub-Shade': true, 'BearCub-Skeleton': true, 'BearCub-Zombie': true, 'BearCub-CottonCandyPink': true, 'BearCub-CottonCandyBlue': true, 'BearCub-Golden': true }
|
||||
expect(shared.countMounts(null,user.items.mounts)).to.eql 89
|
||||
expect(shared.countMounts(_.size(user.items.mounts), user.items.mounts)).to.eql 89
|
||||
expect(user.achievements.mountMaster).to.not.be.ok()
|
||||
|
||||
it 'does not get mountMaster with 89 drop pets + 1 mantis shrimp', ->
|
||||
user = newUser()
|
||||
user.items.mounts = {'MantisShrimp-Base': true, 'Wolf-White': true, 'Wolf-Desert': true, 'Wolf-Red': true, 'Wolf-Shade': true, 'Wolf-Skeleton': true, 'Wolf-Zombie': true, 'Wolf-CottonCandyPink': true, 'Wolf-CottonCandyBlue': true, 'Wolf-Golden': true, 'TigerCub-Base': true, 'TigerCub-White': true, 'TigerCub-Desert': true, 'TigerCub-Red': true, 'TigerCub-Shade': true, 'TigerCub-Skeleton': true, 'TigerCub-Zombie': true, 'TigerCub-CottonCandyPink': true, 'TigerCub-CottonCandyBlue': true, 'TigerCub-Golden': true, 'PandaCub-Base': true, 'PandaCub-White': true, 'PandaCub-Desert': true, 'PandaCub-Red': true, 'PandaCub-Shade': true, 'PandaCub-Skeleton': true, 'PandaCub-Zombie': true, 'PandaCub-CottonCandyPink': true, 'PandaCub-CottonCandyBlue': true, 'PandaCub-Golden': true, 'LionCub-Base': true, 'LionCub-White': true, 'LionCub-Desert': true, 'LionCub-Red': true, 'LionCub-Shade': true, 'LionCub-Skeleton': true, 'LionCub-Zombie': true, 'LionCub-CottonCandyPink': true, 'LionCub-CottonCandyBlue': true, 'LionCub-Golden': true, 'Fox-Base': true, 'Fox-White': true, 'Fox-Desert': true, 'Fox-Red': true, 'Fox-Shade': true, 'Fox-Skeleton': true, 'Fox-Zombie': true, 'Fox-CottonCandyPink': true, 'Fox-CottonCandyBlue': true, 'Fox-Golden': true, 'FlyingPig-Base': true, 'FlyingPig-White': true, 'FlyingPig-Desert': true, 'FlyingPig-Red': true, 'FlyingPig-Shade': true, 'FlyingPig-Skeleton': true, 'FlyingPig-Zombie': true, 'FlyingPig-CottonCandyPink': true, 'FlyingPig-CottonCandyBlue': true, 'FlyingPig-Golden': true, 'Dragon-Base': true, 'Dragon-White': true, 'Dragon-Desert': true, 'Dragon-Red': true, 'Dragon-Shade': true, 'Dragon-Skeleton': true, 'Dragon-Zombie': true, 'Dragon-CottonCandyPink': true, 'Dragon-CottonCandyBlue': true, 'Dragon-Golden': true, 'Cactus-Base': true, 'Cactus-White': true, 'Cactus-Desert': true, 'Cactus-Red': true, 'Cactus-Shade': true, 'Cactus-Skeleton': true, 'Cactus-Zombie': true, 'Cactus-CottonCandyPink': true, 'Cactus-CottonCandyBlue': true, 'Cactus-Golden': true, 'BearCub-Base': true, 'BearCub-White': true, 'BearCub-Desert': true, 'BearCub-Red': true, 'BearCub-Shade': true, 'BearCub-Skeleton': true, 'BearCub-Zombie': true, 'BearCub-CottonCandyPink': true, 'BearCub-CottonCandyBlue': true, 'BearCub-Golden': true }
|
||||
expect(shared.countMounts(null,user.items.mounts)).to.eql 89
|
||||
expect(shared.countMounts(_.size(user.items.mounts), user.items.mounts)).to.eql 89
|
||||
expect(user.achievements.mountMaster).to.not.be.ok()
|
||||
|
||||
xit 'does get mountMaster', ->
|
||||
user = newUser()
|
||||
user.items.mounts = {'Wolf-Base': true, 'Wolf-White': true, 'Wolf-Desert': true, 'Wolf-Red': true, 'Wolf-Shade': true, 'Wolf-Skeleton': true, 'Wolf-Zombie': true, 'Wolf-CottonCandyPink': true, 'Wolf-CottonCandyBlue': true, 'Wolf-Golden': true, 'TigerCub-Base': true, 'TigerCub-White': true, 'TigerCub-Desert': true, 'TigerCub-Red': true, 'TigerCub-Shade': true, 'TigerCub-Skeleton': true, 'TigerCub-Zombie': true, 'TigerCub-CottonCandyPink': true, 'TigerCub-CottonCandyBlue': true, 'TigerCub-Golden': true, 'PandaCub-Base': true, 'PandaCub-White': true, 'PandaCub-Desert': true, 'PandaCub-Red': true, 'PandaCub-Shade': true, 'PandaCub-Skeleton': true, 'PandaCub-Zombie': true, 'PandaCub-CottonCandyPink': true, 'PandaCub-CottonCandyBlue': true, 'PandaCub-Golden': true, 'LionCub-Base': true, 'LionCub-White': true, 'LionCub-Desert': true, 'LionCub-Red': true, 'LionCub-Shade': true, 'LionCub-Skeleton': true, 'LionCub-Zombie': true, 'LionCub-CottonCandyPink': true, 'LionCub-CottonCandyBlue': true, 'LionCub-Golden': true, 'Fox-Base': true, 'Fox-White': true, 'Fox-Desert': true, 'Fox-Red': true, 'Fox-Shade': true, 'Fox-Skeleton': true, 'Fox-Zombie': true, 'Fox-CottonCandyPink': true, 'Fox-CottonCandyBlue': true, 'Fox-Golden': true, 'FlyingPig-Base': true, 'FlyingPig-White': true, 'FlyingPig-Desert': true, 'FlyingPig-Red': true, 'FlyingPig-Shade': true, 'FlyingPig-Skeleton': true, 'FlyingPig-Zombie': true, 'FlyingPig-CottonCandyPink': true, 'FlyingPig-CottonCandyBlue': true, 'FlyingPig-Golden': true, 'Dragon-Base': true, 'Dragon-White': true, 'Dragon-Desert': true, 'Dragon-Red': true, 'Dragon-Shade': true, 'Dragon-Skeleton': true, 'Dragon-Zombie': true, 'Dragon-CottonCandyPink': true, 'Dragon-CottonCandyBlue': true, 'Dragon-Golden': true, 'Cactus-Base': true, 'Cactus-White': true, 'Cactus-Desert': true, 'Cactus-Red': true, 'Cactus-Shade': true, 'Cactus-Skeleton': true, 'Cactus-Zombie': true, 'Cactus-CottonCandyPink': true, 'Cactus-CottonCandyBlue': true, 'Cactus-Golden': true, 'BearCub-Base': true, 'BearCub-White': true, 'BearCub-Desert': true, 'BearCub-Red': true, 'BearCub-Shade': true, 'BearCub-Skeleton': true, 'BearCub-Zombie': true, 'BearCub-CottonCandyPink': true, 'BearCub-CottonCandyBlue': true, 'BearCub-Golden': true }
|
||||
expect(shared.countMounts(null,user.items.mounts)).to.eql 90
|
||||
expect(shared.countMounts(_.size(user.items.mounts), user.items.mounts)).to.eql 90
|
||||
expect(user.achievements.mountMaster).to.be.ok()
|
||||
|
||||
describe 'Simple Scoring', ->
|
||||
beforeEach ->
|
||||
{@before, @after} = beforeAfter()
|
||||
@@ -1023,37 +967,3 @@ describe 'Helper', ->
|
||||
expect(shared.startOfDay({now: new Date(2013, 0, 1, 0)}, timezoneOffset:zone).format(fstr)).to.eql today
|
||||
expect(shared.startOfDay({now: new Date(2013, 0, 1, 5)}, timezoneOffset:zone).format(fstr)).to.eql today
|
||||
expect(shared.startOfDay({now: new Date(2013, 0, 1, 23, 59, 59), timezoneOffset:zone}).format(fstr)).to.eql today
|
||||
|
||||
it 'counts pets', ->
|
||||
pets = {}
|
||||
expect(shared.countPets(null, pets)).to.eql 0
|
||||
expect(shared.countPets(1, pets)).to.eql 1
|
||||
|
||||
pets = { "Dragon-Red": 1, "Wolf-Base": 2 }
|
||||
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": true, "Wolf-Base": true }
|
||||
expect(shared.countMounts(null, mounts)).to.eql 2
|
||||
expect(shared.countMounts(2, mounts)).to.eql 2
|
||||
|
||||
mounts = { "Dragon-Red": true, "Gryphon-Base": true }
|
||||
expect(shared.countMounts(null, mounts)).to.eql 1
|
||||
expect(shared.countMounts(_.size(mounts), mounts)).to.eql 1
|
||||
|
||||
mounts = { "Wolf-Base": true, "BearCub-Polar": true}
|
||||
expect(shared.countMounts(null, mounts)).to.eql 1
|
||||
expect(shared.countMounts(_.size(mounts), mounts)).to.eql 1
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
var sinon = require('sinon');
|
||||
var chai = require("chai")
|
||||
chai.use(require("sinon-chai"))
|
||||
var expect = chai.expect
|
||||
|
||||
require('coffee-script');
|
||||
var count = require('../../common/script/count');
|
||||
|
||||
describe('count', function() {
|
||||
describe('beastMasterProgress', function() {
|
||||
it('returns 0 if no pets', function() {
|
||||
var pets = {};
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(0);
|
||||
});
|
||||
|
||||
it('counts drop pets', function() {
|
||||
var pets = { "Dragon-Red": 1, "Wolf-Base": 2 };
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(2);
|
||||
});
|
||||
|
||||
it('does not count quest pets', function() {
|
||||
var pets = { "Dragon-Red": 1, "Gryphon-Base": 1 };
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(1);
|
||||
});
|
||||
|
||||
it('does not count special pets', function() {
|
||||
var pets = {
|
||||
"Wolf-Base": 2,
|
||||
"Wolf-Veteran": 1,
|
||||
"Wolf-Cerberus": 1,
|
||||
"Dragon-Hydra": 1
|
||||
};
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(1);
|
||||
});
|
||||
|
||||
it('counts drop pets that have been raised to a mount', function() {
|
||||
var raisedToMount = -1;
|
||||
var pets = { "Dragon-Red": 1, "Wolf-Base": raisedToMount };
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(2);
|
||||
});
|
||||
|
||||
it('does not counts drop pets that have been released', function() {
|
||||
var releasedPet = 0;
|
||||
var pets = { "Dragon-Red": 1, "Wolf-Base": releasedPet };
|
||||
var beastMasterTotal = count.beastMasterProgress(pets);
|
||||
expect(beastMasterTotal).to.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mountMasterProgress', function() {
|
||||
it('returns 0 if no mounts', function() {
|
||||
var mounts = {};
|
||||
var mountMasterTotal = count.mountMasterProgress(mounts);
|
||||
expect(mountMasterTotal).to.eql(0);
|
||||
});
|
||||
|
||||
it('counts drop mounts', function() {
|
||||
var mounts = { "Dragon-Red": true, "Wolf-Base": true };
|
||||
var mountMasterTotal = count.mountMasterProgress(mounts);
|
||||
expect(mountMasterTotal).to.eql(2);
|
||||
});
|
||||
|
||||
it('does not count quest mounts', function() {
|
||||
var mounts = { "Dragon-Red": true, "Gryphon-Base": true };
|
||||
var mountMasterTotal = count.mountMasterProgress(mounts);
|
||||
expect(mountMasterTotal).to.eql(1);
|
||||
});
|
||||
|
||||
it('does not count special mounts', function() {
|
||||
var mounts = { "Wolf-Base": true, "BearCub-Polar": true};
|
||||
var mountMasterTotal = count.mountMasterProgress(mounts);
|
||||
expect(mountMasterTotal).to.eql(1);
|
||||
});
|
||||
|
||||
it('only counts drop mounts that are currently owned', function() {
|
||||
var notCurrentlyOwned = false;
|
||||
var mounts = { "Dragon-Red": true, "Wolf-Base": notCurrentlyOwned };
|
||||
var mountMasterTotal = count.mountMasterProgress(mounts);
|
||||
expect(mountMasterTotal).to.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remainingGearInSet', function() {
|
||||
it('counts remaining gear based on set', function() {
|
||||
var gear = {
|
||||
'weapon_wizard_0':true,
|
||||
'weapon_wizard_1':true,
|
||||
'weapon_warrior_0':true,
|
||||
'weapon_warrior_1':true,
|
||||
'weapon_armor_0':true,
|
||||
'weapon_armor_1':true
|
||||
};
|
||||
|
||||
var armoireCount = count.remainingGearInSet(gear, 'warrior');
|
||||
expect(armoireCount).to.eql(20);
|
||||
});
|
||||
|
||||
it('includes previously owned items in count', function() {
|
||||
var gear = {
|
||||
'weapon_warrior_0':false,
|
||||
'weapon_warrior_1':false,
|
||||
'weapon_armor_0':true,
|
||||
'weapon_armor_1':true
|
||||
};
|
||||
|
||||
var armoireCount = count.remainingGearInSet(gear, 'warrior');
|
||||
expect(armoireCount).to.eql(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dropPetsCurrentlyOwned', function() {
|
||||
it('counts drop pets owned', function() {
|
||||
var pets = {
|
||||
"Wolf-Base": 2,
|
||||
"Wolf-Red": 4
|
||||
};
|
||||
var dropPets = count.dropPetsCurrentlyOwned(pets);
|
||||
expect(dropPets).to.eql(2);
|
||||
});
|
||||
|
||||
it('does not count pets that have been raised to mounts', function() {
|
||||
var pets = {
|
||||
"Wolf-Base": -1,
|
||||
"Wolf-Red": 4,
|
||||
"Wolf-Veteran": 1,
|
||||
"Gryphon-Base": 1
|
||||
};
|
||||
var dropPets = count.dropPetsCurrentlyOwned(pets);
|
||||
expect(dropPets).to.eql(1);
|
||||
});
|
||||
|
||||
it('does not count quest pets', function() {
|
||||
var pets = {
|
||||
"Wolf-Base": 2,
|
||||
"Wolf-Red": 4,
|
||||
"Gryphon-Base": 1
|
||||
};
|
||||
var dropPets = count.dropPetsCurrentlyOwned(pets);
|
||||
expect(dropPets).to.eql(2);
|
||||
});
|
||||
|
||||
it('does not count special pets', function() {
|
||||
var pets = {
|
||||
"Wolf-Base": 2,
|
||||
"Wolf-Red": 4,
|
||||
"Wolf-Veteran": 1
|
||||
};
|
||||
var dropPets = count.dropPetsCurrentlyOwned(pets);
|
||||
expect(dropPets).to.eql(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -8,30 +8,59 @@ describe('memberServices', function() {
|
||||
members = Members;
|
||||
}));
|
||||
|
||||
afterEach(function() {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
|
||||
|
||||
it('has no members at the beginning', function() {
|
||||
expect(members.members).to.be.an('object');
|
||||
expect(members.members).to.eql({});
|
||||
expect(members.selectedMember).to.be.undefined;
|
||||
});
|
||||
|
||||
it('populates members', function(){
|
||||
var uid = 'abc';
|
||||
members.populate({
|
||||
members: [{ _id: uid }]
|
||||
});
|
||||
expect(members.members).to.eql({
|
||||
abc: { _id: uid }
|
||||
describe('addToMembersList', function() {
|
||||
it('adds member to members object', function() {
|
||||
var member = { _id: 'user_id' };
|
||||
members.addToMembersList(member);
|
||||
expect(members.members).to.eql({
|
||||
user_id: { _id: 'user_id' }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('selects a member', function(){
|
||||
var uid = 'abc';
|
||||
$httpBackend.expectGET('/api/v2/members/' + uid).respond({ _id: uid });
|
||||
members.selectMember(uid, function(){});
|
||||
$httpBackend.flush();
|
||||
describe('selectMember', function() {
|
||||
it('fetches member if not already in cache', function() {
|
||||
var uid = 'abc';
|
||||
$httpBackend.expectGET('/api/v2/members/' + uid).respond({ _id: uid });
|
||||
members.selectMember(uid, function(){});
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(members.selectedMember._id).to.eql(uid);
|
||||
expect(members.members).to.have.property(uid);
|
||||
expect(members.selectedMember._id).to.eql(uid);
|
||||
expect(members.members).to.have.property(uid);
|
||||
});
|
||||
|
||||
it('fetches member if member data in cache is incomplete', function() {
|
||||
var uid = 'abc';
|
||||
members.members = {
|
||||
abc: { _id: 'abc', items: {} }
|
||||
}
|
||||
$httpBackend.expectGET('/api/v2/members/' + uid).respond({ _id: uid });
|
||||
members.selectMember(uid, function(){});
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(members.selectedMember._id).to.eql(uid);
|
||||
expect(members.members).to.have.property(uid);
|
||||
});
|
||||
|
||||
it('gets member from cache if member has a weapons object', function() {
|
||||
var uid = 'abc';
|
||||
members.members[uid] = { _id: uid, items: { weapon: {} } };
|
||||
members.selectMember(uid, function(){
|
||||
expect(members.selectedMember._id).to.eql(uid);
|
||||
expect(members.members).to.have.property(uid);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
'use strict';
|
||||
|
||||
describe('Stats Service', function() {
|
||||
var scope, statCalc, user;
|
||||
|
||||
beforeEach(function() {
|
||||
user = specHelper.newUser();
|
||||
|
||||
module(function($provide) {
|
||||
$provide.value('User', {user: user});
|
||||
});
|
||||
|
||||
inject(function($rootScope, $controller, Stats) {
|
||||
statCalc = Stats;
|
||||
});
|
||||
});
|
||||
|
||||
describe('beastMasterProgress', function() {
|
||||
it('counts drop pets that user has', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : 5,
|
||||
"BearCub-CottonCandyBlue" : 5,
|
||||
"Cactus-Zombie" : 5,
|
||||
"Deer-Golden" : 5,
|
||||
"Deer-Red" : 5,
|
||||
"Egg-Desert" : 5,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
|
||||
|
||||
expect(beastMasterDisplay).to.eql('3/90');
|
||||
});
|
||||
|
||||
it('counts drop pets with a value of -1', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : -1,
|
||||
"BearCub-CottonCandyBlue" : -1,
|
||||
"Cactus-Zombie" : 5,
|
||||
"Deer-Golden" : 5,
|
||||
"Deer-Red" : 5,
|
||||
"Egg-Desert" : 5,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
|
||||
|
||||
expect(beastMasterDisplay).to.eql('3/90');
|
||||
});
|
||||
|
||||
it('does not count drop pets with a value of 0', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : 0,
|
||||
"BearCub-CottonCandyBlue" : 0,
|
||||
"Cactus-Zombie" : 5,
|
||||
"Deer-Golden" : 5,
|
||||
"Deer-Red" : 5,
|
||||
"Egg-Desert" : 5,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
|
||||
|
||||
expect(beastMasterDisplay).to.eql('1/90');
|
||||
});
|
||||
});
|
||||
|
||||
describe('classBonus', function() {
|
||||
it('calculates class bonus', function() {
|
||||
var equippedGear = {
|
||||
"weapon" : "weapon_warrior_1",
|
||||
"shield" : "shield_warrior_1",
|
||||
"head" : "head_warrior_1",
|
||||
"armor" : "armor_warrior_1"
|
||||
};
|
||||
var user = {
|
||||
_statsComputed: { str: 50 },
|
||||
stats: {
|
||||
lvl: 10,
|
||||
buffs: { str: 10 },
|
||||
str: 10
|
||||
},
|
||||
items: {
|
||||
gear: { equipped: equippedGear }
|
||||
}
|
||||
};
|
||||
var stat = 'str';
|
||||
var classBonus = statCalc.classBonus(user, stat);
|
||||
|
||||
expect(classBonus).to.eql(20)
|
||||
});
|
||||
|
||||
it('does not return value if user has not been wrapped (_statComputed)', function() {
|
||||
var equippedGear = {
|
||||
"weapon" : "weapon_warrior_1",
|
||||
"shield" : "shield_warrior_1",
|
||||
"head" : "head_warrior_1",
|
||||
"armor" : "armor_warrior_1"
|
||||
};
|
||||
var user = {
|
||||
stats: {
|
||||
lvl: 10,
|
||||
buffs: { str: 10 },
|
||||
str: 10
|
||||
},
|
||||
items: {
|
||||
gear: { equipped: equippedGear }
|
||||
}
|
||||
};
|
||||
var stat = 'str';
|
||||
var classBonus = statCalc.classBonus(user, stat);
|
||||
|
||||
expect(classBonus).to.not.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe('expDisplay', function() {
|
||||
it('displays exp as "exp / toNextLevelExp"', function() {
|
||||
user.stats.exp = 10;
|
||||
user.stats.lvl = 29;
|
||||
var expDisplay = statCalc.expDisplay(user);
|
||||
|
||||
expect(expDisplay).to.eql('10/640');
|
||||
});
|
||||
|
||||
it('Rounds exp down when given a decimal', function() {
|
||||
user.stats.exp = 10.999;
|
||||
user.stats.lvl = 29;
|
||||
var expDisplay = statCalc.expDisplay(user);
|
||||
|
||||
expect(expDisplay).to.eql('10/640');
|
||||
});
|
||||
});
|
||||
|
||||
describe('equipmentStatBonus', function() {
|
||||
it('tallies up stats from euqipment that is equipped', function() {
|
||||
var equippedGear = {
|
||||
"weapon" : "weapon_special_1",
|
||||
"shield" : "shield_special_1",
|
||||
"head" : "head_special_1",
|
||||
"armor" : "armor_special_1"
|
||||
};
|
||||
|
||||
var strStat = statCalc.equipmentStatBonus('str', equippedGear);
|
||||
var conStat = statCalc.equipmentStatBonus('con', equippedGear);
|
||||
var intStat = statCalc.equipmentStatBonus('int', equippedGear);
|
||||
var perStat = statCalc.equipmentStatBonus('per', equippedGear);
|
||||
|
||||
expect(strStat).to.eql(24);
|
||||
expect(conStat).to.eql(24);
|
||||
expect(intStat).to.eql(24);
|
||||
expect(perStat).to.eql(24);
|
||||
});
|
||||
});
|
||||
|
||||
describe('goldDisplay', function() {
|
||||
it('displays gold', function() {
|
||||
var gold = 30;
|
||||
var goldDisplay = statCalc.goldDisplay(gold);
|
||||
|
||||
expect(goldDisplay).to.eql(30);
|
||||
});
|
||||
|
||||
it('Rounds gold down when given a decimal', function() {
|
||||
var gold = 30.999;
|
||||
var goldDisplay = statCalc.goldDisplay(gold);
|
||||
|
||||
expect(goldDisplay).to.eql(30);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hpDisplay', function() {
|
||||
it('displays hp as "hp / totalHP"', function() {
|
||||
var hp = 34;
|
||||
var hpDisplay = statCalc.hpDisplay(hp);
|
||||
|
||||
expect(hpDisplay).to.eql('34/50');
|
||||
});
|
||||
|
||||
it('Rounds hp up when given a decimal', function() {
|
||||
|
||||
var hp = 34.4;
|
||||
var hpDisplay = statCalc.hpDisplay(hp);
|
||||
|
||||
expect(hpDisplay).to.eql('35/50');
|
||||
});
|
||||
});
|
||||
|
||||
describe('levelBonus', function() {
|
||||
it('calculates bonus as half of level for even numbered level under 100', function() {
|
||||
var level = 50;
|
||||
var bonus = statCalc.levelBonus(level);
|
||||
expect(bonus).to.eql(25);
|
||||
});
|
||||
|
||||
it('calculates bonus as half of level, rounded down, for odd numbered level under 100', function() {
|
||||
var level = 51;
|
||||
var bonus = statCalc.levelBonus(level);
|
||||
expect(bonus).to.eql(25);
|
||||
});
|
||||
|
||||
it('calculates bonus as 50 for levels >= 100', function() {
|
||||
var level = 150;
|
||||
var bonus = statCalc.levelBonus(level);
|
||||
expect(bonus).to.eql(50);
|
||||
});
|
||||
|
||||
it('calculates bonus as 0 for level 1', function() {
|
||||
var level = 1;
|
||||
var bonus = statCalc.levelBonus(level);
|
||||
expect(bonus).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mountMasterProgress', function() {
|
||||
it('counts drop mounts that user has', function() {
|
||||
user.items.mounts = {
|
||||
"Hedgehog-Desert" : true,
|
||||
"Octopus-CottonCandyPink" : true,
|
||||
"TigerCub-White" : true,
|
||||
"Wolf-Golden" : true,
|
||||
"Owl-CottonCandyBlue" : true,
|
||||
"Mammoth-Base" : true,
|
||||
"Bunny-Skeleton" : true
|
||||
}
|
||||
|
||||
var mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts);
|
||||
|
||||
expect(mountMasterDisplay).to.eql('2/90');
|
||||
});
|
||||
|
||||
it('does not count drop mounts with a value of false', function() {
|
||||
user.items.mounts = {
|
||||
"Hedgehog-Desert" : true,
|
||||
"Octopus-CottonCandyPink" : true,
|
||||
"TigerCub-White" : false,
|
||||
"Wolf-Golden" : false,
|
||||
"Owl-CottonCandyBlue" : true,
|
||||
"Mammoth-Base" : true,
|
||||
"Bunny-Skeleton" : true
|
||||
}
|
||||
|
||||
var mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts);
|
||||
|
||||
expect(mountMasterDisplay).to.eql('0/90');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mpDisplay', function() {
|
||||
it('displays mp as "mp / totalMP"', function() {
|
||||
user._statsComputed = { maxMP: 100 };
|
||||
user.stats.mp = 30;
|
||||
var mpDisplay = statCalc.mpDisplay(user);
|
||||
|
||||
expect(mpDisplay).to.eql('30/100');
|
||||
});
|
||||
|
||||
it('Rounds mp down when given a decimal', function() {
|
||||
user._statsComputed = { maxMP: 100 };
|
||||
user.stats.mp = 30.99;
|
||||
var mpDisplay = statCalc.mpDisplay(user);
|
||||
|
||||
expect(mpDisplay).to.eql('30/100');
|
||||
});
|
||||
});
|
||||
|
||||
describe('totalCount', function() {
|
||||
it('counts all pets that user has', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : 5,
|
||||
"BearCub-CottonCandyBlue" : 5,
|
||||
"Cactus-Zombie" : 5,
|
||||
"Deer-Golden" : 5,
|
||||
"Deer-Red" : 5,
|
||||
"Egg-Desert" : 5,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var petsFound = statCalc.totalCount(user.items.pets);
|
||||
|
||||
expect(petsFound).to.eql(7);
|
||||
});
|
||||
|
||||
it('includes pets that have a value of 0', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : 0,
|
||||
"BearCub-CottonCandyBlue" : 5,
|
||||
"Cactus-Zombie" : 0,
|
||||
"Deer-Golden" : 0,
|
||||
"Deer-Red" : 0,
|
||||
"Egg-Desert" : 0,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var petsFound = statCalc.totalCount(user.items.pets);
|
||||
|
||||
expect(petsFound).to.eql(7);
|
||||
});
|
||||
|
||||
it('includes pets that have a value of -1', function() {
|
||||
user.items.pets = {
|
||||
"BearCub-Base" : -1,
|
||||
"BearCub-CottonCandyBlue" : 5,
|
||||
"Cactus-Zombie" : -1,
|
||||
"Deer-Golden" : -1,
|
||||
"Deer-Red" : -1,
|
||||
"Egg-Desert" : -1,
|
||||
"MantisShrimp-Base" : 5
|
||||
}
|
||||
|
||||
var petsFound = statCalc.totalCount(user.items.pets);
|
||||
|
||||
expect(petsFound).to.eql(7);
|
||||
});
|
||||
|
||||
it('counts all mounts that user has', function() {
|
||||
user.items.mounts = {
|
||||
"Hedgehog-Desert" : true,
|
||||
"Octopus-CottonCandyPink" : true,
|
||||
"TigerCub-White" : true,
|
||||
"Wolf-Golden" : true,
|
||||
"Owl-CottonCandyBlue" : true,
|
||||
"Mammoth-Base" : true,
|
||||
"Bunny-Skeleton" : true
|
||||
}
|
||||
|
||||
var mountsFound = statCalc.totalCount(user.items.mounts);
|
||||
|
||||
expect(mountsFound).to.eql(7);
|
||||
});
|
||||
|
||||
it('inlcudes mounts with a value of false', function() {
|
||||
user.items.mounts = {
|
||||
"Hedgehog-Desert" : false,
|
||||
"Octopus-CottonCandyPink" : true,
|
||||
"TigerCub-White" : false,
|
||||
"Wolf-Golden" : false,
|
||||
"Owl-CottonCandyBlue" : false,
|
||||
"Mammoth-Base" : true,
|
||||
"Bunny-Skeleton" : false
|
||||
}
|
||||
|
||||
var mountsFound = statCalc.totalCount(user.items.mounts);
|
||||
|
||||
expect(mountsFound).to.eql(7);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -159,61 +159,6 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
||||
};
|
||||
}])
|
||||
|
||||
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller',
|
||||
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller) {
|
||||
|
||||
$controller('RootCtrl', {$scope: $scope});
|
||||
|
||||
$scope.timestamp = function(timestamp){
|
||||
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
||||
}
|
||||
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
||||
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
||||
if(member)
|
||||
member.petCount = Shared.countPets($rootScope.countExists(member.items.pets), member.items.pets);
|
||||
member.mountCount = Shared.countMounts($rootScope.countExists(member.items.mounts), member.items.mounts);
|
||||
$scope.profile = member;
|
||||
});
|
||||
$scope.sendPrivateMessage = function(uuid, message){
|
||||
// Don't do anything if the user somehow gets here without a message.
|
||||
if (!message) return;
|
||||
|
||||
$http.post('/api/v2/members/'+uuid+'/message',{message:message}).success(function(){
|
||||
Notification.text(window.env.t('messageSentAlert'));
|
||||
$rootScope.User.sync();
|
||||
$scope.$close();
|
||||
});
|
||||
}
|
||||
$scope.gift = {
|
||||
type: 'gems',
|
||||
gems: {amount:0, fromBalance:true},
|
||||
subscription: {key:''},
|
||||
message:''
|
||||
};
|
||||
$scope.sendGift = function(uuid, gift){
|
||||
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
||||
Notification.text('Gift sent!')
|
||||
$rootScope.User.sync();
|
||||
$scope.$close();
|
||||
})
|
||||
}
|
||||
$scope.reportAbuse = function(reporter, message, groupId) {
|
||||
message.flags[reporter._id] = true;
|
||||
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||
Notification.text(window.env.t('abuseReported'));
|
||||
$scope.$close();
|
||||
});
|
||||
}
|
||||
$scope.clearFlagCount = function(message, groupId) {
|
||||
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||
message.flagCount = 0;
|
||||
Notification.text("Flags cleared");
|
||||
$scope.$close();
|
||||
});
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
.controller('AutocompleteCtrl', ['$scope', '$timeout', 'Groups', 'User', 'InputCaret', function ($scope,$timeout,Groups,User,InputCaret) {
|
||||
$scope.clearUserlist = function() {
|
||||
$scope.response = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
habitrpg.controller("InventoryCtrl",
|
||||
['$rootScope', '$scope', 'Shared', '$window', 'User', 'Content', 'Analytics', 'Quests',
|
||||
function($rootScope, $scope, Shared, $window, User, Content, Analytics, Quests) {
|
||||
['$rootScope', '$scope', 'Shared', '$window', 'User', 'Content', 'Analytics', 'Quests', 'Stats',
|
||||
function($rootScope, $scope, Shared, $window, User, Content, Analytics, Quests, Stats) {
|
||||
|
||||
var user = User.user;
|
||||
|
||||
@@ -8,8 +8,8 @@ habitrpg.controller("InventoryCtrl",
|
||||
|
||||
$scope.selectedEgg = null; // {index: 1, name: "Tiger", value: 5}
|
||||
$scope.selectedPotion = null; // {index: 5, name: "Red", value: 3}
|
||||
$scope.totalPets = _.size(Content.dropEggs) * _.size(Content.hatchingPotions);
|
||||
$scope.totalMounts = _.size(Content.dropEggs) * _.size(Content.hatchingPotions);
|
||||
|
||||
_updateDropAnimalCount(user.items);
|
||||
|
||||
// Functions from Quests service
|
||||
$scope.lockQuest = Quests.lockQuest;
|
||||
@@ -93,19 +93,19 @@ habitrpg.controller("InventoryCtrl",
|
||||
$scope.selectedEgg = null;
|
||||
$scope.selectedPotion = null;
|
||||
|
||||
$rootScope.petCount = Shared.countPets($rootScope.countExists(User.user.items.pets), User.user.items.pets);
|
||||
_updateDropAnimalCount(user.items);
|
||||
|
||||
// Checks if beastmaster has been reached for the first time
|
||||
if(!User.user.achievements.beastMaster
|
||||
&& $rootScope.petCount >= 90) {
|
||||
if(!user.achievements.beastMaster
|
||||
&& $scope.petCount >= 90) {
|
||||
User.user.achievements.beastMaster = true;
|
||||
$rootScope.openModal('achievements/beastMaster');
|
||||
}
|
||||
|
||||
// Checks if Triad Bingo has been reached for the first time
|
||||
if(!User.user.achievements.triadBingo
|
||||
&& $rootScope.mountCount >= 90
|
||||
&& Shared.countTriad(User.user.items.pets) >= 90) {
|
||||
if(!user.achievements.triadBingo
|
||||
&& $scope.mountCount >= 90
|
||||
&& Shared.count.dropPetsCurrentlyOwned(User.user.items.pets) >= 90) {
|
||||
User.user.achievements.triadBingo = true;
|
||||
$rootScope.openModal('achievements/triadBingo');
|
||||
}
|
||||
@@ -128,14 +128,15 @@ habitrpg.controller("InventoryCtrl",
|
||||
}
|
||||
User.user.ops.feed({params:{pet: pet, food: food.key}});
|
||||
$scope.selectedFood = null;
|
||||
$rootScope.mountCount = Shared.countMounts($rootScope.countExists(User.user.items.mounts), User.user.items.mounts);
|
||||
|
||||
// Checks if mountmaster has been reached for the first time
|
||||
if(!User.user.achievements.mountMaster
|
||||
&& $rootScope.mountCount >= 90) {
|
||||
User.user.achievements.mountMaster = true;
|
||||
$rootScope.openModal('achievements/mountMaster');
|
||||
}
|
||||
_updateDropAnimalCount(user.items);
|
||||
|
||||
// Checks if mountmaster has been reached for the first time
|
||||
if(!user.achievements.mountMaster
|
||||
&& $scope.mountCount >= 90) {
|
||||
User.user.achievements.mountMaster = true;
|
||||
$rootScope.openModal('achievements/mountMaster');
|
||||
}
|
||||
|
||||
// Selecting Pet
|
||||
} else {
|
||||
@@ -204,5 +205,12 @@ habitrpg.controller("InventoryCtrl",
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
function _updateDropAnimalCount(items) {
|
||||
$scope.petCount = Shared.count.beastMasterProgress(items.pets);
|
||||
$scope.mountCount = Shared.count.mountMasterProgress(items.mounts);
|
||||
$scope.beastMasterProgress = Stats.beastMasterProgress(items.pets);
|
||||
$scope.mountMasterProgress = Stats.mountMasterProgress(items.mounts);
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
habitrpg
|
||||
.controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', 'Chat', '$controller', 'Stats',
|
||||
function($scope, $rootScope, Members, Shared, $http, Notification, Groups, Chat, $controller, Stats) {
|
||||
|
||||
$controller('RootCtrl', {$scope: $scope});
|
||||
|
||||
$scope.timestamp = function(timestamp){
|
||||
return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase());
|
||||
}
|
||||
|
||||
$scope.statCalc = Stats;
|
||||
|
||||
// We watch Members.selectedMember because it's asynchronously set, so would be a hassle to handle updates here
|
||||
$scope.$watch( function() { return Members.selectedMember; }, function (member) {
|
||||
if(member) {
|
||||
$scope.profile = member;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.sendPrivateMessage = function(uuid, message){
|
||||
// Don't do anything if the user somehow gets here without a message.
|
||||
if (!message) return;
|
||||
|
||||
$http.post('/api/v2/members/'+uuid+'/message',{message:message}).success(function(){
|
||||
Notification.text(window.env.t('messageSentAlert'));
|
||||
$rootScope.User.sync();
|
||||
$scope.$close();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.gift = {
|
||||
type: 'gems',
|
||||
gems: {amount:0, fromBalance:true},
|
||||
subscription: {key:''},
|
||||
message:''
|
||||
};
|
||||
|
||||
$scope.sendGift = function(uuid, gift){
|
||||
$http.post('/api/v2/members/'+uuid+'/gift', gift).success(function(){
|
||||
Notification.text('Gift sent!')
|
||||
$rootScope.User.sync();
|
||||
$scope.$close();
|
||||
})
|
||||
};
|
||||
|
||||
$scope.reportAbuse = function(reporter, message, groupId) {
|
||||
message.flags[reporter._id] = true;
|
||||
Chat.utils.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||
Notification.text(window.env.t('abuseReported'));
|
||||
$scope.$close();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.clearFlagCount = function(message, groupId) {
|
||||
Chat.utils.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){
|
||||
message.flagCount = 0;
|
||||
Notification.text("Flags cleared");
|
||||
$scope.$close();
|
||||
});
|
||||
}
|
||||
}
|
||||
]);
|
||||
@@ -89,9 +89,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
// count pets, mounts collected totals, etc
|
||||
$rootScope.countExists = function(items) {return _.reduce(items,function(m,v){return m+(v?1:0)},0)}
|
||||
|
||||
$rootScope.petCount = Shared.countPets($rootScope.countExists(User.user.items.pets), User.user.items.pets);
|
||||
$rootScope.mountCount = Shared.countMounts($rootScope.countExists(User.user.items.mounts), User.user.items.mounts);
|
||||
|
||||
$scope.safeApply = function(fn) {
|
||||
var phase = this.$root.$$phase;
|
||||
if(phase == '$apply' || phase == '$digest') {
|
||||
|
||||
@@ -162,13 +162,11 @@ habitrpg.controller('SettingsCtrl',
|
||||
|
||||
$scope.releaseMounts = function() {
|
||||
User.user.ops.releaseMounts({});
|
||||
$rootScope.mountCount = 0;
|
||||
$rootScope.$state.go('tasks');
|
||||
}
|
||||
|
||||
$scope.releaseBoth = function() {
|
||||
User.user.ops.releaseBoth({});
|
||||
$rootScope.mountCount = 0;
|
||||
$rootScope.$state.go('tasks');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
|
||||
$scope.user = User.user;
|
||||
|
||||
$scope.armoireCount = function(gear) {
|
||||
return Shared.countArmoire(gear);
|
||||
return Shared.count.remainingGearInSet(gear, 'armoire');
|
||||
};
|
||||
|
||||
$scope.score = function(task, direction) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared',
|
||||
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared) {
|
||||
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared', 'Content', 'Stats',
|
||||
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared, Content, Stats) {
|
||||
$scope.profile = User.user;
|
||||
$scope.profile.petCount = Shared.countPets($rootScope.countExists($scope.profile.items.pets), $scope.profile.items.pets);
|
||||
$scope.profile.mountCount = Shared.countMounts($rootScope.countExists($scope.profile.items.mounts), $scope.profile.items.mounts);
|
||||
|
||||
$scope.statCalc = Stats;
|
||||
|
||||
$scope.hideUserAvatar = function() {
|
||||
$(".userAvatar").hide();
|
||||
};
|
||||
|
||||
@@ -1,87 +1,60 @@
|
||||
'use strict';
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.factory('Members', membersFactory);
|
||||
|
||||
/**
|
||||
* Services that persists and retrieves user from localStorage.
|
||||
*/
|
||||
membersFactory.$inject = [
|
||||
'$rootScope',
|
||||
'Shared',
|
||||
'ApiUrl',
|
||||
'$resource'
|
||||
];
|
||||
|
||||
angular.module('habitrpg').factory('Members',
|
||||
['$rootScope', 'Shared', 'ApiUrl', '$resource',
|
||||
function($rootScope, Shared, ApiUrl, $resource) {
|
||||
var members = {};
|
||||
var Member = $resource(ApiUrl.get() + '/api/v2/members/:uid', {uid:'@_id'});
|
||||
var memberServices = {
|
||||
function membersFactory($rootScope, Shared, ApiUrl, $resource) {
|
||||
var members = {};
|
||||
var fetchMember = $resource(ApiUrl.get() + '/api/v2/members/:uid', { uid: '@_id' }).get;
|
||||
|
||||
Member: Member,
|
||||
function selectMember(uid, cb) {
|
||||
|
||||
members: members,
|
||||
|
||||
/**
|
||||
* Allows us to lazy-load party / group / public members throughout the application.
|
||||
* @param obj - either a group or an individual member. If it's a group, we lazy-load all of its members.
|
||||
*/
|
||||
populate: function(obj){
|
||||
|
||||
function populateGroup(group){
|
||||
_.each(group.members, function(member){
|
||||
// meaning `populate('members')` wasn't run on the server, so we're getting the "in-database" form of
|
||||
// the members array, which is just a list of IDs - not the populated objects
|
||||
if (_.isString(member)) return;
|
||||
|
||||
// lazy-load
|
||||
members[member._id] = member;
|
||||
})
|
||||
}
|
||||
|
||||
// Array of groups
|
||||
if (_.isArray(obj)) {
|
||||
if (obj[0] && obj[0].members) {
|
||||
_.each(obj, function(group){
|
||||
populateGroup(group);
|
||||
})
|
||||
}
|
||||
|
||||
// Individual Group
|
||||
} else if (obj.members)
|
||||
populateGroup(obj);
|
||||
|
||||
// individual Member
|
||||
if (obj._id) {
|
||||
members[obj._id] = obj;
|
||||
}
|
||||
},
|
||||
|
||||
selectedMember: undefined,
|
||||
|
||||
/**
|
||||
* Once users are populated, we fetch them throughout the application (eg, modals). This
|
||||
* either gets them or fetches if not available
|
||||
* @param uid
|
||||
*/
|
||||
selectMember: function(uid, cb) {
|
||||
var self = this;
|
||||
// Fetch from cache if we can. For guild members, only their uname will have been fetched on initial load,
|
||||
// check if they have full fields (eg, check profile.items and an item inside
|
||||
// because sometimes profile.items exists but it's empty like when user is fetched for party
|
||||
// and then for guild)
|
||||
// and if not, fetch them
|
||||
if (members[uid] && members[uid].items && members[uid].items.weapon) {
|
||||
Shared.wrap(members[uid],false);
|
||||
self.selectedMember = members[uid];
|
||||
cb();
|
||||
var memberIsReady = _checkIfMemberIsReady(members[uid]);
|
||||
|
||||
if (memberIsReady) {
|
||||
_prepareMember(self, members[uid], cb);
|
||||
} else {
|
||||
Member.get({uid: uid}, function(member){
|
||||
self.populate(member); // lazy load for later
|
||||
Shared.wrap(member,false);
|
||||
self.selectedMember = members[member._id];
|
||||
cb();
|
||||
fetchMember({ uid: uid }, function(member) {
|
||||
addToMembersList(member); // lazy load for later
|
||||
_prepareMember(self, member, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function addToMembersList(member){
|
||||
if (member._id) {
|
||||
members[member._id] = member;
|
||||
}
|
||||
}
|
||||
|
||||
function _checkIfMemberIsReady(member) {
|
||||
return member && member.items && member.items.weapon;
|
||||
}
|
||||
|
||||
function _prepareMember(self, member, cb) {
|
||||
Shared.wrap(member, false);
|
||||
self.selectedMember = members[member._id];
|
||||
cb();
|
||||
}
|
||||
|
||||
$rootScope.$on('userUpdated', function(event, user){
|
||||
addToMembersList(user);
|
||||
})
|
||||
|
||||
return {
|
||||
members: members,
|
||||
addToMembersList: addToMembersList,
|
||||
selectedMember: undefined,
|
||||
selectMember: selectMember
|
||||
}
|
||||
}
|
||||
|
||||
$rootScope.$on('userUpdated', function(event, user){
|
||||
memberServices.populate(user);
|
||||
})
|
||||
|
||||
return memberServices;
|
||||
}]);
|
||||
}());
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Created by Sabe on 7/7/2015.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.factory('Stats', statsFactory);
|
||||
|
||||
statsFactory.$inject = [
|
||||
'Content',
|
||||
'Shared'
|
||||
];
|
||||
|
||||
function statsFactory(Content, Shared) {
|
||||
var DROP_ANIMALS = _.keys(Content.pets);
|
||||
var TOTAL_NUMBER_OF_DROP_ANIMALS = DROP_ANIMALS.length;
|
||||
|
||||
function beastMasterProgress(pets) {
|
||||
var dropPetsFound = Shared.count.beastMasterProgress(pets);
|
||||
var display = _formatOutOfTotalDisplay(dropPetsFound, TOTAL_NUMBER_OF_DROP_ANIMALS);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function classBonus(user, stat) {
|
||||
var computedStats = user._statsComputed;
|
||||
|
||||
if(computedStats) {
|
||||
var bonus = computedStats[stat]
|
||||
- user.stats.buffs[stat]
|
||||
- levelBonus(user.stats.lvl)
|
||||
- equipmentStatBonus(stat, user.items.gear.equipped)
|
||||
- user.stats[stat];
|
||||
|
||||
return bonus;
|
||||
}
|
||||
}
|
||||
|
||||
function equipmentStatBonus(stat, equipped) {
|
||||
var gear = Content.gear.flat;
|
||||
var total = 0;
|
||||
|
||||
var equipmentTypes = ['weapon', 'armor', 'head', 'shield'];
|
||||
|
||||
_(equipmentTypes).each(function(type) {
|
||||
var equippedItem = equipped[type];
|
||||
if(gear[equippedItem]) {
|
||||
var equipmentStat = gear[equippedItem][stat];
|
||||
|
||||
total += equipmentStat;
|
||||
}
|
||||
});
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
function expDisplay(user) {
|
||||
var exp = Math.floor(user.stats.exp);
|
||||
var toNextLevel = Shared.tnl(user.stats.lvl);
|
||||
var display = _formatOutOfTotalDisplay(exp, toNextLevel);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function goldDisplay(gold) {
|
||||
var display = Math.floor(gold);
|
||||
return display;
|
||||
}
|
||||
|
||||
function hpDisplay(hp) {
|
||||
var remainingHP = Math.ceil(hp);
|
||||
var totalHP = Shared.maxHealth;
|
||||
var display = _formatOutOfTotalDisplay(remainingHP, totalHP);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function levelBonus(level) {
|
||||
// Level bonus is derived by taking the level, subtracting one,
|
||||
// taking the smaller of it or maxLevel (100),
|
||||
// dividing that by two and then raising it to a whole number
|
||||
|
||||
var levelOrMaxLevel = Math.min((level - 1), Shared.maxLevel);
|
||||
var levelDividedByTwo = levelOrMaxLevel / 2;
|
||||
var bonus = Math.ceil(levelDividedByTwo );
|
||||
|
||||
return bonus;
|
||||
}
|
||||
|
||||
function mountMasterProgress(mounts) {
|
||||
var dropMountsFound = Shared.count.mountMasterProgress(mounts);
|
||||
var display = _formatOutOfTotalDisplay(dropMountsFound, TOTAL_NUMBER_OF_DROP_ANIMALS);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function mpDisplay(user) {
|
||||
var remainingMP = Math.floor(user.stats.mp);
|
||||
var totalMP = user._statsComputed.maxMP;
|
||||
var display = _formatOutOfTotalDisplay(remainingMP, totalMP);
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
function totalCount(objectToCount) {
|
||||
var total = _.size(objectToCount);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
function _formatOutOfTotalDisplay(stat, totalStat) {
|
||||
var display = stat + "/" + totalStat;
|
||||
return display;
|
||||
}
|
||||
|
||||
return {
|
||||
beastMasterProgress: beastMasterProgress,
|
||||
classBonus: classBonus,
|
||||
equipmentStatBonus: equipmentStatBonus,
|
||||
expDisplay: expDisplay,
|
||||
goldDisplay: goldDisplay,
|
||||
hpDisplay: hpDisplay,
|
||||
levelBonus: levelBonus,
|
||||
mountMasterProgress: mountMasterProgress,
|
||||
mpDisplay: mpDisplay,
|
||||
totalCount: totalCount
|
||||
}
|
||||
}
|
||||
}());
|
||||
@@ -6,11 +6,12 @@ window.habitrpg = angular.module('habitrpg', ['chieffancypants.loadingBar', 'ui.
|
||||
.constant("STORAGE_SETTINGS_ID", 'habit-mobile-settings')
|
||||
.constant("MOBILE_APP", false)
|
||||
|
||||
.controller("RootCtrl", ['$scope', '$location', '$modal', '$http', function($scope, $location, $modal, $http){
|
||||
.controller("RootCtrl", ['$scope', '$location', '$modal', '$http', 'Stats', function($scope, $location, $modal, $http, Stats){
|
||||
var memberId = $location.search()['memberId'];
|
||||
if (memberId) {
|
||||
$http.get('/api/v2/members/'+memberId).success(function(data, status, headers, config){
|
||||
$scope.profile = data;
|
||||
$scope.profile = window.habitrpgShared.wrap(data, false);
|
||||
$scope.statCalc = Stats;
|
||||
$scope.Content = window.habitrpgShared.content;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/member.html',
|
||||
@@ -18,8 +19,6 @@ window.habitrpg = angular.module('habitrpg', ['chieffancypants.loadingBar', 'ui.
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
$scope.Math = window.Math;
|
||||
}])
|
||||
|
||||
.controller("PlansCtrl", ['$rootScope','Analytics',
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
"js/services/challengeServices.js",
|
||||
"js/services/paymentServices.js",
|
||||
"js/services/questServices.js",
|
||||
"js/services/statServices.js",
|
||||
|
||||
"js/filters/money.js",
|
||||
"js/filters/roundLargeNumbers.js",
|
||||
@@ -70,6 +71,7 @@
|
||||
|
||||
"js/controllers/authCtrl.js",
|
||||
"js/controllers/menuCtrl.js",
|
||||
"js/controllers/memberModalCtrl.js",
|
||||
"js/controllers/notificationCtrl.js",
|
||||
"js/controllers/rootCtrl.js",
|
||||
"js/controllers/settingsCtrl.js",
|
||||
@@ -111,6 +113,8 @@
|
||||
"js/static.js",
|
||||
"js/services/analyticsServices.js",
|
||||
"js/services/notificationServices.js",
|
||||
"js/services/sharedServices.js",
|
||||
"js/services/statServices.js",
|
||||
"common/script/public/userServices.js",
|
||||
"js/controllers/authCtrl.js",
|
||||
"js/controllers/footerCtrl.js"
|
||||
@@ -138,6 +142,8 @@
|
||||
"js/static.js",
|
||||
"js/services/analyticsServices.js",
|
||||
"js/services/notificationServices.js",
|
||||
"js/services/sharedServices.js",
|
||||
"js/services/statServices.js",
|
||||
"common/script/public/userServices.js",
|
||||
"js/controllers/authCtrl.js",
|
||||
"js/controllers/footerCtrl.js"
|
||||
|
||||
@@ -495,30 +495,24 @@ UserSchema.pre('save', function(next) {
|
||||
}
|
||||
|
||||
// Determines if Beast Master should be awarded
|
||||
var petCount = shared.countPets(_.reduce(this.items.pets,function(m,v){
|
||||
//HOTFIX - Remove when solution is found, the first argument passed to reduce is a function
|
||||
if(_.isFunction(v)) return m;
|
||||
return m+(v?1:0)},0), this.items.pets);
|
||||
|
||||
if (petCount >= 90 || this.achievements.beastMasterCount > 0) {
|
||||
this.achievements.beastMaster = true
|
||||
var beastMasterProgress = shared.count.beastMasterProgress(this.items.pets);
|
||||
if (beastMasterProgress >= 90 || this.achievements.beastMasterCount > 0) {
|
||||
this.achievements.beastMaster = true;
|
||||
}
|
||||
|
||||
// Determines if Mount Master should be awarded
|
||||
var mountCount = shared.countMounts(_.reduce(this.items.mounts,function(m,v){
|
||||
//HOTFIX - Remove when solution is found, the first argument passed to reduce is a function
|
||||
if(_.isFunction(v)) return m;
|
||||
return m+(v?1:0)},0), this.items.mounts);
|
||||
var mountMasterProgress = shared.count.mountMasterProgress(this.items.mounts);
|
||||
|
||||
if (mountCount >= 90 || this.achievements.mountMasterCount > 0) {
|
||||
if (mountMasterProgress >= 90 || this.achievements.mountMasterCount > 0) {
|
||||
this.achievements.mountMaster = true
|
||||
}
|
||||
|
||||
// Determines if Triad Bingo should be awarded
|
||||
|
||||
var triadCount = shared.countTriad(this.items.pets);
|
||||
var dropPetCount = shared.count.dropPetsCurrentlyOwned(this.items.pets);
|
||||
var qualifiesForTriad = dropPetCount >= 90 && mountMasterProgress >= 90;
|
||||
|
||||
if ((mountCount >= 90 && triadCount >= 90) || this.achievements.triadBingoCount > 0) {
|
||||
if (qualifiesForTriad || this.achievements.triadBingoCount > 0) {
|
||||
this.achievements.triadBingo = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ mixin mountList(source)
|
||||
a(target='_blank', href='http://www.kickstarter.com/profile/mattboch')=env.t('mattBoch')
|
||||
.popover-content
|
||||
p=env.t('mattShall', {name: "{{user.profile.name}}"})
|
||||
h4= env.t('mountMasterProgress') + ': {{mountCount}} / {{totalMounts}} ' + env.t('mountsTamed')
|
||||
h4= env.t('mountMasterProgress') + ': {{::mountMasterProgress}} ' + env.t('mountsTamed')
|
||||
.row: .col-md-12
|
||||
+mountList(env.Content.dropEggs)
|
||||
.row: .col-md-12
|
||||
|
||||
@@ -22,7 +22,7 @@ mixin petList(source)
|
||||
a(target='_blank', href='http://www.kickstarter.com/profile/mattboch')=env.t('mattBoch')
|
||||
.popover-content
|
||||
p=env.t('mattBochText1')
|
||||
h4=env.t('beastMasterProgress') + ': {{petCount}} / {{totalPets}} ' + env.t('petsFound')
|
||||
h4=env.t('beastMasterProgress') + ': {{::beastMasterProgress}} ' + env.t('petsFound')
|
||||
|
||||
.row: .col-md-12
|
||||
+petList(env.Content.dropEggs)
|
||||
|
||||
@@ -1,91 +1,18 @@
|
||||
h4(class=mobile?'item item-divider':'')=env.t('stats')
|
||||
table.table.table-striped
|
||||
tr
|
||||
mixin basicRow(label, value)
|
||||
tr&attributes(attributes)
|
||||
td
|
||||
strong=env.t('health')
|
||||
| : {{Math.ceil(profile.stats.hp)}} / {{::Shared.maxHealth}}
|
||||
tr(ng-if='profile.stats.lvl >= 10 && !profile.preferences.disableClasses')
|
||||
td
|
||||
strong=env.t('mana')
|
||||
| : {{Math.floor(profile.stats.mp)}} / {{profile._statsComputed.maxMP}}
|
||||
tr
|
||||
td
|
||||
strong=env.t('gold')
|
||||
| : {{Math.floor(profile.stats.gp)}}
|
||||
tr
|
||||
td
|
||||
strong=env.t('level')
|
||||
| : {{profile.stats.lvl}}
|
||||
tr
|
||||
td
|
||||
strong=env.t('experience')
|
||||
| : {{Math.floor(profile.stats.exp)}} / {{Shared.tnl(profile.stats.lvl)}}
|
||||
strong=env.t(label)
|
||||
| : #{value}
|
||||
|
||||
unless mobile
|
||||
h4.stats-equipment(class=mobile?'item item-divider':'',ng-show='user.flags.itemsEnabled')=env.t('equipment')
|
||||
table.table.table-striped(ng-show='user.flags.itemsEnabled')
|
||||
tr(ng-repeat='(k,v) in profile.items.gear.equipped', ng-init='piece=Content.gear.flat[v]', ng-show='piece')
|
||||
td
|
||||
strong {{piece.text()}}
|
||||
strong(ng-show='piece.str || piece.con || piece.per || piece.int') :
|
||||
span(ng-repeat='stat in ["str","con","per","int"]', ng-show='piece[stat]') {{piece[stat]}} {{env.t(stat)}}
|
||||
mixin statList(calculatedStat, popover, text, useOneTimeBinding)
|
||||
- var binding = useOneTimeBinding ? "::" : ""
|
||||
li(ng-if=binding + '#{calculatedStat} > 0')
|
||||
span.hint(popover-title=env.t('#{popover}'), popover-trigger='mouseenter',
|
||||
popover-placement='top', popover=env.t('#{popover}Text'))
|
||||
=env.t(text)
|
||||
=': {{' + binding + calculatedStat + '}}'
|
||||
|
||||
h4(class=mobile?'item item-divider':'')=env.t('attributes')
|
||||
table.table.table-striped
|
||||
each v,k in { str: {title:"strength",popover:'strengthText'},int: {title:"intelligence",popover:'intText'},con: {title:"constitution",popover:'conText'},per: {title:"perception",popover:'perText'} }
|
||||
tr
|
||||
td
|
||||
span.hint(popover-title=env.t(v.title), popover-placement='right', popover=env.t(v.popover), popover-trigger='mouseenter', style='margin-right:3px')
|
||||
strong=env.t(v.title)
|
||||
span
|
||||
strong : {{profile._statsComputed.#{k}}}
|
||||
td
|
||||
ul.list-unstyled(ng-init='g=Content.gear.flat;e=profile.items.gear.equipped')
|
||||
li(ng-show='profile.stats.lvl > 1')
|
||||
span.hint(popover-title=env.t('levelBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('levelBonusText'))=env.t('level')
|
||||
|: {{Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2)}}
|
||||
li(ng-show='g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} > 0')
|
||||
span.hint(popover-title=env.t('equipment'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('equipmentBonusText'))=env.t('equipment')
|
||||
|: {{g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} || 0}}
|
||||
li(ng-show='profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k} > 0')
|
||||
span.hint(popover-title=env.t('classBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('classBonusText'))=env.t('classEquipBonus')
|
||||
|: {{profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1,100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k}}}
|
||||
li(ng-show='profile.stats.#{k} > 0')
|
||||
span.hint(popover-title=env.t('allocatedPoints'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('allocatedPointsText'))=env.t('allocated')
|
||||
|: {{profile.stats.#{k} || 0}}
|
||||
li(ng-show='profile.stats.buffs.#{k} > 0')
|
||||
span.hint(popover-title=env.t('buffs'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('buffsText'))=env.t('buffs')
|
||||
|: {{profile.stats.buffs.#{k} || 0}}
|
||||
tr(ng-if='profile.stats.buffs.stealth')
|
||||
td
|
||||
span.hint(popover-title=env.t('stealth'), popover-trigger='mouseenter', popover-placement='right', popover=env.t('stealthNewDay'))
|
||||
strong
|
||||
=env.t('stealth')
|
||||
strong : {{profile.stats.buffs.stealth}}
|
||||
td
|
||||
tr(ng-if='profile.stats.buffs.streaks')
|
||||
td
|
||||
strong.hint(popover-title=env.t('streaksFrozen'), popover-trigger='mouseenter', popover-placement='right', popover=env.t('streaksFrozenText'))=env.t('streaksFrozen')
|
||||
td
|
||||
|
||||
h4(class=mobile?'item item-divider':'',ng-if='user.flags.dropsEnabled')=env.t('pets')
|
||||
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
||||
tr
|
||||
td
|
||||
strong=env.t('petsFound')
|
||||
| : {{_.size(profile.items.pets)}}
|
||||
tr
|
||||
td
|
||||
strong=env.t('beastMasterProgress')
|
||||
| : {{profile.petCount}}/90
|
||||
|
||||
h4(class=mobile?'item item-divider':'', ng-if='user.flags.dropsEnabled')=env.t('mounts')
|
||||
table.table.table-striped(ng-if='user.flags.dropsEnabled')
|
||||
tr
|
||||
td
|
||||
strong=env.t('mountsTamed')
|
||||
| : {{_.size(profile.items.mounts)}}
|
||||
tr
|
||||
td
|
||||
strong=env.t('mountMasterProgress')
|
||||
| : {{profile.mountCount}}/90
|
||||
include ./stats/basic-stats
|
||||
include ./stats/equipment
|
||||
include ./stats/attributes
|
||||
include ./stats/pets-and-mounts
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
h4(class=mobile?'item item-divider':'')=env.t('attributes')
|
||||
|
||||
table.table.table-striped
|
||||
each statInfo, stat in { str: {title:"strength",popover:'strengthText'},int: {title:"intelligence",popover:'intText'},con: {title:"constitution",popover:'conText'},per: {title:"perception",popover:'perText'} }
|
||||
tr
|
||||
td
|
||||
span.hint(popover-title=env.t(statInfo.title), popover-placement='right',
|
||||
popover=env.t(statInfo.popover), popover-trigger='mouseenter')
|
||||
strong=env.t(statInfo.title)
|
||||
strong : {{profile._statsComputed.#{stat}}}
|
||||
|
||||
td: ul.list-unstyled
|
||||
+statList('statCalc.levelBonus(profile.stats.lvl)', 'levelBonus', 'level', true)
|
||||
+statList('statCalc.equipmentStatBonus("' + stat + '", profile.items.gear.equipped)', 'equipmentBonus', 'equipment', true)
|
||||
+statList('statCalc.classBonus(profile, "' + stat + '")', 'classBonus', 'classEquipBonus')
|
||||
+statList('profile.stats.' + stat, 'allocatedPoints', 'allocated')
|
||||
+statList('profile.stats.buffs.' + stat, 'buffs', 'buffs', true)
|
||||
|
||||
tr(ng-if='profile.stats.buffs.stealth')
|
||||
td(colspan='2')
|
||||
strong.hint(popover-title=env.t('stealth'), popover-trigger='mouseenter',
|
||||
popover-placement='right', popover=env.t('stealthNewDay'))
|
||||
=env.t('stealth')
|
||||
strong : {{profile.stats.buffs.stealth}}
|
||||
tr(ng-if='profile.stats.buffs.streaks')
|
||||
td(colspan='2')
|
||||
strong.hint(popover-title=env.t('streaksFrozen'), popover-trigger='mouseenter',
|
||||
popover-placement='right', popover=env.t('streaksFrozenText'))
|
||||
=env.t('streaksFrozen')
|
||||
@@ -0,0 +1,7 @@
|
||||
h4(class=mobile?'item item-divider':'')=env.t('stats')
|
||||
table.table.table-striped
|
||||
+basicRow('health', '{{::statCalc.hpDisplay(profile.stats.hp)}}')
|
||||
+basicRow('mana', '{{statCalc.mpDisplay(profile)}}')(ng-if='profile.stats.lvl >= 10 && !profile.preferences.disableClasses')
|
||||
+basicRow('gold', '{{::statCalc.goldDisplay(profile.stats.gp)}}')
|
||||
+basicRow('level', '{{::profile.stats.lvl}}')
|
||||
+basicRow('experience', '{{::statCalc.expDisplay(profile)}}')
|
||||
@@ -0,0 +1,10 @@
|
||||
unless mobile
|
||||
h4.stats-equipment(class=mobile?'item item-divider':'',
|
||||
ng-show='user.flags.itemsEnabled')=env.t('equipment')
|
||||
table.table.table-striped(ng-show='user.flags.itemsEnabled')
|
||||
tr(ng-repeat='(itemType,gear) in profile.items.gear.equipped',
|
||||
ng-init='piece=Content.gear.flat[gear]', ng-show='piece')
|
||||
td
|
||||
strong {{piece.text()}}
|
||||
strong(ng-show='piece.str || piece.con || piece.per || piece.int') :
|
||||
span(ng-repeat='stat in ["str","con","per","int"]', ng-show='piece[stat]') {{piece[stat]}} {{env.t(stat)}}
|
||||
@@ -0,0 +1,12 @@
|
||||
div(ng-if='user.flags.dropsEnabled')
|
||||
h4(class=mobile?'item item-divider':'')=env.t('pets')
|
||||
|
||||
table.table.table-striped
|
||||
+basicRow('petsFound','{{::statCalc.totalCount(profile.items.pets)}}')
|
||||
+basicRow('beastMasterProgress','{{::statCalc.beastMasterProgress(profile.items.pets)}}')
|
||||
|
||||
h4(class=mobile?'item item-divider':'')=env.t('mounts')
|
||||
|
||||
table.table.table-striped
|
||||
+basicRow('mountsTamed','{{::statCalc.totalCount(profile.items.mounts)}}')
|
||||
+basicRow('mountMasterProgress','{{::statCalc.mountMasterProgress(profile.items.mounts)}}')
|
||||
Reference in New Issue
Block a user