mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Move egg function to helpers
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import {each, defaults} from 'lodash';
|
import {generateEggs} from '../helpers';
|
||||||
import {translator as t} from '../helpers';
|
|
||||||
|
|
||||||
const DROP_EGGS = [
|
const DROP_EGGS = [
|
||||||
'Wolf',
|
'Wolf',
|
||||||
@@ -13,26 +12,6 @@ const DROP_EGGS = [
|
|||||||
'BearCub',
|
'BearCub',
|
||||||
];
|
];
|
||||||
|
|
||||||
let eggs = { };
|
let eggs = generateEggs(DROP_EGGS, {type: 'drop', canBuy: true});
|
||||||
|
|
||||||
each(DROP_EGGS, (pet) => {
|
|
||||||
eggs[pet] = {
|
|
||||||
text: t(`dropEgg${pet}Text`),
|
|
||||||
mountText: t(`dropEgg${pet}MountText`),
|
|
||||||
adjective: t(`dropEgg${pet}Adjective`),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
each(eggs, (egg, key) => {
|
|
||||||
return defaults(egg, {
|
|
||||||
canBuy: true,
|
|
||||||
value: 3,
|
|
||||||
key: key,
|
|
||||||
notes: t('eggNotes', {
|
|
||||||
eggText: egg.text,
|
|
||||||
eggAdjective: egg.adjective
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default eggs;
|
export default eggs;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {each, defaults} from 'lodash';
|
import {generateEggs} from '../helpers';
|
||||||
import {translator as t} from '../helpers';
|
|
||||||
|
|
||||||
const QUEST_EGGS = [
|
const QUEST_EGGS = [
|
||||||
'Gryphon',
|
'Gryphon',
|
||||||
@@ -25,26 +24,6 @@ const QUEST_EGGS = [
|
|||||||
'Horse',
|
'Horse',
|
||||||
];
|
];
|
||||||
|
|
||||||
let eggs = { };
|
let eggs = generateEggs(QUEST_EGGS, {type: 'quest', canBuy: false});
|
||||||
|
|
||||||
each(QUEST_EGGS, (pet) => {
|
|
||||||
eggs[pet] = {
|
|
||||||
text: t(`questEgg${pet}Text`),
|
|
||||||
mountText: t(`questEgg${pet}MountText`),
|
|
||||||
adjective: t(`questEgg${pet}Adjective`),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
each(eggs, (egg, key) => {
|
|
||||||
return defaults(egg, {
|
|
||||||
canBuy: false,
|
|
||||||
value: 3,
|
|
||||||
key: key,
|
|
||||||
notes: t('eggNotes', {
|
|
||||||
eggText: egg.text,
|
|
||||||
eggAdjective: egg.adjective
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default eggs;
|
export default eggs;
|
||||||
|
|||||||
@@ -143,3 +143,31 @@ export function generateBackgrounds(sets) {
|
|||||||
|
|
||||||
return backgrounds;
|
return backgrounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------
|
||||||
|
// Egg Helpers
|
||||||
|
//----------------------------------------
|
||||||
|
|
||||||
|
export function generateEggs(set, options={}) {
|
||||||
|
let eggs = {};
|
||||||
|
let type = options.type;
|
||||||
|
let canBuy = options.canBuy;
|
||||||
|
|
||||||
|
each(set, (pet) => {
|
||||||
|
eggs[pet] = {
|
||||||
|
text: translator(`${type}Egg${pet}Text`),
|
||||||
|
mountText: translator(`${type}Egg${pet}MountText`),
|
||||||
|
adjective: translator(`${type}Egg${pet}Adjective`),
|
||||||
|
canBuy: canBuy,
|
||||||
|
value: 3,
|
||||||
|
key: pet,
|
||||||
|
}
|
||||||
|
|
||||||
|
eggs[pet].notes = translator('eggNotes', {
|
||||||
|
eggText: eggs[pet].text,
|
||||||
|
eggAdjective: eggs[pet].adjective
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return eggs;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user