mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Create merge function
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import {assign} from 'lodash';
|
||||
import {merge} from '../helpers';
|
||||
|
||||
import dropEggs from './drops';
|
||||
import questEggs from './quest';
|
||||
|
||||
let allEggs = {};
|
||||
|
||||
assign(allEggs, dropEggs);
|
||||
assign(allEggs, questEggs);
|
||||
let allEggs = merge([dropEggs, questEggs]);
|
||||
|
||||
export default {
|
||||
allEggs: allEggs,
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import {each, defaults, assign} from 'lodash';
|
||||
import {translator as t} from '../helpers';
|
||||
import {each, defaults} from 'lodash';
|
||||
import {
|
||||
translator as t,
|
||||
merge
|
||||
} from '../helpers';
|
||||
|
||||
import baseFood from './base';
|
||||
import saddle from './saddle';
|
||||
import cake from './birthday';
|
||||
import candy from './fall';
|
||||
|
||||
let allFood = {};
|
||||
|
||||
assign(allFood, baseFood);
|
||||
assign(allFood, saddle);
|
||||
assign(allFood, cake);
|
||||
assign(allFood, candy);
|
||||
let allFood = merge([baseFood, saddle, cake, candy]);
|
||||
|
||||
export default allFood;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {each, defaults} from 'lodash';
|
||||
import {each, defaults, assign} from 'lodash';
|
||||
import capitalize from 'lodash.capitalize';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
|
||||
@@ -27,6 +27,20 @@ export function formatForTranslator(name) {
|
||||
let capitalCamelCasedName = capitalize(camelCasedName);
|
||||
|
||||
return capitalCamelCasedName;
|
||||
};
|
||||
|
||||
//----------------------------------------
|
||||
// Object Merger
|
||||
//----------------------------------------
|
||||
|
||||
export function merge(array=[]) {
|
||||
let mergedObject = {};
|
||||
|
||||
each(array, (item) => {
|
||||
assign(mergedObject, item);
|
||||
});
|
||||
|
||||
return mergedObject;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import {each, defaults, assign} from 'lodash';
|
||||
import capitalize from 'lodash.capitalize';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import {translator as t} from '../helpers';
|
||||
import {each, defaults} from 'lodash';
|
||||
import {
|
||||
translator as t,
|
||||
merge,
|
||||
formatForTranslator
|
||||
} from '../helpers';
|
||||
|
||||
let dilatoryDistressSeries = {
|
||||
dilatoryDistress1: {
|
||||
@@ -95,16 +97,13 @@ let dilatoryDistressSeries = {
|
||||
},
|
||||
};
|
||||
|
||||
let goldPurchasableQuests = { };
|
||||
|
||||
assign(goldPurchasableQuests, dilatoryDistressSeries);
|
||||
let goldPurchasableQuests = merge([dilatoryDistressSeries]);
|
||||
|
||||
each(goldPurchasableQuests, (quest, name) => {
|
||||
let camelName = camelCase(name);
|
||||
let capitalizedName = capitalize(camelName);
|
||||
let formattedName = formatForTranslator(name);
|
||||
|
||||
let questDefaults = {
|
||||
completion: t(`quest${capitalizedName}Completion`),
|
||||
completion: t(`quest${formattedName}Completion`),
|
||||
category: 'gold',
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import {each, assign, defaults, sortBy} from 'lodash';
|
||||
import capitalize from 'lodash.capitalize';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import {translator as t} from '../helpers';
|
||||
import {each, defaults, sortBy} from 'lodash';
|
||||
import {
|
||||
translator as t,
|
||||
merge,
|
||||
formatForTranslator
|
||||
} from '../helpers';
|
||||
|
||||
import worldQuests from './world';
|
||||
import holidayQuests from './holiday';
|
||||
@@ -9,28 +11,27 @@ import petQuests from './pet';
|
||||
import unlockableQuests from './unlockable';
|
||||
import goldPurchasableQuests from './gold-purchasable';
|
||||
|
||||
let allQuests = { };
|
||||
|
||||
assign(allQuests, worldQuests);
|
||||
assign(allQuests, holidayQuests);
|
||||
assign(allQuests, petQuests);
|
||||
assign(allQuests, unlockableQuests);
|
||||
assign(allQuests, goldPurchasableQuests);
|
||||
let allQuests = merge([
|
||||
worldQuests,
|
||||
holidayQuests,
|
||||
petQuests,
|
||||
unlockableQuests,
|
||||
goldPurchasableQuests
|
||||
]);
|
||||
|
||||
each(allQuests, function(quest, key) {
|
||||
let camelName = camelCase(key);
|
||||
let capitalizedName = capitalize(camelName);
|
||||
let formattedName = formatForTranslator(key);
|
||||
|
||||
let questDefaults = {
|
||||
key: key,
|
||||
text: t(`quest${capitalizedName}Text`),
|
||||
notes: t(`quest${capitalizedName}Notes`),
|
||||
text: t(`quest${formattedName}Text`),
|
||||
notes: t(`quest${formattedName}Notes`),
|
||||
canBuy: true,
|
||||
value: 4,
|
||||
};
|
||||
|
||||
let questBossDefaults = {
|
||||
name: t(`quest${capitalizedName}Boss`),
|
||||
name: t(`quest${formattedName}Boss`),
|
||||
str: 1,
|
||||
def: 1,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import {each, defaults, assign} from 'lodash';
|
||||
import {translator as t} from '../helpers';
|
||||
import {each, defaults} from 'lodash';
|
||||
import {
|
||||
translator as t,
|
||||
merge,
|
||||
formatForTranslator
|
||||
} from '../helpers';
|
||||
|
||||
let inviteFriends = {
|
||||
basilist: {
|
||||
@@ -342,13 +346,13 @@ let goldenKnightSeries = {
|
||||
},
|
||||
};
|
||||
|
||||
let unlockableQuests = { };
|
||||
|
||||
assign(unlockableQuests, inviteFriends);
|
||||
assign(unlockableQuests, atomSeries);
|
||||
assign(unlockableQuests, viceSeries);
|
||||
assign(unlockableQuests, moonstoneSeries);
|
||||
assign(unlockableQuests, goldenKnightSeries);
|
||||
let unlockableQuests = merge([
|
||||
inviteFriends,
|
||||
atomSeries,
|
||||
viceSeries,
|
||||
moonstoneSeries,
|
||||
goldenKnightSeries,
|
||||
]);
|
||||
|
||||
each(unlockableQuests, (quest, name) => {
|
||||
let questDefaults = {
|
||||
|
||||
Reference in New Issue
Block a user