mirror of
https://github.com/HabitRPG/habitica.git
synced 2026-05-09 11:11:17 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 934dd565f6 | |||
| 3057637b1e | |||
| 3156663ee5 | |||
| 4a9497b600 | |||
| 35aab8d889 | |||
| 88c876c673 |
@@ -0,0 +1,38 @@
|
||||
import { getMatchingSwap, makeSubstitutionMap } from '../../website/common/script/content/constants/aprilFools';
|
||||
|
||||
describe('April Fools', () => {
|
||||
describe('getMatchingSwap', () => {
|
||||
it('returns Veggie for 2020', () => {
|
||||
const swap = getMatchingSwap(new Date('2020-04-01'));
|
||||
expect(swap).to.equal('Veggie');
|
||||
});
|
||||
it('returns Cryptid for 2025', () => {
|
||||
const swap = getMatchingSwap(new Date('2025-04-01'));
|
||||
expect(swap).to.equal('Cryptid');
|
||||
});
|
||||
it('Cycles through swaps correctly', () => {
|
||||
const swap = getMatchingSwap(new Date('2026-04-01'));
|
||||
expect(swap).to.equal('Veggie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('makeSubstitutionMap', () => {
|
||||
it('returns correct substitution for Veggie', () => {
|
||||
const substitutions = makeSubstitutionMap('Veggie');
|
||||
expect(substitutions.pets['Pet-Wolf-']).to.equal('Pet-Wolf-Veggie');
|
||||
expect(substitutions.pets['Pet-TigerCub-']).to.equal('Pet-TigerCub-Veggie');
|
||||
expect(substitutions.pets['Pet-Yarn-']).to.equal('Pet-Dragon-Veggie');
|
||||
expect(substitutions.pets.default).to.equal('Pet-Dragon-Veggie');
|
||||
expect(substitutions.pets.noPet).to.equal('Pet-TigerCub-Veggie');
|
||||
});
|
||||
|
||||
it('returns correct substitution for Cryptid', () => {
|
||||
const substitutions = makeSubstitutionMap('Cryptid');
|
||||
expect(substitutions.pets['Pet-Fox-']).to.equal('Pet-Fox-Cryptid');
|
||||
expect(substitutions.pets['Pet-FlyingPig-']).to.equal('Pet-FlyingPig-Cryptid');
|
||||
expect(substitutions.pets['Pet-Yarn-']).to.equal('Pet-Dragon-Cryptid');
|
||||
expect(substitutions.pets.default).to.equal('Pet-Dragon-Cryptid');
|
||||
expect(substitutions.pets.noPet).to.equal('Pet-TigerCub-Cryptid');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -321,10 +321,11 @@ export default {
|
||||
return null;
|
||||
},
|
||||
petClass () {
|
||||
const foolEvent = this.currentEventList?.find(event => event.aprilFools && moment()
|
||||
.isBetween(event.start, event.end));
|
||||
if (foolEvent) {
|
||||
return this.foolPet(this.member.items.currentPet, foolEvent.aprilFools);
|
||||
const substitutionEvent = this.currentEventList?.find(event => event.spriteSubstitutions
|
||||
&& moment().isBetween(event.start, event.end));
|
||||
if (substitutionEvent && substitutionEvent.spriteSubstitutions.pets) {
|
||||
return this.foolPet(`Pet-${this.member.items.currentPet}`,
|
||||
substitutionEvent.spriteSubstitutions.pets);
|
||||
}
|
||||
if (this.member?.items.currentPet) return `Pet-${this.member.items.currentPet}`;
|
||||
return '';
|
||||
|
||||
@@ -182,12 +182,10 @@ export default {
|
||||
return 'GreyedOut';
|
||||
},
|
||||
imageName () {
|
||||
const foolEvent = this.currentEventList?.find(event => moment()
|
||||
.isBetween(event.start, event.end) && event.aprilFools);
|
||||
if (this.isOwned() && foolEvent) {
|
||||
if (this.isSpecial()) return `stable_${this.foolPet(this.item.key, foolEvent.aprilFools)}`;
|
||||
const petString = `${this.item.eggKey}-${this.item.key}`;
|
||||
return `stable_${this.foolPet(petString, foolEvent.aprilFools)}`;
|
||||
const substitutionEvent = this.currentEventList?.find(event => moment()
|
||||
.isBetween(event.start, event.end) && event.spriteSubstitutions);
|
||||
if (this.isOwned() && substitutionEvent && substitutionEvent.spriteSubstitutions.pets) {
|
||||
return `stable_${this.foolPet(`Pet-${this.item.key}`, substitutionEvent.spriteSubstitutions.pets)}`;
|
||||
}
|
||||
|
||||
if (this.isOwned() || (this.mountOwned() && this.isHatchable())) {
|
||||
|
||||
@@ -1,56 +1,14 @@
|
||||
import includes from 'lodash/includes';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
foolPet (pet, prank) {
|
||||
const SPECIAL_PETS = [
|
||||
'Bear-Veteran',
|
||||
'BearCub-Polar',
|
||||
'Cactus-Veteran',
|
||||
'Dragon-Hydra',
|
||||
'Dragon-Veteran',
|
||||
'Fox-Veteran',
|
||||
'Gryphatrice-Jubilant',
|
||||
'Gryphon-Gryphatrice',
|
||||
'Gryphon-RoyalPurple',
|
||||
'Hippogriff-Hopeful',
|
||||
'Jackalope-RoyalPurple',
|
||||
'JackOLantern-Base',
|
||||
'JackOLantern-Ghost',
|
||||
'JackOLantern-Glow',
|
||||
'JackOLantern-RoyalPurple',
|
||||
'Lion-Veteran',
|
||||
'MagicalBee-Base',
|
||||
'Mammoth-Base',
|
||||
'MantisShrimp-Base',
|
||||
'Orca-Base',
|
||||
'Phoenix-Base',
|
||||
'Tiger-Veteran',
|
||||
'Turkey-Base',
|
||||
'Turkey-Gilded',
|
||||
'Wolf-Cerberus',
|
||||
'Wolf-Veteran',
|
||||
];
|
||||
const BASE_PETS = [
|
||||
'BearCub',
|
||||
'Cactus',
|
||||
'Dragon',
|
||||
'FlyingPig',
|
||||
'Fox',
|
||||
'LionCub',
|
||||
'PandaCub',
|
||||
'TigerCub',
|
||||
'Wolf',
|
||||
];
|
||||
if (!pet) return `Pet-TigerCub-${prank}`;
|
||||
if (SPECIAL_PETS.indexOf(pet) !== -1) {
|
||||
return `Pet-Dragon-${prank}`;
|
||||
foolPet (pet, substitutions) {
|
||||
console.log(pet);
|
||||
if (!pet) return substitutions.noPet;
|
||||
for (const key in substitutions) {
|
||||
if (pet.startsWith(key)) {
|
||||
return substitutions[key];
|
||||
}
|
||||
}
|
||||
const species = pet.slice(0, pet.indexOf('-'));
|
||||
if (includes(BASE_PETS, species)) {
|
||||
return `Pet-${species}-${prank}`;
|
||||
}
|
||||
return `Pet-BearCub-${prank}`;
|
||||
return substitutions.default;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import eggs from '../eggs';
|
||||
|
||||
const SWAPS = [
|
||||
'Veggie',
|
||||
'Dessert',
|
||||
'VirtualPet',
|
||||
'TeaShop',
|
||||
'Fungi',
|
||||
'Cryptid',
|
||||
];
|
||||
|
||||
export function getMatchingSwap (date = new Date()) {
|
||||
const year = date.getFullYear();
|
||||
const diff = year - 2020;
|
||||
return SWAPS[diff % SWAPS.length];
|
||||
}
|
||||
|
||||
export function makeSubstitutionMap (swappedPotion) {
|
||||
const substitutions = {
|
||||
pets: {
|
||||
'Pet-Wolf-': `Pet-Wolf-${swappedPotion}`,
|
||||
'Pet-TigerCub-': `Pet-TigerCub-${swappedPotion}`,
|
||||
'Pet-PandaCub-': `Pet-PandaCub-${swappedPotion}`,
|
||||
'Pet-LionCub-': `Pet-LionCub-${swappedPotion}`,
|
||||
'Pet-Fox-': `Pet-Fox-${swappedPotion}`,
|
||||
'Pet-FlyingPig-': `Pet-FlyingPig-${swappedPotion}`,
|
||||
'Pet-Dragon-': `Pet-Dragon-${swappedPotion}`,
|
||||
'Pet-Cactus-': `Pet-Cactus-${swappedPotion}`,
|
||||
'Pet-BearCub-': `Pet-BearCub-${swappedPotion}`,
|
||||
default: `Pet-Dragon-${swappedPotion}`,
|
||||
noPet: `Pet-TigerCub-${swappedPotion}`,
|
||||
},
|
||||
};
|
||||
for (const egg of Object.keys(eggs.drops)) {
|
||||
substitutions.pets[`Pet-${egg}-`] = `Pet-${egg}-${swappedPotion}`;
|
||||
}
|
||||
for (const egg of Object.keys(eggs.quests)) {
|
||||
substitutions.pets[`Pet-${egg}-`] = `Pet-Dragon-${swappedPotion}`;
|
||||
}
|
||||
return substitutions;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable key-spacing */
|
||||
import moment from 'moment';
|
||||
import { getMatchingSwap, makeSubstitutionMap } from './aprilFools';
|
||||
|
||||
// gem block: number of gems
|
||||
const gemsPromo = {
|
||||
@@ -53,7 +54,7 @@ export const REPEATING_EVENTS = {
|
||||
aprilFools: {
|
||||
start: new Date('1970-04-01T04:00-04:00'),
|
||||
end: new Date('1970-04-02T03:59-04:00'),
|
||||
aprilFools: 'Cryptid',
|
||||
spriteSubstitutions: makeSubstitutionMap(getMatchingSwap()),
|
||||
},
|
||||
aprilFoolsResale: {
|
||||
start: new Date('1970-04-03T04:00-04:00'),
|
||||
|
||||
Reference in New Issue
Block a user