Collection quest progress reports "found no [item names]" fixes #7816 (#7883)

* Updated collection quest tests for no found items.

Single-item quests state [user] found no [items]. instead of [user] found nothing. If a
quest has two items, the chat message is [user] found no [item1] and no [item2].

* Collection quest messages changed from [user] found nothing to [user] found no [item]

* Tests for no collection quest items found changed to [user] found 0 [item1], 0 [item2]

* Changed chat messages for no found collection quest items to [user] found 0 [item1], 0 [item2]

* Sort items alphabetically in multi-item quests so that it always returns the same string

* Formatting updates to conform to test specifications (for collection quest progress reports with no items found

* Simplified handling of items not found: any items not found are added to the list of found items with quantity 0 for reporting in the group chat. This also causes all items to appear, in the list, even if only one type is found in a multi-item quest.

* Test the group chat message when no items are found in multi-item quests. Test succes no longer depends on the order items are listed.
This commit is contained in:
Alyssa Batula
2016-09-11 00:03:28 -04:00
committed by Blade Barringer
parent b8878df6bd
commit 923b6c495e
2 changed files with 28 additions and 2 deletions

View File

@@ -607,12 +607,20 @@ schema.methods._processCollectionQuest = async function processCollectionQuest (
group.quest.progress.collect[item]++;
});
// Add 0 for all items not found
let questItems = Object.keys(this.quest.progress.collect);
for (let i = 0; i < questItems.length; i++) {
if (!itemsFound[questItems[i]]) {
itemsFound[questItems[i]] = 0;
}
}
let foundText = _.reduce(itemsFound, (m, v, k) => {
m.push(`${v} ${quest.collect[k].text('en')}`);
return m;
}, []);
foundText = foundText.length > 0 ? foundText.join(', ') : 'nothing';
foundText = foundText.join(', ');
group.sendChat(`\`${user.profile.name} found ${foundText}.\``);
group.markModified('quest.progress.collect');