Files
habitica/common/script/src/content/spells/spell-helper.js
T
2015-09-21 17:35:27 -05:00

26 lines
772 B
JavaScript

import {each, defaults} from 'lodash';
import capitalize from 'lodash.capitalize';
import {translator as t} from '../helpers';
export function diminishingReturns(bonus, max, halfway=max/2) {
return max * (bonus / (bonus + halfway));
};
export function calculateBonus(value, stat, crit=1, stat_scale=0.5) {
return (value < 0 ? 1 : value + 1) + (stat * stat_scale * crit);
};
export function setSpellDefaults (className, spells) {
let capitalClassName = capitalize(className);
each(spells, (spell, key) => {
let capitalSpellKey = capitalize(key);
let spellDefaults = {
text: t(`spell${capitalClassName}${capitalSpellKey}Text`),
notes: t(`spell${capitalClassName}${capitalSpellKey}Notes`),
};
defaults(spell, spellDefaults);
});
};