mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-22 03:34:14 +00:00
Add generateGearSet function
This commit is contained in:
parent
7948e8a8e2
commit
edce15a722
1 changed files with 32 additions and 0 deletions
|
|
@ -87,3 +87,35 @@ export function setFoodDefaults(food, options={}) {
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
//----------------------------------------
|
||||
// Gear Helpers
|
||||
//----------------------------------------
|
||||
|
||||
export function generateGearSet(gear, options={}) {
|
||||
let setName = formatForTranslator(options.setName);
|
||||
let gearType = options.gearType;
|
||||
|
||||
each(gear, (item, number) => {
|
||||
let text = `${gearType}${setName}${number}Text`;
|
||||
let notes = `${gearType}${setName}${number}Notes`;
|
||||
let attributes = _getGearAttributes(item);
|
||||
let gearDefaults = {
|
||||
text: translator(text),
|
||||
notes: translator(notes, attributes),
|
||||
}
|
||||
|
||||
defaults(item, gearDefaults);
|
||||
});
|
||||
}
|
||||
|
||||
function _getGearAttributes(gear) {
|
||||
let attr = {};
|
||||
|
||||
if (gear.str) { attr.str = gear.str };
|
||||
if (gear.con) { attr.con = gear.con };
|
||||
if (gear.int) { attr.int = gear.int };
|
||||
if (gear.per) { attr.per = gear.per };
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue