Add more achievements to notifications list (#11332)

* Add more achievements to notifications list

* use addNotification

* Fix logic to not award stable achievements over and over

* Improve achievement display

* Fix setting notifications for party inviter

* Add tests that notifications are added correctly

* Fix tests
This commit is contained in:
Phillip Thelen
2019-10-18 17:04:33 +02:00
committed by Matteo Pagliazzi
parent ec7ded042b
commit 360aaa9f0b
8 changed files with 108 additions and 25 deletions

View File

@@ -188,23 +188,26 @@ schema.pre('save', true, function preSaveUser (next, done) {
// Determines if Beast Master should be awarded
let beastMasterProgress = common.count.beastMasterProgress(this.items.pets);
if (beastMasterProgress >= 90 || this.achievements.beastMasterCount > 0) {
if ((beastMasterProgress >= 90 || this.achievements.beastMasterCount > 0) && this.achievements.beastMaster !== true) {
this.achievements.beastMaster = true;
this.addNotification('ACHIEVEMENT_BEAST_MASTER');
}
// Determines if Mount Master should be awarded
let mountMasterProgress = common.count.mountMasterProgress(this.items.mounts);
if (mountMasterProgress >= 90 || this.achievements.mountMasterCount > 0) {
if ((mountMasterProgress >= 90 || this.achievements.mountMasterCount > 0) && this.achievements.mountMaster !== true) {
this.achievements.mountMaster = true;
this.addNotification('ACHIEVEMENT_MOUNT_MASTER');
}
// Determines if Triad Bingo should be awarded
let dropPetCount = common.count.dropPetsCurrentlyOwned(this.items.pets);
let qualifiesForTriad = dropPetCount >= 90 && mountMasterProgress >= 90;
if (qualifiesForTriad || this.achievements.triadBingoCount > 0) {
if ((qualifiesForTriad || this.achievements.triadBingoCount > 0) && this.achievements.triadBingo !== true) {
this.achievements.triadBingo = true;
this.addNotification('ACHIEVEMENT_TRIAD_BINGO');
}
// EXAMPLE CODE for allowing all existing and new players to be