mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-12 00:31:21 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
f076b09686
8 changed files with 71 additions and 45 deletions
|
@ -767,6 +767,8 @@
|
||||||
current_value: "Current Value"
|
current_value: "Current Value"
|
||||||
default_value: "Default value"
|
default_value: "Default value"
|
||||||
parameters: "Parameters"
|
parameters: "Parameters"
|
||||||
|
required_parameters: "Required Parameters"
|
||||||
|
optional_parameters: "Optional Parameters"
|
||||||
returns: "Returns"
|
returns: "Returns"
|
||||||
granted_by: "Granted by"
|
granted_by: "Granted by"
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ me.FunctionArgumentSchema = me.object {
|
||||||
'default':
|
'default':
|
||||||
name: 'target'
|
name: 'target'
|
||||||
type: 'object'
|
type: 'object'
|
||||||
|
optional: false
|
||||||
example: 'this.getNearestEnemy()'
|
example: 'this.getNearestEnemy()'
|
||||||
description: 'The target of this function.'
|
description: 'The target of this function.'
|
||||||
required: ['name', 'type', 'example', 'description']
|
required: ['name', 'type', 'example', 'description']
|
||||||
|
@ -173,6 +174,7 @@ me.FunctionArgumentSchema = me.object {
|
||||||
i18n: { type: 'object', format: 'i18n', props: ['description'], description: 'Help translate this argument'}
|
i18n: { type: 'object', format: 'i18n', props: ['description'], description: 'Help translate this 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.')
|
type: me.shortString(title: 'Type', description: 'Intended type of the argument.')
|
||||||
|
optional: {title: 'Optional', description: 'Whether an argument may be omitted when calling the function', type: 'boolean'}
|
||||||
example:
|
example:
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,7 +95,7 @@ if !selectedMethod
|
||||||
else if language == 'io'
|
else if language == 'io'
|
||||||
span= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + docName + '(' + argumentExamples.join(', ') + ')'
|
span= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + docName + '(' + argumentExamples.join(', ') + ')'
|
||||||
|
|
||||||
if (doc.type != 'function' && doc.type != 'snippet' && doc.owner != 'HTML' && doc.owner != 'CSS') || doc.name == 'now'
|
if (doc.type != 'function' && doc.type != 'snippet' && !_.contains(['HTML', 'CSS', 'WebJavaScript', 'jQuery'], doc.owner)) || doc.name == 'now'
|
||||||
p.value
|
p.value
|
||||||
strong
|
strong
|
||||||
span(data-i18n="skill_docs.current_value") Current Value
|
span(data-i18n="skill_docs.current_value") Current Value
|
||||||
|
@ -103,30 +103,47 @@ if (doc.type != 'function' && doc.type != 'snippet' && doc.owner != 'HTML' && do
|
||||||
pre
|
pre
|
||||||
code.current-value(data-prop=doc.name)= value
|
code.current-value(data-prop=doc.name)= value
|
||||||
|
|
||||||
|
mixin argumentEntry(arg)
|
||||||
|
div
|
||||||
|
code= arg.name
|
||||||
|
span.spr :
|
||||||
|
code= arg.type
|
||||||
|
if arg.example
|
||||||
|
| (
|
||||||
|
span(data-i18n="skill_docs.ex") ex
|
||||||
|
span.spr :
|
||||||
|
code= arg.example
|
||||||
|
| )
|
||||||
|
if arg.description
|
||||||
|
div!= marked(arg.description)
|
||||||
|
if arg.default
|
||||||
|
div
|
||||||
|
em
|
||||||
|
span(data-i18n="skill_docs.default_value") Default value
|
||||||
|
span.spr :
|
||||||
|
code= arg.default
|
||||||
|
|
||||||
if doc.args && doc.args.length
|
if doc.args && doc.args.length
|
||||||
|
- var hasOptionalArguments = _.any(doc.args, function(arg){ return arg.optional })
|
||||||
p.args
|
p.args
|
||||||
strong
|
strong
|
||||||
span(data-i18n="skill_docs.parameters") Parameters
|
if hasOptionalArguments
|
||||||
|
span(data-i18n="skill_docs.required_parameters") Required Parameters
|
||||||
|
else
|
||||||
|
span(data-i18n="skill_docs.parameters") Parameters
|
||||||
span.spr :
|
span.spr :
|
||||||
for arg in doc.args
|
for arg in doc.args
|
||||||
div
|
unless arg.optional
|
||||||
code= arg.name
|
+argumentEntry(arg)
|
||||||
|
if hasOptionalArguments
|
||||||
|
p.args
|
||||||
|
strong
|
||||||
|
span(data-i18n="skill_docs.optional_parameters") Optional Parameters
|
||||||
span.spr :
|
span.spr :
|
||||||
code= arg.type
|
for arg in doc.args
|
||||||
if arg.example
|
if arg.optional
|
||||||
| (
|
+argumentEntry(arg)
|
||||||
span(data-i18n="skill_docs.ex") ex
|
|
||||||
span.spr :
|
|
||||||
code= arg.example
|
|
||||||
| )
|
|
||||||
if arg.description
|
|
||||||
div!= marked(arg.description)
|
|
||||||
if arg.default
|
|
||||||
div
|
|
||||||
em
|
|
||||||
span(data-i18n="skill_docs.default_value") Default value
|
|
||||||
span.spr :
|
|
||||||
code= arg.default
|
|
||||||
|
|
||||||
if doc.returns
|
if doc.returns
|
||||||
p.returns
|
p.returns
|
||||||
|
|
|
@ -49,7 +49,7 @@ module.exports = class DocFormatter
|
||||||
@doc.type = 'snippet'
|
@doc.type = 'snippet'
|
||||||
@doc.owner = 'snippets'
|
@doc.owner = 'snippets'
|
||||||
@doc.shortName = @doc.shorterName = @doc.title = @doc.name
|
@doc.shortName = @doc.shorterName = @doc.title = @doc.name
|
||||||
else if @doc.owner in ['HTML', 'CSS']
|
else if @doc.owner in ['HTML', 'CSS', 'WebJavaScript', 'jQuery']
|
||||||
@doc.shortName = @doc.shorterName = @doc.title = @doc.name
|
@doc.shortName = @doc.shorterName = @doc.title = @doc.name
|
||||||
else
|
else
|
||||||
@doc.owner ?= 'this'
|
@doc.owner ?= 'this'
|
||||||
|
@ -165,7 +165,19 @@ module.exports = class DocFormatter
|
||||||
[docName, args] = @getDocNameAndArguments()
|
[docName, args] = @getDocNameAndArguments()
|
||||||
argumentExamples = (arg.example or arg.default or arg.name for arg in @doc.args ? [])
|
argumentExamples = (arg.example or arg.default or arg.name for arg in @doc.args ? [])
|
||||||
argumentExamples.unshift args[0] if args.length > argumentExamples.length
|
argumentExamples.unshift args[0] if args.length > argumentExamples.length
|
||||||
content = popoverTemplate doc: @doc, docName: docName, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: argumentExamples, writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
content = popoverTemplate {
|
||||||
|
doc: @doc
|
||||||
|
docName: docName
|
||||||
|
language: @options.language
|
||||||
|
value: @formatValue()
|
||||||
|
marked: marked
|
||||||
|
argumentExamples: argumentExamples
|
||||||
|
writable: @options.writable
|
||||||
|
selectedMethod: @options.selectedMethod
|
||||||
|
cooldowns: @inferCooldowns()
|
||||||
|
item: @options.item
|
||||||
|
_: _
|
||||||
|
}
|
||||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||||
content = @replaceSpriteName content
|
content = @replaceSpriteName content
|
||||||
content = content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
content = content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||||
|
|
|
@ -157,6 +157,8 @@ module.exports = class SpellPaletteView extends CocoView
|
||||||
LoDash: 'programmableLoDashProperties'
|
LoDash: 'programmableLoDashProperties'
|
||||||
Vector: 'programmableVectorProperties'
|
Vector: 'programmableVectorProperties'
|
||||||
HTML: 'programmableHTMLProperties'
|
HTML: 'programmableHTMLProperties'
|
||||||
|
WebJavaScript: 'programmableWebJavaScriptProperties'
|
||||||
|
jQuery: 'programmableJQueryProperties'
|
||||||
CSS: 'programmableCSSProperties'
|
CSS: 'programmableCSSProperties'
|
||||||
snippets: 'programmableSnippets'
|
snippets: 'programmableSnippets'
|
||||||
else
|
else
|
||||||
|
@ -197,7 +199,7 @@ module.exports = class SpellPaletteView extends CocoView
|
||||||
return 'more' if entry.doc.owner is 'this' and entry.doc.name in (propGroups.more ? [])
|
return 'more' if entry.doc.owner is 'this' and entry.doc.name in (propGroups.more ? [])
|
||||||
entry.doc.owner
|
entry.doc.owner
|
||||||
@entries = _.sortBy @entries, (entry) ->
|
@entries = _.sortBy @entries, (entry) ->
|
||||||
order = ['this', 'more', 'Math', 'Vector', 'String', 'Object', 'Array', 'Function', 'HTML', 'CSS', 'snippets']
|
order = ['this', 'more', 'Math', 'Vector', 'String', 'Object', 'Array', 'Function', 'HTML', 'CSS', 'WebJavaScript', 'jQuery', 'snippets']
|
||||||
index = order.indexOf groupForEntry entry
|
index = order.indexOf groupForEntry entry
|
||||||
index = String.fromCharCode if index is -1 then order.length else index
|
index = String.fromCharCode if index is -1 then order.length else index
|
||||||
index += entry.doc.name
|
index += entry.doc.name
|
||||||
|
@ -248,7 +250,7 @@ module.exports = class SpellPaletteView extends CocoView
|
||||||
console.log @thang.id, "couldn't find item ThangType for", slot, thangTypeName
|
console.log @thang.id, "couldn't find item ThangType for", slot, thangTypeName
|
||||||
|
|
||||||
# Get any Math-, Vector-, etc.-owned properties into their own tabs
|
# Get any Math-, Vector-, etc.-owned properties into their own tabs
|
||||||
for owner, storage of propStorage when not (owner in ['this', 'more', 'snippets', 'HTML', 'CSS'])
|
for owner, storage of propStorage when not (owner in ['this', 'more', 'snippets', 'HTML', 'CSS', 'WebJavaScript', 'jQuery'])
|
||||||
continue unless @thang[storage]?.length
|
continue unless @thang[storage]?.length
|
||||||
@tabs ?= {}
|
@tabs ?= {}
|
||||||
@tabs[owner] = []
|
@tabs[owner] = []
|
||||||
|
@ -262,7 +264,7 @@ module.exports = class SpellPaletteView extends CocoView
|
||||||
|
|
||||||
# Assign any unassigned properties to the hero itself.
|
# Assign any unassigned properties to the hero itself.
|
||||||
for owner, storage of propStorage
|
for owner, storage of propStorage
|
||||||
continue unless owner in ['this', 'more', 'snippets', 'HTML', 'CSS']
|
continue unless owner in ['this', 'more', 'snippets', 'HTML', 'CSS', 'WebJavaScript', 'jQuery']
|
||||||
for prop in _.reject(@thang[storage] ? [], (prop) -> itemsByProp[prop] or prop[0] is '_') # no private properties
|
for prop in _.reject(@thang[storage] ? [], (prop) -> itemsByProp[prop] or prop[0] is '_') # no private properties
|
||||||
continue if prop is 'say' and @options.level.get 'hidesSay' # Hide for Dungeon Campaign
|
continue if prop is 'say' and @options.level.get 'hidesSay' # Hide for Dungeon Campaign
|
||||||
continue if prop is 'moveXY' and @options.level.get('slug') is 'slalom' # Hide for Slalom
|
continue if prop is 'moveXY' and @options.level.get('slug') is 'slalom' # Hide for Slalom
|
||||||
|
|
|
@ -157,14 +157,14 @@ module.exports = class TomeView extends CocoView
|
||||||
if @options.observing
|
if @options.observing
|
||||||
difficulty = Math.max 0, difficulty - 1 # Show the difficulty they won, not the next one.
|
difficulty = Math.max 0, difficulty - 1 # Show the difficulty they won, not the next one.
|
||||||
Backbone.Mediator.publish 'tome:cast-spells', {
|
Backbone.Mediator.publish 'tome:cast-spells', {
|
||||||
@spells,
|
@spells,
|
||||||
preload,
|
preload,
|
||||||
realTime,
|
realTime,
|
||||||
justBegin,
|
justBegin,
|
||||||
difficulty,
|
difficulty,
|
||||||
submissionCount: sessionState.submissionCount ? 0,
|
submissionCount: sessionState.submissionCount ? 0,
|
||||||
flagHistory: sessionState.flagHistory ? [],
|
flagHistory: sessionState.flagHistory ? [],
|
||||||
god: @options.god,
|
god: @options.god,
|
||||||
fixedSeed: @options.fixedSeed
|
fixedSeed: @options.fixedSeed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,11 +229,13 @@ module.exports = class TomeView extends CocoView
|
||||||
return null unless hero = _.find @options.level.get('thangs'), id: 'Hero Placeholder'
|
return null unless hero = _.find @options.level.get('thangs'), id: 'Hero Placeholder'
|
||||||
return null unless programmableConfig = _.find(hero.components, (component) -> component.config?.programmableMethods).config
|
return null unless programmableConfig = _.find(hero.components, (component) -> component.config?.programmableMethods).config
|
||||||
usesHTMLConfig = _.find(hero.components, (component) -> component.config?.programmableHTMLProperties).config
|
usesHTMLConfig = _.find(hero.components, (component) -> component.config?.programmableHTMLProperties).config
|
||||||
|
usesWebJavaScriptConfig = _.find(hero.components, (component) -> component.config?.programmableWebJavaScriptProperties)?.config
|
||||||
|
usesJQueryConfig = _.find(hero.components, (component) -> component.config?.programmableJQueryProperties)?.config
|
||||||
console.warn "Couldn't find usesHTML config; is it presented and not defaulted on the Hero Placeholder?" unless usesHTMLConfig
|
console.warn "Couldn't find usesHTML config; is it presented and not defaulted on the Hero Placeholder?" unless usesHTMLConfig
|
||||||
thang =
|
thang =
|
||||||
id: 'Hero Placeholder'
|
id: 'Hero Placeholder'
|
||||||
isProgrammable: true
|
isProgrammable: true
|
||||||
thang = _.merge thang, programmableConfig, usesHTMLConfig
|
thang = _.merge thang, programmableConfig, usesHTMLConfig, usesWebJavaScriptConfig, usesJQueryConfig
|
||||||
thang
|
thang
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
|
|
|
@ -12,7 +12,7 @@ module.exports =
|
||||||
|
|
||||||
connect: () ->
|
connect: () ->
|
||||||
address = module.exports.generateMongoConnectionString()
|
address = module.exports.generateMongoConnectionString()
|
||||||
winston.info "Connecting to Mongo with connection string #{address}"
|
winston.info "Connecting to Mongo with connection string #{address}, readpref: #{config.mongo.readpref}"
|
||||||
|
|
||||||
mongoose.connect address
|
mongoose.connect address
|
||||||
mongoose.connection.once 'open', -> Grid.gfs = Grid(mongoose.connection.db, mongoose.mongo)
|
mongoose.connection.once 'open', -> Grid.gfs = Grid(mongoose.connection.db, mongoose.mongo)
|
||||||
|
@ -25,11 +25,7 @@ module.exports =
|
||||||
mongooseCache.install(mongoose, {max: 1000, maxAge: maxAge, debug: false}, Aggregate)
|
mongooseCache.install(mongoose, {max: 1000, maxAge: maxAge, debug: false}, Aggregate)
|
||||||
|
|
||||||
generateMongoConnectionString: ->
|
generateMongoConnectionString: ->
|
||||||
if not global.testing and config.tokyo
|
if not global.testing and config.mongo.mongoose_replica_string
|
||||||
address = config.mongo.mongoose_tokyo_replica_string
|
|
||||||
else if not global.testing and config.saoPaulo
|
|
||||||
address = config.mongo.mongoose_saoPaulo_replica_string
|
|
||||||
else if not global.testing and config.mongo.mongoose_replica_string
|
|
||||||
address = config.mongo.mongoose_replica_string
|
address = config.mongo.mongoose_replica_string
|
||||||
else
|
else
|
||||||
dbName = config.mongo.db
|
dbName = config.mongo.db
|
||||||
|
|
|
@ -23,8 +23,7 @@ config.mongo =
|
||||||
analytics_db: process.env.COCO_MONGO_ANALYTICS_DATABASE_NAME or 'analytics'
|
analytics_db: process.env.COCO_MONGO_ANALYTICS_DATABASE_NAME or 'analytics'
|
||||||
analytics_collection: process.env.COCO_MONGO_ANALYTICS_COLLECTION or 'analytics.log.event'
|
analytics_collection: process.env.COCO_MONGO_ANALYTICS_COLLECTION or 'analytics.log.event'
|
||||||
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
|
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
|
||||||
mongoose_tokyo_replica_string: process.env.COCO_MONGO_MONGOOSE_TOKYO_REPLICA_STRING or ''
|
readpref: process.env.COCO_MONGO_READPREF or 'primary'
|
||||||
mongoose_saoPaulo_replica_string : process.env.COCO_MONGO_MONGOOSE_SAOPAULO_REPLICA_STRING or ''
|
|
||||||
|
|
||||||
if process.env.COCO_MONGO_LS_REPLICA_STRING?
|
if process.env.COCO_MONGO_LS_REPLICA_STRING?
|
||||||
config.mongo.level_session_replica_string = process.env.COCO_MONGO_LS_REPLICA_STRING
|
config.mongo.level_session_replica_string = process.env.COCO_MONGO_LS_REPLICA_STRING
|
||||||
|
@ -32,12 +31,6 @@ if process.env.COCO_MONGO_LS_REPLICA_STRING?
|
||||||
if process.env.COCO_MONGO_LS_AUX_REPLICA_STRING?
|
if process.env.COCO_MONGO_LS_AUX_REPLICA_STRING?
|
||||||
config.mongo.level_session_aux_replica_string = process.env.COCO_MONGO_LS_AUX_REPLICA_STRING
|
config.mongo.level_session_aux_replica_string = process.env.COCO_MONGO_LS_AUX_REPLICA_STRING
|
||||||
|
|
||||||
|
|
||||||
if config.tokyo or config.saoPaulo
|
|
||||||
config.mongo.readpref = 'nearest'
|
|
||||||
else
|
|
||||||
config.mongo.readpref = 'primary'
|
|
||||||
|
|
||||||
config.apple =
|
config.apple =
|
||||||
verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://sandbox.itunes.apple.com/verifyReceipt'
|
verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://sandbox.itunes.apple.com/verifyReceipt'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue