mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Refactored Achievement's getExpFunction to use the new defaults system, now on the server side.
This commit is contained in:
parent
434a0c071b
commit
f54c3236ab
2 changed files with 5 additions and 4 deletions
|
@ -4,6 +4,7 @@ log = require 'winston'
|
||||||
utils = require '../../app/lib/utils'
|
utils = require '../../app/lib/utils'
|
||||||
plugins = require('../plugins/plugins')
|
plugins = require('../plugins/plugins')
|
||||||
AchievablePlugin = require '../plugins/achievements'
|
AchievablePlugin = require '../plugins/achievements'
|
||||||
|
TreemaUtils = require '../../bower_components/treema/treema-utils.js'
|
||||||
|
|
||||||
# `pre` and `post` are not called for update operations executed directly on the database,
|
# `pre` and `post` are not called for update operations executed directly on the database,
|
||||||
# including `Model.update`,`.findByIdAndUpdate`,`.findOneAndUpdate`, `.findOneAndRemove`,and `.findByIdAndRemove`.order
|
# including `Model.update`,`.findByIdAndUpdate`,`.findOneAndUpdate`, `.findOneAndRemove`,and `.findByIdAndRemove`.order
|
||||||
|
@ -25,10 +26,9 @@ AchievementSchema.methods.stringifyQuery = ->
|
||||||
@set('query', JSON.stringify(@get('query'))) if typeof @get('query') != 'string'
|
@set('query', JSON.stringify(@get('query'))) if typeof @get('query') != 'string'
|
||||||
|
|
||||||
AchievementSchema.methods.getExpFunction = ->
|
AchievementSchema.methods.getExpFunction = ->
|
||||||
# TODO DEFAULTS
|
func = @get('function') ? {}
|
||||||
kind = @get('function')?.kind or jsonschema.properties.function.default.kind
|
TreemaUtils.populateDefaults(func, jsonschema.properties.function)
|
||||||
parameters = @get('function')?.parameters or jsonschema.properties.function.default.parameters
|
return utils.functionCreators[func.kind](func.parameters) if func.kind of utils.functionCreators
|
||||||
return utils.functionCreators[kind](parameters) if kind of utils.functionCreators
|
|
||||||
|
|
||||||
AchievementSchema.methods.isRecalculable = -> @get('recalculable') isnt false
|
AchievementSchema.methods.isRecalculable = -> @get('recalculable') isnt false
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ logging = require './server/commons/logging'
|
||||||
config = require './server_config'
|
config = require './server_config'
|
||||||
auth = require './server/routes/auth'
|
auth = require './server/routes/auth'
|
||||||
UserHandler = require './server/users/user_handler'
|
UserHandler = require './server/users/user_handler'
|
||||||
|
global.tv4 = require 'tv4' # required for TreemaUtils to work
|
||||||
|
|
||||||
productionLogging = (tokens, req, res) ->
|
productionLogging = (tokens, req, res) ->
|
||||||
status = res.statusCode
|
status = res.statusCode
|
||||||
|
|
Loading…
Reference in a new issue