mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Add generateGearSet function
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user