This commit is contained in:
Scott Erickson 2014-02-13 16:42:49 -08:00
commit 4001d1c7fe
6 changed files with 57 additions and 16 deletions

View file

@ -106,11 +106,14 @@ module.exports = class HomeView extends View
onSimulateButtonClick: (e) =>
@alreadyPostedResults = false
console.log "Simulating world!"
$.ajax
url: "/queue/scoring"
type: "GET"
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) =>
console.log data
levelName = data.sessions[0].levelID
@ -161,6 +164,7 @@ module.exports = class HomeView extends View
console.log "TASK REGISTRATION ERROR:#{JSON.stringify error}"
complete: (result) =>
@alreadyPostedResults = true
@onSimulateButtonClick()
translateGoalStatesIntoTaskResults: (goalStates) =>

View file

@ -1,6 +1,9 @@
SpellListEntryView = require './spell_list_entry_view'
ThangAvatarView = require 'views/play/level/thang_avatar_view'
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
template: template
@ -47,17 +50,50 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
@avatar.render()
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
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
onMouseLeaveAvatar: (e) -> # Don't call super

View file

@ -30,7 +30,6 @@ module.exports = class SpellPaletteView extends View
props = @thang.programmableProperties ? []
snippets = @thang.programmableSnippets ? []
console.log "yo got snippets", snippets
shortenize = props.length + snippets.length > 6
@entries = []
@entries.push @addEntry(allDocs[prop] ? prop, shortenize) for prop in props

View file

@ -142,8 +142,7 @@ me.FunctionArgumentSchema = me.object {
type: "object"
example: "this.getNearestEnemy()"
description: "The target of this function."
"default": null
required: ['name', 'type', 'example', 'description', 'default']
required: ['name', 'type', 'example', 'description']
},
name: {type: 'string', pattern: me.identifierPattern, title: "Name", description: "Name of the function argument."}
# not actual JS types, just whatever they describe...

View file

@ -20,7 +20,7 @@ PropertyDocumentationSchema = c.object {
"default":
name: "foo"
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']
},
name: {type: 'string', title: "Name", description: "Name of the property."}

View file

@ -40,7 +40,10 @@ module.exports.createNewTask = (req, res) ->
LevelSession.find { "levelID": "project-dota", "submitted": true}, (err, submittedSessions) ->
taskPairs = []
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]
async.each taskPairs, sendTaskPairToQueue, (taskPairError) ->
return errors.serverError res, "There was an error sending the task pairs to the queue" if taskPairError?