diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 27d5d5f4d0..5a6f989111 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -1,7 +1,6 @@ api = module.exports _ = require 'lodash' -moment = require 'moment' t = require('../../dist/scripts/content/helpers').translator @@ -85,16 +84,6 @@ api.spells = require('../../dist/scripts/content/spells/index') api.cardTypes = require('../../dist/scripts/content/card-types') -# Intercept all spells to reduce user.stats.mp after casting the spell -_.each api.spells, (spellClass) -> - _.each spellClass, (spell, key) -> - spell.key = key - _cast = spell.cast - spell.cast = (user, target) -> - #return if spell.target and spell.target != (if target.type then 'task' else 'user') - _cast(user,target) - user.stats.mp -= spell.mana - api.special = api.spells.special ### diff --git a/common/script/src/content/spells/index.js b/common/script/src/content/spells/index.js index 742eb5e10f..e99fc03866 100644 --- a/common/script/src/content/spells/index.js +++ b/common/script/src/content/spells/index.js @@ -1,3 +1,5 @@ +import {each} from 'lodash'; + import wizard from './wizard'; import warrior from './warrior'; import healer from './healer'; @@ -33,4 +35,17 @@ var spells = { special: special, }; +// Intercept all spells to reduce user.stats.mp after casting the spell +each(spells, (spellClass) => { + each(spellClass, (spell, key) => { + spell.key = key; + + let _cast = spell.cast; + spell.cast = (user, target) => { + _cast(user, target); + return user.stats.mp -= spell.mana; + }; + }); +}); + export default spells; diff --git a/common/script/src/content/spells/spell-helper.js b/common/script/src/content/spells/spell-helper.js deleted file mode 100644 index 2ae7d640fc..0000000000 --- a/common/script/src/content/spells/spell-helper.js +++ /dev/null @@ -1,25 +0,0 @@ -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); - }); -};