mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 01:25:42 -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'
|
||||
plugins = require('../plugins/plugins')
|
||||
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,
|
||||
# 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'
|
||||
|
||||
AchievementSchema.methods.getExpFunction = ->
|
||||
# TODO DEFAULTS
|
||||
kind = @get('function')?.kind or jsonschema.properties.function.default.kind
|
||||
parameters = @get('function')?.parameters or jsonschema.properties.function.default.parameters
|
||||
return utils.functionCreators[kind](parameters) if kind of utils.functionCreators
|
||||
func = @get('function') ? {}
|
||||
TreemaUtils.populateDefaults(func, jsonschema.properties.function)
|
||||
return utils.functionCreators[func.kind](func.parameters) if func.kind of utils.functionCreators
|
||||
|
||||
AchievementSchema.methods.isRecalculable = -> @get('recalculable') isnt false
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ logging = require './server/commons/logging'
|
|||
config = require './server_config'
|
||||
auth = require './server/routes/auth'
|
||||
UserHandler = require './server/users/user_handler'
|
||||
global.tv4 = require 'tv4' # required for TreemaUtils to work
|
||||
|
||||
productionLogging = (tokens, req, res) ->
|
||||
status = res.statusCode
|
||||
|
|
Loading…
Reference in a new issue