2014-05-11 10:13:13 -04:00
|
|
|
c = require './../schemas'
|
|
|
|
|
2014-05-13 16:46:56 -04:00
|
|
|
# TODO add these: http://docs.mongodb.org/manual/reference/operator/query/
|
|
|
|
MongoQueryOperatorSchema =
|
2014-09-04 14:16:01 -04:00
|
|
|
title: 'Query Operator'
|
2014-05-13 16:46:56 -04:00
|
|
|
type: 'object'
|
|
|
|
properties:
|
|
|
|
'$gt': type: 'number'
|
|
|
|
'$gte': type: 'number'
|
|
|
|
'$in': type: 'array'
|
|
|
|
'$lt': type: 'number'
|
|
|
|
'$lte': type: 'number'
|
2014-06-30 22:16:26 -04:00
|
|
|
'$ne': type: ['number', 'string']
|
2014-05-13 16:46:56 -04:00
|
|
|
'$nin': type: 'array'
|
2014-09-04 14:16:01 -04:00
|
|
|
'$exists': type: 'boolean'
|
|
|
|
additionalProperties: false
|
2014-05-21 07:52:09 -04:00
|
|
|
|
|
|
|
MongoFindQuerySchema =
|
2014-09-04 14:16:01 -04:00
|
|
|
title: 'Query'
|
2014-05-21 07:52:09 -04:00
|
|
|
type: 'object'
|
|
|
|
patternProperties:
|
2015-11-28 11:39:05 -05:00
|
|
|
'^[-a-zA-Z0-9._]*$':
|
2014-09-04 14:16:01 -04:00
|
|
|
anyOf: [
|
|
|
|
{$ref: '#/definitions/mongoQueryOperator'},
|
2014-07-28 09:14:11 -04:00
|
|
|
{type: 'string'}
|
2014-06-30 22:16:26 -04:00
|
|
|
{type: 'object'}
|
2014-07-28 09:14:11 -04:00
|
|
|
{type: 'boolean'}
|
2014-05-21 07:52:09 -04:00
|
|
|
]
|
2015-11-17 18:24:33 -05:00
|
|
|
properties: {}
|
2014-09-04 14:16:01 -04:00
|
|
|
additionalProperties: false
|
2014-05-21 07:52:09 -04:00
|
|
|
definitions: {}
|
|
|
|
|
2014-05-21 13:47:17 -04:00
|
|
|
AchievementSchema = c.object()
|
2014-05-21 07:52:09 -04:00
|
|
|
c.extendNamedProperties AchievementSchema
|
2014-08-07 16:03:00 -04:00
|
|
|
c.extendBasicProperties AchievementSchema, 'achievement'
|
2014-05-21 07:52:09 -04:00
|
|
|
c.extendSearchableProperties AchievementSchema
|
|
|
|
|
2014-08-23 18:51:59 -04:00
|
|
|
AchievementSchema.default =
|
|
|
|
worth: 10
|
|
|
|
description: 'Probably the coolest you\'ll ever get.'
|
|
|
|
difficulty: 1
|
|
|
|
recalculable: true
|
|
|
|
function: {}
|
|
|
|
|
2014-07-28 08:13:38 -04:00
|
|
|
_.extend AchievementSchema.properties,
|
2014-05-21 13:47:17 -04:00
|
|
|
query:
|
2014-05-22 10:59:01 -04:00
|
|
|
#type:'object'
|
2014-09-04 14:16:01 -04:00
|
|
|
$ref: '#/definitions/mongoFindQuery'
|
2014-09-26 05:28:54 -04:00
|
|
|
worth: c.float()
|
2014-06-30 22:16:26 -04:00
|
|
|
collection: {type: 'string'}
|
2014-08-23 18:51:59 -04:00
|
|
|
description: c.shortString()
|
2014-08-05 08:33:33 -04:00
|
|
|
userField: c.shortString()
|
2014-05-22 10:59:01 -04:00
|
|
|
related: c.objectId(description: 'Related entity')
|
2014-08-18 17:36:13 -04:00
|
|
|
icon: {type: 'string', format: 'image-file', title: 'Icon', description: 'Image should be a 100x100 transparent png.'}
|
2014-07-28 08:13:38 -04:00
|
|
|
category:
|
2014-08-07 16:03:00 -04:00
|
|
|
enum: ['level', 'ladder', 'contributor']
|
|
|
|
description: 'For categorizing and display purposes'
|
2014-07-28 08:13:38 -04:00
|
|
|
difficulty: c.int
|
|
|
|
description: 'The higher the more difficult'
|
2014-05-21 13:47:17 -04:00
|
|
|
proportionalTo:
|
|
|
|
type: 'string'
|
|
|
|
description: 'For repeatables only. Denotes the field a repeatable achievement needs for its calculations'
|
2014-08-03 17:58:51 -04:00
|
|
|
recalculable:
|
|
|
|
type: 'boolean'
|
2014-09-30 22:32:11 -04:00
|
|
|
description: 'Deprecated: all achievements must be recalculable now. Used to need to be set to true before it is eligible for recalculation.'
|
2014-05-31 17:19:55 -04:00
|
|
|
function:
|
|
|
|
type: 'object'
|
2014-07-28 08:13:38 -04:00
|
|
|
description: 'Function that gives total experience for X amount achieved'
|
2014-06-03 06:40:47 -04:00
|
|
|
properties:
|
2015-02-18 12:06:32 -05:00
|
|
|
kind: {enum: ['linear', 'logarithmic', 'quadratic', 'pow'] }
|
2014-06-03 06:40:47 -04:00
|
|
|
parameters:
|
2014-05-31 17:19:55 -04:00
|
|
|
type: 'object'
|
2014-08-29 19:28:07 -04:00
|
|
|
default: { a: 1, b: 0, c: 0 }
|
2014-05-31 17:19:55 -04:00
|
|
|
properties:
|
2014-08-23 18:51:59 -04:00
|
|
|
a: {type: 'number' }
|
|
|
|
b: {type: 'number' }
|
|
|
|
c: {type: 'number' }
|
2014-06-14 14:12:17 -04:00
|
|
|
additionalProperties: true
|
2014-08-23 18:51:59 -04:00
|
|
|
default: {kind: 'linear', parameters: {}}
|
2014-06-03 06:40:47 -04:00
|
|
|
required: ['kind', 'parameters']
|
|
|
|
additionalProperties: false
|
2014-10-27 20:11:48 -04:00
|
|
|
i18n: {type: 'object', format: 'i18n', props: ['name', 'description'], description: 'Help translate this achievement'}
|
2014-09-26 05:28:54 -04:00
|
|
|
rewards: c.RewardSchema 'awarded by this achievement'
|
|
|
|
|
2014-07-28 08:13:38 -04:00
|
|
|
|
|
|
|
_.extend AchievementSchema, # Let's have these on the bottom
|
2014-08-05 08:33:33 -04:00
|
|
|
# TODO We really need some required properties in my opinion but this makes creating new achievements impossible as it is now
|
|
|
|
#required: ['name', 'description', 'query', 'worth', 'collection', 'userField', 'category', 'difficulty']
|
2014-07-28 08:13:38 -04:00
|
|
|
additionalProperties: false
|
2014-05-21 13:47:17 -04:00
|
|
|
|
|
|
|
AchievementSchema.definitions = {}
|
2014-09-04 14:16:01 -04:00
|
|
|
AchievementSchema.definitions['mongoQueryOperator'] = MongoQueryOperatorSchema
|
|
|
|
AchievementSchema.definitions['mongoFindQuery'] = MongoFindQuerySchema
|
2014-10-27 20:11:48 -04:00
|
|
|
c.extendTranslationCoverageProperties AchievementSchema
|
2015-02-05 15:01:19 -05:00
|
|
|
c.extendPatchableProperties AchievementSchema
|
2014-05-21 13:47:17 -04:00
|
|
|
|
2014-05-21 07:52:09 -04:00
|
|
|
module.exports = AchievementSchema
|