mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Fix some scheduling issues (#15274)
* fix logic for time travelers schedule * fix potion availability * fix tests
This commit is contained in:
@@ -47,7 +47,7 @@ describe('content index', () => {
|
|||||||
const junePets = content.petInfo;
|
const junePets = content.petInfo;
|
||||||
expect(junePets['Chameleon-Base']).to.not.exist;
|
expect(junePets['Chameleon-Base']).to.not.exist;
|
||||||
clock.restore();
|
clock.restore();
|
||||||
clock = sinon.useFakeTimers(new Date('2024-07-10'));
|
clock = sinon.useFakeTimers(new Date('2024-07-20'));
|
||||||
const julyPets = content.petInfo;
|
const julyPets = content.petInfo;
|
||||||
expect(julyPets['Chameleon-Base']).to.exist;
|
expect(julyPets['Chameleon-Base']).to.exist;
|
||||||
expect(Object.keys(junePets).length, '').to.equal(Object.keys(julyPets).length - 10);
|
expect(Object.keys(junePets).length, '').to.equal(Object.keys(julyPets).length - 10);
|
||||||
@@ -58,7 +58,7 @@ describe('content index', () => {
|
|||||||
const juneMounts = content.mountInfo;
|
const juneMounts = content.mountInfo;
|
||||||
expect(juneMounts['Chameleon-Base']).to.not.exist;
|
expect(juneMounts['Chameleon-Base']).to.not.exist;
|
||||||
clock.restore();
|
clock.restore();
|
||||||
clock = sinon.useFakeTimers(new Date('2024-07-10'));
|
clock = sinon.useFakeTimers(new Date('2024-07-20'));
|
||||||
const julyMounts = content.mountInfo;
|
const julyMounts = content.mountInfo;
|
||||||
expect(julyMounts['Chameleon-Base']).to.exist;
|
expect(julyMounts['Chameleon-Base']).to.exist;
|
||||||
expect(Object.keys(juneMounts).length, '').to.equal(Object.keys(julyMounts).length - 10);
|
expect(Object.keys(juneMounts).length, '').to.equal(Object.keys(julyMounts).length - 10);
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ describe('Content Schedule', () => {
|
|||||||
const date = new Date('2024-04-15');
|
const date = new Date('2024-04-15');
|
||||||
const matchers = getAllScheduleMatchingGroups(date);
|
const matchers = getAllScheduleMatchingGroups(date);
|
||||||
expect(matchers.premiumHatchingPotions).to.exist;
|
expect(matchers.premiumHatchingPotions).to.exist;
|
||||||
expect(matchers.premiumHatchingPotions.items.length).to.equal(4);
|
expect(matchers.premiumHatchingPotions.items.length).to.equal(5);
|
||||||
expect(matchers.premiumHatchingPotions.items.indexOf('Garden')).to.not.equal(-1);
|
expect(matchers.premiumHatchingPotions.items.indexOf('Veggie')).to.not.equal(-1);
|
||||||
expect(matchers.premiumHatchingPotions.items.indexOf('Porcelain')).to.not.equal(-1);
|
expect(matchers.premiumHatchingPotions.items.indexOf('Porcelain')).to.not.equal(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -245,27 +245,33 @@ describe('Content Schedule', () => {
|
|||||||
it('allows sets matching the month', () => {
|
it('allows sets matching the month', () => {
|
||||||
const date = new Date('2024-07-08');
|
const date = new Date('2024-07-08');
|
||||||
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
||||||
expect(matcher.match('202307')).to.be.true;
|
expect(matcher.match('202307'), '202307').to.be.true;
|
||||||
expect(matcher.match('202207')).to.be.true;
|
expect(matcher.match('202207'), '202207').to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disallows sets not matching the month', () => {
|
it('disallows sets not matching the month', () => {
|
||||||
const date = new Date('2024-07-08');
|
const date = new Date('2024-07-08');
|
||||||
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
||||||
expect(matcher.match('202306')).to.be.false;
|
expect(matcher.match('202306'), '202306').to.be.false;
|
||||||
expect(matcher.match('202402')).to.be.false;
|
expect(matcher.match('202402'), '202402').to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disallows sets from current month', () => {
|
it('disallows sets from current month', () => {
|
||||||
const date = new Date('2024-07-08');
|
const date = new Date('2024-07-08');
|
||||||
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
||||||
expect(matcher.match('202407')).to.be.false;
|
expect(matcher.match('202407'), '202407').to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disallows sets from the future', () => {
|
it('disallows sets from the future', () => {
|
||||||
const date = new Date('2024-07-08');
|
const date = new Date('2024-07-08');
|
||||||
const matcher = getAllScheduleMatchingGroups(date).backgrounds;
|
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
||||||
expect(matcher.match('202507')).to.be.false;
|
expect(matcher.match('202507'), '202507').to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches sets released in the earlier half of the year', () => {
|
||||||
|
const date = new Date('2024-07-08');
|
||||||
|
const matcher = getAllScheduleMatchingGroups(date).timeTravelers;
|
||||||
|
expect(matcher.match('202401'), '202401').to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export const REPEATING_EVENTS = {
|
|||||||
{
|
{
|
||||||
type: 'premiumHatchingPotions',
|
type: 'premiumHatchingPotions',
|
||||||
items: [
|
items: [
|
||||||
'Garden',
|
'Veggie',
|
||||||
'TeaShop',
|
'TeaShop',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ function timeTravelersMatcher (month1, month2) {
|
|||||||
return function call (item, date) {
|
return function call (item, date) {
|
||||||
const month = parseInt(item.substring(4, 6), 10);
|
const month = parseInt(item.substring(4, 6), 10);
|
||||||
const year = parseInt(item.substring(0, 4), 10);
|
const year = parseInt(item.substring(0, 4), 10);
|
||||||
if (date.getFullYear() === year && (date.getMonth() + 1) >= month) {
|
if (date.getFullYear() < year
|
||||||
|
|| (date.getFullYear() === year && (date.getMonth() + 1) === month)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return month === month1 || month === month2;
|
return month === month1 || month === month2;
|
||||||
@@ -207,6 +208,7 @@ export const MONTHLY_SCHEDULE = {
|
|||||||
items: [
|
items: [
|
||||||
'StainedGlass',
|
'StainedGlass',
|
||||||
'Porcelain',
|
'Porcelain',
|
||||||
|
'BirchBark',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user