mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Refactoring defaults in schemas.
This commit is contained in:
parent
0721b49216
commit
78a4000e34
5 changed files with 14 additions and 27 deletions
|
@ -16,7 +16,7 @@ systems = [
|
|||
PropertyDocumentationSchema = c.object {
|
||||
title: 'Property Documentation'
|
||||
description: 'Documentation entry for a property this Component will add to its Thang which other Components might want to also use.'
|
||||
'default':
|
||||
default:
|
||||
name: 'foo'
|
||||
type: 'object'
|
||||
description: 'The `foo` property can satisfy all the #{spriteName}\'s foobar needs. Use it wisely.'
|
||||
|
@ -88,9 +88,6 @@ PropertyDocumentationSchema = c.object {
|
|||
DependencySchema = c.object {
|
||||
title: 'Component Dependency'
|
||||
description: 'A Component upon which this Component depends.'
|
||||
'default':
|
||||
#original: ?
|
||||
majorVersion: 0
|
||||
required: ['original', 'majorVersion']
|
||||
format: 'latest-version-reference'
|
||||
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
||||
|
@ -114,6 +111,7 @@ LevelComponentSchema = c.object {
|
|||
codeLanguage: 'coffeescript'
|
||||
dependencies: [] # TODO: should depend on something by default
|
||||
propertyDocumentation: []
|
||||
configSchema: {}
|
||||
}
|
||||
c.extendNamedProperties LevelComponentSchema # let's have the name be the first property
|
||||
LevelComponentSchema.properties.name.pattern = c.classNamePattern
|
||||
|
@ -123,13 +121,11 @@ _.extend LevelComponentSchema.properties,
|
|||
description: 'The short name of the System this Component belongs to, like \"ai\".'
|
||||
type: 'string'
|
||||
'enum': systems
|
||||
'default': 'ai'
|
||||
description:
|
||||
title: 'Description'
|
||||
description: 'A short explanation of what this Component does.'
|
||||
type: 'string'
|
||||
maxLength: 2000
|
||||
'default': 'This Component makes the Thang attack itself.'
|
||||
codeLanguage:
|
||||
type: 'string'
|
||||
title: 'Language'
|
||||
|
@ -138,7 +134,6 @@ _.extend LevelComponentSchema.properties,
|
|||
code:
|
||||
title: 'Code'
|
||||
description: 'The code for this Component, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
||||
'default': attackSelfCode
|
||||
type: 'string'
|
||||
format: 'coffee'
|
||||
js:
|
||||
|
@ -146,14 +141,13 @@ _.extend LevelComponentSchema.properties,
|
|||
description: 'The transpiled JavaScript code for this Component'
|
||||
type: 'string'
|
||||
format: 'hidden'
|
||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Components upon which this Component depends.', 'default': [], uniqueItems: true}, DependencySchema
|
||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this Component will add to its Thang which other Components might want to also use.', 'default': []}, PropertyDocumentationSchema
|
||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Components upon which this Component depends.', uniqueItems: true}, DependencySchema
|
||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this Component will add to its Thang which other Components might want to also use.'}, PropertyDocumentationSchema
|
||||
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this Component as configuration.', default: {type: 'object', additionalProperties: false}}
|
||||
official:
|
||||
type: 'boolean'
|
||||
title: 'Official'
|
||||
description: 'Whether this is an official CodeCombat Component.'
|
||||
'default': false
|
||||
|
||||
c.extendBasicProperties LevelComponentSchema, 'level.component'
|
||||
c.extendSearchableProperties LevelComponentSchema
|
||||
|
|
|
@ -2,7 +2,7 @@ c = require './../schemas'
|
|||
|
||||
LevelFeedbackLevelSchema = c.object {required: ['original', 'majorVersion']}, {
|
||||
original: c.objectId({})
|
||||
majorVersion: {type: 'integer', minimum: 0, default: 0}}
|
||||
majorVersion: {type: 'integer', minimum: 0 }}
|
||||
|
||||
LevelFeedbackSchema = c.object {
|
||||
title: 'Feedback'
|
||||
|
|
|
@ -18,11 +18,14 @@ LevelSessionLevelSchema = c.object {required: ['original', 'majorVersion'], link
|
|||
majorVersion:
|
||||
type: 'integer'
|
||||
minimum: 0
|
||||
default: 0
|
||||
|
||||
LevelSessionSchema = c.object
|
||||
title: 'Session'
|
||||
description: 'A single session for a given level.'
|
||||
default:
|
||||
codeLanguage: 'javascript'
|
||||
submittedCodeLanguage: 'javascript'
|
||||
playtime: 0
|
||||
|
||||
_.extend LevelSessionSchema.properties,
|
||||
# denormalization
|
||||
|
@ -123,12 +126,10 @@ _.extend LevelSessionSchema.properties,
|
|||
|
||||
codeLanguage:
|
||||
type: 'string'
|
||||
default: 'javascript'
|
||||
|
||||
playtime:
|
||||
type: 'number'
|
||||
title: 'Playtime'
|
||||
default: 0
|
||||
description: 'The total playtime on this session'
|
||||
|
||||
teamSpells:
|
||||
|
@ -167,7 +168,6 @@ _.extend LevelSessionSchema.properties,
|
|||
|
||||
submittedCodeLanguage:
|
||||
type: 'string'
|
||||
default: 'javascript'
|
||||
|
||||
transpiledCode:
|
||||
type: 'object'
|
||||
|
|
|
@ -21,7 +21,7 @@ class Jitter extends System
|
|||
PropertyDocumentationSchema = c.object {
|
||||
title: 'Property Documentation'
|
||||
description: 'Documentation entry for a property this System will add to its Thang which other Systems might want to also use.'
|
||||
'default':
|
||||
default:
|
||||
name: 'foo'
|
||||
type: 'object'
|
||||
description: 'This System provides a "foo" property to satisfy all one\'s foobar needs. Use it wisely.'
|
||||
|
@ -36,9 +36,6 @@ PropertyDocumentationSchema = c.object {
|
|||
DependencySchema = c.object {
|
||||
title: 'System Dependency'
|
||||
description: 'A System upon which this System depends.'
|
||||
'default':
|
||||
#original: ?
|
||||
majorVersion: 0
|
||||
required: ['original', 'majorVersion']
|
||||
format: 'latest-version-reference'
|
||||
links: [{rel: 'db', href: '/db/level.system/{(original)}/version/{(majorVersion)}'}]
|
||||
|
@ -54,7 +51,7 @@ LevelSystemSchema = c.object {
|
|||
title: 'System'
|
||||
description: 'A System which can affect Level behavior.'
|
||||
required: ['name', 'description', 'code', 'dependencies', 'propertyDocumentation', 'codeLanguage']
|
||||
'default':
|
||||
default:
|
||||
name: 'JitterSystem'
|
||||
description: 'This System makes all idle, movable Thangs jitter around.'
|
||||
code: jitterSystemCode
|
||||
|
@ -70,7 +67,6 @@ _.extend LevelSystemSchema.properties,
|
|||
description: 'A short explanation of what this System does.'
|
||||
type: 'string'
|
||||
maxLength: 2000
|
||||
'default': 'This System doesn\'t do anything yet.'
|
||||
codeLanguage:
|
||||
type: 'string'
|
||||
title: 'Language'
|
||||
|
@ -79,7 +75,6 @@ _.extend LevelSystemSchema.properties,
|
|||
code:
|
||||
title: 'Code'
|
||||
description: 'The code for this System, as a CoffeeScript class. TODO: add link to documentation for how to write these.'
|
||||
'default': jitterSystemCode
|
||||
type: 'string'
|
||||
format: 'coffee'
|
||||
js:
|
||||
|
@ -87,14 +82,13 @@ _.extend LevelSystemSchema.properties,
|
|||
description: 'The transpiled JavaScript code for this System'
|
||||
type: 'string'
|
||||
format: 'hidden'
|
||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Systems upon which this System depends.', 'default': [], uniqueItems: true}, DependencySchema
|
||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this System will add to its Level which other Systems might want to also use.', 'default': []}, PropertyDocumentationSchema
|
||||
dependencies: c.array {title: 'Dependencies', description: 'An array of Systems upon which this System depends.', uniqueItems: true}, DependencySchema
|
||||
propertyDocumentation: c.array {title: 'Property Documentation', description: 'An array of documentation entries for each notable property this System will add to its Level which other Systems might want to also use.'}, PropertyDocumentationSchema
|
||||
configSchema: _.extend metaschema, {title: 'Configuration Schema', description: 'A schema for validating the arguments that can be passed to this System as configuration.', default: {type: 'object', additionalProperties: false}}
|
||||
official:
|
||||
type: 'boolean'
|
||||
title: 'Official'
|
||||
description: 'Whether this is an official CodeCombat System.'
|
||||
'default': false
|
||||
|
||||
c.extendBasicProperties LevelSystemSchema, 'level.system'
|
||||
c.extendSearchableProperties LevelSystemSchema
|
||||
|
|
|
@ -5,7 +5,7 @@ module.exports = ThangComponentSchema = c.object {
|
|||
description: 'Configuration for a Component that this Thang uses.'
|
||||
format: 'component-reference'
|
||||
required: ['original', 'majorVersion']
|
||||
'default':
|
||||
default:
|
||||
majorVersion: 0
|
||||
config: {}
|
||||
links: [{rel: 'db', href: '/db/level.component/{(original)}/version/{(majorVersion)}'}]
|
||||
|
@ -17,5 +17,4 @@ module.exports = ThangComponentSchema = c.object {
|
|||
description: 'Which major version of the Component is being used.'
|
||||
type: 'integer'
|
||||
minimum: 0
|
||||
default: 0
|
||||
format: 'hidden'
|
||||
|
|
Loading…
Reference in a new issue