Added triad bingo achievment

This commit is contained in:
Blade Barringer 2015-01-16 16:43:48 -06:00
parent 7860819ee3
commit e25472759a
2 changed files with 21 additions and 7 deletions

View file

@ -77,6 +77,13 @@ habitrpg.controller("InventoryCtrl",
return _.pick(inventory, function(v,k){return v>0;});
}
$scope.calcTriadBingo = function() {
for (var p in User.user.items.pets) {
if(User.user.items.pets[p] < 0) return false;
}
return true;
};
$scope.hatch = function(egg, potion){
var eggName = Content.eggs[egg.key].text();
var potName = Content.hatchingPotions[potion.key].text();
@ -95,10 +102,11 @@ habitrpg.controller("InventoryCtrl",
// Checks if Triad Bingo has been reached for the first time
if(!User.user.achievements.triadBingo
&& Shared.countPets(null, User.user.items.pets) >= 90
&& Shared.countMounts(null, User.user.items.mounts) >= 90) {
// @TODO Loop through pets and make sure all are > -1
//User.user.achievements.triadBingo = true;
//$rootScope.openModal('achievements/triadBingo');
&& Shared.countMounts(null, User.user.items.mounts) >= 90
&& $scope.calcTriadBingo()) {
User.user.achievements.triadBingo = true;
$rootScope.openModal('achievements/triadBingo');
}
}

View file

@ -454,9 +454,15 @@ UserSchema.pre('save', function(next) {
// Determines if Triad Bingo should be awarded
if (mountCount >= 90 || this.achievements.triadBingoCount > 0) {
// @TODO loop through pets and make sure they're all greater than -1
//this.achievements.triadBingo = true
var giveTriadBingo = function(pets) {
for(var p in pets) {
if(pets[p] == -1) return false;
}
return true;
};
if ((mountCount >= 90 && giveTriadBingo(this.items.pets)) || this.achievements.triadBingoCount > 0) {
this.achievements.triadBingo = true;
}
// EXAMPLE CODE for allowing all existing and new players to be