mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Merge pull request #114 from smoratinos/master
code style : wrap some lines that exceeds 120 characters, replace some '=>' by '->'
This commit is contained in:
commit
787faf82a3
8 changed files with 129 additions and 32 deletions
|
@ -192,8 +192,12 @@ module.exports = class Handler
|
|||
return @sendDatabaseError(res, err) if err
|
||||
@sendSuccess(res, @formatEntity(req, document))
|
||||
|
||||
# TODO: think about pulling some common stuff out of postFirstVersion/postNewVersion into a postVersion if we can figure out the breakpoints?
|
||||
# ..... actually, probably better would be to do the returns with throws instead and have a handler which turns them into status codes and messages
|
||||
###
|
||||
TODO: think about pulling some common stuff out of postFirstVersion/postNewVersion
|
||||
into a postVersion if we can figure out the breakpoints?
|
||||
..... actually, probably better would be to do the returns with throws instead
|
||||
and have a handler which turns them into status codes and messages
|
||||
###
|
||||
postFirstVersion: (req, res) ->
|
||||
return @sendBadInputError(res, 'No input.') if _.isEmpty(req.body)
|
||||
return @sendBadInputError(res, 'id should not be included.') if req.body._id
|
||||
|
@ -264,7 +268,7 @@ module.exports = class Handler
|
|||
@modelClass.findById(idOrSlug).exec (err, document) ->
|
||||
done(err, document)
|
||||
catch e
|
||||
@modelClass.findOne {slug: idOrSlug}, (err, document) =>
|
||||
@modelClass.findOne {slug: idOrSlug}, (err, document) ->
|
||||
done(err, document)
|
||||
|
||||
|
||||
|
|
|
@ -7,4 +7,6 @@ CampaignHandler = class CampaignHandler extends Handler
|
|||
modelClass: Campaign
|
||||
editableProperties: ['name', 'description', 'levels']
|
||||
|
||||
|
||||
|
||||
module.exports = new CampaignHandler()
|
|
@ -51,7 +51,7 @@ UserHandler = class UserHandler extends Handler
|
|||
fbAT = req.query.facebookAccessToken
|
||||
return callback(null, req, user) unless fbID and fbAT
|
||||
url = "https://graph.facebook.com/me?access_token=#{fbAT}"
|
||||
request(url, (error, response, body) =>
|
||||
request(url, (error, response, body) ->
|
||||
body = JSON.parse(body)
|
||||
emailsMatch = req.body.email is body.email
|
||||
return callback(res:'Invalid Facebook Access Token.', code:422) unless emailsMatch
|
||||
|
@ -64,7 +64,7 @@ UserHandler = class UserHandler extends Handler
|
|||
gpAT = req.query.gplusAccessToken
|
||||
return callback(null, req, user) unless gpID and gpAT
|
||||
url = "https://www.googleapis.com/oauth2/v2/userinfo?access_token=#{gpAT}"
|
||||
request(url, (error, response, body) =>
|
||||
request(url, (error, response, body) ->
|
||||
body = JSON.parse(body)
|
||||
emailsMatch = req.body.email is body.email
|
||||
return callback(res:'Invalid G+ Access Token.', code:422) unless emailsMatch
|
||||
|
|
|
@ -14,7 +14,8 @@ me.array = (ext, items) -> combine {type: 'array', items: items or {}}, ext
|
|||
me.shortString = (ext) -> combine({type: 'string', maxLength: 100}, ext)
|
||||
me.pct = (ext) -> combine({type: 'number', maximum: 1.0, minimum: 0.0}, ext)
|
||||
me.date = (ext) -> combine({type: 'string', format: 'date-time'}, ext)
|
||||
me.objectId = (ext) -> schema = combine({type: ['object', 'string'] }, ext) # should just be string (Mongo ID), but sometimes mongoose turns them into objects representing those, so we are lenient
|
||||
# should just be string (Mongo ID), but sometimes mongoose turns them into objects representing those, so we are lenient
|
||||
me.objectId = (ext) -> schema = combine({type: ['object', 'string'] }, ext)
|
||||
|
||||
PointSchema = me.object {title: "Point", description: "An {x, y} coordinate point.", format: "point2d", required: ["x", "y"]},
|
||||
x: {title: "x", description: "The x coordinate.", type: "number", "default": 15}
|
||||
|
@ -69,7 +70,8 @@ versionedProps = (linkFragment) ->
|
|||
minor: { type: 'number', minimum: 0 }
|
||||
isLatestMajor: { type: 'boolean' }
|
||||
isLatestMinor: { type: 'boolean' }
|
||||
original: me.objectId(links: [{rel: 'extra', href: "/db/#{linkFragment}/{($)}"}], format: 'hidden') # TODO: figure out useful 'rel' values here
|
||||
# TODO: figure out useful 'rel' values here
|
||||
original: me.objectId(links: [{rel: 'extra', href: "/db/#{linkFragment}/{($)}"}], format: 'hidden')
|
||||
parent: me.objectId(links: [{rel: 'extra', href: "/db/#{linkFragment}/{($)}"}], format: 'hidden')
|
||||
creator: me.objectId(links: [{rel: 'extra', href: "/db/user/{($)}"}], format: 'hidden')
|
||||
created: me.date( { title: 'Created', readOnly: true })
|
||||
|
@ -133,7 +135,11 @@ me.FunctionArgumentSchema = me.object {
|
|||
required: ['name', 'type', 'example', 'description', 'default']
|
||||
},
|
||||
name: {type: 'string', pattern: me.identifierPattern, title: "Name", description: "Name of the function argument."}
|
||||
type: me.shortString(title: "Type", description: "Intended type of the argument.") # not actual JS types, just whatever they describe...
|
||||
# not actual JS types, just whatever they describe...
|
||||
type: me.shortString(title: "Type", description: "Intended type of the argument.")
|
||||
example: me.shortString(title: "Example", description: "Example value for the argument.")
|
||||
description: {type: 'string', description: "Description of the argument.", maxLength: 1000}
|
||||
"default": {title: "Default", description: "Default value of the argument. (Your code should set this.)", "default": null}
|
||||
"default":
|
||||
title: "Default"
|
||||
description: "Default value of the argument. (Your code should set this.)"
|
||||
"default": null
|
||||
|
|
|
@ -7,11 +7,15 @@ class AttacksSelf extends Component
|
|||
chooseAction: ->
|
||||
@attack @
|
||||
"""
|
||||
systems = ["action", "ai", "alliance", "collision", "combat", "display", "event", "existence", "hearing", "inventory", "movement", "programming", "targeting", "ui", "vision", "misc", "physics"]
|
||||
systems = [
|
||||
"action", "ai", "alliance", "collision", "combat", "display", "event", "existence", "hearing"
|
||||
"inventory", "movement", "programming", "targeting", "ui", "vision", "misc", "physics"
|
||||
]
|
||||
|
||||
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."
|
||||
description: "Documentation entry for a property this Component will add to its Thang which other Components might
|
||||
want to also use."
|
||||
"default":
|
||||
name: "foo"
|
||||
type: "object"
|
||||
|
@ -19,7 +23,8 @@ PropertyDocumentationSchema = c.object {
|
|||
required: ['name', 'type', 'description']
|
||||
},
|
||||
name: {type: 'string', pattern: c.identifierPattern, title: "Name", description: "Name of the property."}
|
||||
type: c.shortString(title: "Type", description: "Intended type of the property.") # not actual JS types, just whatever they describe...
|
||||
# not actual JS types, just whatever they describe...
|
||||
type: c.shortString(title: "Type", description: "Intended type of the property.")
|
||||
description: {type: 'string', description: "Description of the property.", maxLength: 1000}
|
||||
args: c.array {title: "Arguments", description: "If this property has type 'function', then provide documentation for any function arguments."}, c.FunctionArgumentSchema
|
||||
|
||||
|
@ -34,7 +39,11 @@ DependencySchema = c.object {
|
|||
links: [{rel: "db", href: "/db/level.component/{(original)}/version/{(majorVersion)}"}]
|
||||
},
|
||||
original: c.objectId(title: "Original", description: "A reference to another Component upon which this Component depends.")
|
||||
majorVersion: {title: "Major Version", description: "Which major version of the Component this Component needs.", type: 'integer', minimum: 0}
|
||||
majorVersion:
|
||||
title: "Major Version"
|
||||
description: "Which major version of the Component this Component needs."
|
||||
type: 'integer'
|
||||
minimum: 0
|
||||
|
||||
LevelComponentSchema = c.object {
|
||||
title: "Component"
|
||||
|
@ -52,15 +61,43 @@ LevelComponentSchema = c.object {
|
|||
c.extendNamedProperties LevelComponentSchema # let's have the name be the first property
|
||||
LevelComponentSchema.properties.name.pattern = c.classNamePattern
|
||||
_.extend LevelComponentSchema.properties,
|
||||
system: {title: "System", 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."}
|
||||
language: {type: "string", title: "Language", description: "Which programming language this Component is written in.", "enum": ["coffeescript"]}
|
||||
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: {title: "JavaScript", description: "The transpiled JavaScript code for this Component", type: "string", format: "hidden"}
|
||||
system:
|
||||
title: "System"
|
||||
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."
|
||||
language:
|
||||
type: "string"
|
||||
title: "Language"
|
||||
description: "Which programming language this Component is written in."
|
||||
"enum": ["coffeescript"]
|
||||
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:
|
||||
title: "JavaScript"
|
||||
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
|
||||
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}
|
||||
official:
|
||||
type: "boolean"
|
||||
title: "Official"
|
||||
description: "Whether this is an official CodeCombat Component."
|
||||
"default": false
|
||||
|
||||
c.extendBasicProperties LevelComponentSchema, 'level.component'
|
||||
c.extendSearchableProperties LevelComponentSchema
|
||||
|
|
|
@ -20,7 +20,8 @@ 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."
|
||||
description: "Documentation entry for a property this System will add to its Thang which other Systems
|
||||
might want to also use."
|
||||
"default":
|
||||
name: "foo"
|
||||
type: "object"
|
||||
|
@ -28,7 +29,8 @@ PropertyDocumentationSchema = c.object {
|
|||
required: ['name', 'type', 'description']
|
||||
},
|
||||
name: {type: 'string', pattern: c.identifierPattern, title: "Name", description: "Name of the property."}
|
||||
type: c.shortString(title: "Type", description: "Intended type of the property.") # not actual JS types, just whatever they describe...
|
||||
# not actual JS types, just whatever they describe...
|
||||
type: c.shortString(title: "Type", description: "Intended type of the property.")
|
||||
description: {type: 'string', description: "Description of the property.", maxLength: 1000}
|
||||
args: c.array {title: "Arguments", description: "If this property has type 'function', then provide documentation for any function arguments."}, c.FunctionArgumentSchema
|
||||
|
||||
|
@ -43,7 +45,11 @@ DependencySchema = c.object {
|
|||
links: [{rel: "db", href: "/db/level.system/{(original)}/version/{(majorVersion)}"}]
|
||||
},
|
||||
original: c.objectId(title: "Original", description: "A reference to another System upon which this System depends.")
|
||||
majorVersion: {title: "Major Version", description: "Which major version of the System this System needs.", type: 'integer', minimum: 0}
|
||||
majorVersion:
|
||||
title: "Major Version"
|
||||
description: "Which major version of the System this System needs."
|
||||
type: 'integer'
|
||||
minimum: 0
|
||||
|
||||
LevelSystemSchema = c.object {
|
||||
title: "System"
|
||||
|
@ -60,14 +66,37 @@ LevelSystemSchema = c.object {
|
|||
c.extendNamedProperties LevelSystemSchema # let's have the name be the first property
|
||||
LevelSystemSchema.properties.name.pattern = c.classNamePattern
|
||||
_.extend LevelSystemSchema.properties,
|
||||
description: {title: "Description", description: "A short explanation of what this System does.", type: "string", maxLength: 2000, "default": "This System doesn't do anything yet."}
|
||||
language: {type: "string", title: "Language", description: "Which programming language this System is written in.", "enum": ["coffeescript"]}
|
||||
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: {title: "JavaScript", description: "The transpiled JavaScript code for this System", type: "string", format: "hidden"}
|
||||
description:
|
||||
title: "Description"
|
||||
description: "A short explanation of what this System does."
|
||||
type: "string"
|
||||
maxLength: 2000
|
||||
"default": "This System doesn't do anything yet."
|
||||
language:
|
||||
type: "string"
|
||||
title: "Language"
|
||||
description: "Which programming language this System is written in."
|
||||
"enum": ["coffeescript"]
|
||||
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:
|
||||
title: "JavaScript"
|
||||
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
|
||||
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}
|
||||
official:
|
||||
type: "boolean"
|
||||
title: "Official"
|
||||
description: "Whether this is an official CodeCombat System."
|
||||
"default": false
|
||||
|
||||
c.extendBasicProperties LevelSystemSchema, 'level.system'
|
||||
c.extendSearchableProperties LevelSystemSchema
|
||||
|
|
|
@ -12,4 +12,10 @@ module.exports = ThangComponentSchema = c.object {
|
|||
},
|
||||
original: c.objectId(title: "Original", description: "A reference to the original Component being configured.", format: "hidden")
|
||||
config: c.object {title: "Configuration", description: "Component-specific configuration properties.", additionalProperties: true, format: 'thang-component-configuration'}
|
||||
majorVersion: {title: "Major Version", description: "Which major version of the Component is being used.", type: 'integer', minimum: 0, default: 0, format: "hidden"}
|
||||
majorVersion:
|
||||
title: "Major Version"
|
||||
description: "Which major version of the Component is being used."
|
||||
type: 'integer'
|
||||
minimum: 0
|
||||
default: 0
|
||||
format: "hidden"
|
||||
|
|
|
@ -114,12 +114,25 @@ _.extend ThangTypeSchema.properties,
|
|||
rotationType: { title: 'Rotation', type: 'string', enum: ['isometric', 'fixed']}
|
||||
matchWorldDimensions: { title: 'Match World Dimensions', type: 'boolean' }
|
||||
shadow: { title: 'Shadow Diameter', type: 'number', format: 'meters', description: "Shadow diameter in meters" }
|
||||
layerPriority: { title: 'Layer Priority', type: 'integer', description: "Within its layer, sprites are sorted by layer priority, then y, then z." }
|
||||
scale: { title: 'Scale', type: 'number' }
|
||||
layerPriority:
|
||||
title: 'Layer Priority'
|
||||
type: 'integer'
|
||||
description: "Within its layer, sprites are sorted by layer priority, then y, then z."
|
||||
scale:
|
||||
title: 'Scale'
|
||||
type: 'number'
|
||||
positions: PositionsSchema
|
||||
snap: c.object { title: "Snap", description: "In the level editor, snap positioning to these intervals.", required: ['x', 'y'] },
|
||||
x: { title: "Snap X", type: 'number', description: "Snap to this many meters in the x-direction.", default: 4}
|
||||
y: { title: "Snap Y", type: 'number', description: "Snap to this many meters in the y-direction.", default: 4 }
|
||||
x:
|
||||
title: "Snap X"
|
||||
type: 'number'
|
||||
description: "Snap to this many meters in the x-direction."
|
||||
default: 4
|
||||
y:
|
||||
title: "Snap Y"
|
||||
type: 'number'
|
||||
description: "Snap to this many meters in the y-direction."
|
||||
default: 4
|
||||
components: c.array {title: "Components", description: "Thangs are configured by changing the Components attached to them.", uniqueItems: true, format: 'thang-components-array'}, ThangComponentSchema # TODO: uniqueness should be based on "original", not whole thing
|
||||
|
||||
ThangTypeSchema.definitions =
|
||||
|
|
Loading…
Reference in a new issue