mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
Collection quest ignoring items (#13401)
* update tests to check for issue #12664 * rewrite processCollectionQuest to allocate quest items proportionally Removes need to check for excess items, fixing issue #12664 * move test for this bug to the correct context section & remove redundant test * refactor processCollectionQuest more * tweak confusing comments
This commit is contained in:
@@ -488,20 +488,6 @@ describe('Group Model', () => {
|
||||
expect(party.quest.progress.collect.soapBars).to.eq(5);
|
||||
});
|
||||
|
||||
it('does not drop an item if not need when on a collection quest', async () => {
|
||||
party.quest.key = 'dilatoryDistress1';
|
||||
party.quest.active = false;
|
||||
await party.startQuest(questLeader);
|
||||
party.quest.progress.collect.fireCoral = 20;
|
||||
await party.save();
|
||||
|
||||
await Group.processQuestProgress(participatingMember, progress);
|
||||
|
||||
party = await Group.findOne({ _id: party._id });
|
||||
|
||||
expect(party.quest.progress.collect.fireCoral).to.eq(20);
|
||||
});
|
||||
|
||||
it('sends a chat message about progress', async () => {
|
||||
await Group.processQuestProgress(participatingMember, progress);
|
||||
|
||||
@@ -538,8 +524,8 @@ describe('Group Model', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('collection quests with multiple items', () => {
|
||||
it('sends a chat message if no progress is made on quest with multiple items', async () => {
|
||||
describe('collection quests with multiple item types', () => {
|
||||
it('sends a chat message if no progress is made', async () => {
|
||||
progress.collectedItems = 0;
|
||||
party.quest.key = 'dilatoryDistress1';
|
||||
party.quest.active = false;
|
||||
@@ -609,6 +595,28 @@ describe('Group Model', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not drop items when an item type becomes full', async () => {
|
||||
progress.collectedItems = 20;
|
||||
party.quest.key = 'dilatoryDistress1';
|
||||
party.quest.active = false;
|
||||
|
||||
await party.startQuest(questLeader);
|
||||
party.quest.progress.collect.fireCoral = 19;
|
||||
await party.save();
|
||||
|
||||
await Group.processQuestProgress(participatingMember, progress);
|
||||
|
||||
party = await Group.findOne({ _id: party._id });
|
||||
|
||||
// There is a very small chance (~1 in 500K) that blueFins will
|
||||
// be 19 or 20 due to randomness and not any bug. In these cases, this
|
||||
// test doesn't actually verify anything, but it's rare enough that it
|
||||
// shouldn't be a problem, and to make it deterministic would require
|
||||
// stubbing out methods in implementation-specific ways.
|
||||
expect(party.quest.progress.collect.fireCoral).to.be.within(19, 20);
|
||||
expect(party.quest.progress.collect.blueFins).to.be.within(19, 20);
|
||||
});
|
||||
|
||||
it('sends message about victory', async () => {
|
||||
progress.collectedItems = 500;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user