mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
4001d1c7fe
6 changed files with 57 additions and 16 deletions
|
@ -106,11 +106,14 @@ module.exports = class HomeView extends View
|
||||||
|
|
||||||
onSimulateButtonClick: (e) =>
|
onSimulateButtonClick: (e) =>
|
||||||
@alreadyPostedResults = false
|
@alreadyPostedResults = false
|
||||||
|
console.log "Simulating world!"
|
||||||
$.ajax
|
$.ajax
|
||||||
url: "/queue/scoring"
|
url: "/queue/scoring"
|
||||||
type: "GET"
|
type: "GET"
|
||||||
error: (data) =>
|
error: (data) =>
|
||||||
console.log "There are no games to score. Error: #{data}"
|
console.log "There are no games to score. Error: #{JSON.stringify data}"
|
||||||
|
console.log "Retrying in ten seconds..."
|
||||||
|
_.delay @onSimulateButtonClick, 10000
|
||||||
success: (data) =>
|
success: (data) =>
|
||||||
console.log data
|
console.log data
|
||||||
levelName = data.sessions[0].levelID
|
levelName = data.sessions[0].levelID
|
||||||
|
@ -161,6 +164,7 @@ module.exports = class HomeView extends View
|
||||||
console.log "TASK REGISTRATION ERROR:#{JSON.stringify error}"
|
console.log "TASK REGISTRATION ERROR:#{JSON.stringify error}"
|
||||||
complete: (result) =>
|
complete: (result) =>
|
||||||
@alreadyPostedResults = true
|
@alreadyPostedResults = true
|
||||||
|
@onSimulateButtonClick()
|
||||||
|
|
||||||
|
|
||||||
translateGoalStatesIntoTaskResults: (goalStates) =>
|
translateGoalStatesIntoTaskResults: (goalStates) =>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
SpellListEntryView = require './spell_list_entry_view'
|
SpellListEntryView = require './spell_list_entry_view'
|
||||||
ThangAvatarView = require 'views/play/level/thang_avatar_view'
|
ThangAvatarView = require 'views/play/level/thang_avatar_view'
|
||||||
template = require 'templates/play/level/tome/spell_list_tab_entry'
|
template = require 'templates/play/level/tome/spell_list_tab_entry'
|
||||||
|
popoverTemplate = require 'templates/play/level/tome/spell_palette_entry_popover'
|
||||||
|
LevelComponent = require 'models/LevelComponent'
|
||||||
|
{downTheChain} = require 'lib/world/world_utils'
|
||||||
|
|
||||||
module.exports = class SpellListTabEntryView extends SpellListEntryView
|
module.exports = class SpellListTabEntryView extends SpellListEntryView
|
||||||
template: template
|
template: template
|
||||||
|
@ -47,17 +50,50 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
||||||
@avatar.render()
|
@avatar.render()
|
||||||
|
|
||||||
buildDocs: ->
|
buildDocs: ->
|
||||||
# TODO
|
|
||||||
#doc = Docs.getDocsFor(@thang, [@spell.name])[0]
|
|
||||||
#@$el.find('code').attr('title', doc.title()).popover(
|
|
||||||
# animation: true
|
|
||||||
# html: true
|
|
||||||
# placement: 'bottom'
|
|
||||||
# trigger: 'hover'
|
|
||||||
# content: doc.html()
|
|
||||||
# container: @$el.parent()
|
|
||||||
#)
|
|
||||||
@docsBuilt = true
|
@docsBuilt = true
|
||||||
|
lcs = @supermodel.getModels LevelComponent
|
||||||
|
found = false
|
||||||
|
for lc in lcs when not found
|
||||||
|
for doc in lc.get('propertyDocumentation') ? []
|
||||||
|
if doc.name is @spell.name
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
return unless found
|
||||||
|
doc.owner = 'this'
|
||||||
|
doc.shortName = doc.shorterName = doc.title = "this.#{doc.name}();"
|
||||||
|
@$el.popover(
|
||||||
|
animation: true
|
||||||
|
html: true
|
||||||
|
placement: 'bottom'
|
||||||
|
trigger: 'hover'
|
||||||
|
content: @formatPopover doc
|
||||||
|
container: @$el.parent()
|
||||||
|
)
|
||||||
|
|
||||||
|
formatPopover: (doc) ->
|
||||||
|
content = popoverTemplate doc: doc, marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in doc.args ? [])
|
||||||
|
owner = @thang
|
||||||
|
content = content.replace /#{spriteName}/g, @thang.spriteName # No quotes like we'd get with @formatValue
|
||||||
|
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||||
|
|
||||||
|
formatValue: (v) ->
|
||||||
|
# TODO: refactor and move spell_palette_entry_view version of this somewhere else
|
||||||
|
# maybe think about making it common with what Aether does and the SpellDebugView, too
|
||||||
|
if _.isNumber v
|
||||||
|
if v == Math.round v
|
||||||
|
return v
|
||||||
|
return v.toFixed 2
|
||||||
|
if _.isString v
|
||||||
|
return "\"#{v}\""
|
||||||
|
if v?.id
|
||||||
|
return v.id
|
||||||
|
if v?.name
|
||||||
|
return v.name
|
||||||
|
if _.isArray v
|
||||||
|
return '[' + (@formatValue v2 for v2 in v).join(', ') + ']'
|
||||||
|
if _.isPlainObject v
|
||||||
|
return safeJSONStringify v, 2
|
||||||
|
v
|
||||||
|
|
||||||
onMouseEnterAvatar: (e) -> # Don't call super
|
onMouseEnterAvatar: (e) -> # Don't call super
|
||||||
onMouseLeaveAvatar: (e) -> # Don't call super
|
onMouseLeaveAvatar: (e) -> # Don't call super
|
||||||
|
|
|
@ -30,7 +30,6 @@ module.exports = class SpellPaletteView extends View
|
||||||
|
|
||||||
props = @thang.programmableProperties ? []
|
props = @thang.programmableProperties ? []
|
||||||
snippets = @thang.programmableSnippets ? []
|
snippets = @thang.programmableSnippets ? []
|
||||||
console.log "yo got snippets", snippets
|
|
||||||
shortenize = props.length + snippets.length > 6
|
shortenize = props.length + snippets.length > 6
|
||||||
@entries = []
|
@entries = []
|
||||||
@entries.push @addEntry(allDocs[prop] ? prop, shortenize) for prop in props
|
@entries.push @addEntry(allDocs[prop] ? prop, shortenize) for prop in props
|
||||||
|
|
|
@ -142,8 +142,7 @@ me.FunctionArgumentSchema = me.object {
|
||||||
type: "object"
|
type: "object"
|
||||||
example: "this.getNearestEnemy()"
|
example: "this.getNearestEnemy()"
|
||||||
description: "The target of this function."
|
description: "The target of this function."
|
||||||
"default": null
|
required: ['name', 'type', 'example', 'description']
|
||||||
required: ['name', 'type', 'example', 'description', 'default']
|
|
||||||
},
|
},
|
||||||
name: {type: 'string', pattern: me.identifierPattern, title: "Name", description: "Name of the function argument."}
|
name: {type: 'string', pattern: me.identifierPattern, title: "Name", description: "Name of the function argument."}
|
||||||
# not actual JS types, just whatever they describe...
|
# not actual JS types, just whatever they describe...
|
||||||
|
|
|
@ -20,7 +20,7 @@ PropertyDocumentationSchema = c.object {
|
||||||
"default":
|
"default":
|
||||||
name: "foo"
|
name: "foo"
|
||||||
type: "object"
|
type: "object"
|
||||||
description: "This Component provides a 'foo' property to satisfy all one's foobar needs. Use it wisely."
|
description: 'The `foo` property can satisfy all the #{spriteName}\'s foobar needs. Use it wisely.'
|
||||||
required: ['name', 'type', 'description']
|
required: ['name', 'type', 'description']
|
||||||
},
|
},
|
||||||
name: {type: 'string', title: "Name", description: "Name of the property."}
|
name: {type: 'string', title: "Name", description: "Name of the property."}
|
||||||
|
|
|
@ -40,7 +40,10 @@ module.exports.createNewTask = (req, res) ->
|
||||||
LevelSession.find { "levelID": "project-dota", "submitted": true}, (err, submittedSessions) ->
|
LevelSession.find { "levelID": "project-dota", "submitted": true}, (err, submittedSessions) ->
|
||||||
taskPairs = []
|
taskPairs = []
|
||||||
for session in submittedSessions
|
for session in submittedSessions
|
||||||
if String(session._id) isnt req.body.session and session.team isnt sessionToScore.team
|
session = session.toObject()
|
||||||
|
console.log "Attemping to add session of team #{session.team} to taskPairs..."
|
||||||
|
if String(session._id) isnt req.body.session and session.team isnt sessionToScore.team and session.team in ["ogres","humans"]
|
||||||
|
console.log "Adding game to taskPairs!"
|
||||||
taskPairs.push [req.body.session,String session._id]
|
taskPairs.push [req.body.session,String session._id]
|
||||||
async.each taskPairs, sendTaskPairToQueue, (taskPairError) ->
|
async.each taskPairs, sendTaskPairToQueue, (taskPairError) ->
|
||||||
return errors.serverError res, "There was an error sending the task pairs to the queue" if taskPairError?
|
return errors.serverError res, "There was an error sending the task pairs to the queue" if taskPairError?
|
||||||
|
|
Loading…
Reference in a new issue