mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
commit
32147cc16b
10 changed files with 30 additions and 13 deletions
|
@ -165,7 +165,8 @@ module.exports = class Camera extends CocoClass
|
||||||
target = {x: newTargetX, y:newTargetY}
|
target = {x: newTargetX, y:newTargetY}
|
||||||
else
|
else
|
||||||
target = @target
|
target = @target
|
||||||
@zoomTo target, newZoom, 0
|
if not(newZoom >= MAX_ZOOM or newZoom <= Math.max(@minZoom, MIN_ZOOM))
|
||||||
|
@zoomTo target, newZoom, 0
|
||||||
|
|
||||||
onMouseDown: (e) ->
|
onMouseDown: (e) ->
|
||||||
return if @dragDisabled
|
return if @dragDisabled
|
||||||
|
|
|
@ -7,7 +7,6 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
@options.stage.addEventListener 'stagemousedown', @onMouseDown
|
@options.stage.addEventListener 'stagemousedown', @onMouseDown
|
||||||
@options.stage.addEventListener 'stagemousemove', @onMouseMove
|
@options.stage.addEventListener 'stagemousemove', @onMouseMove
|
||||||
@options.stage.addEventListener 'stagemouseup', @onMouseUp
|
@options.stage.addEventListener 'stagemouseup', @onMouseUp
|
||||||
@options.camera.dragDisabled = true
|
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@options.stage.removeEventListener 'stagemousedown', @onMouseDown
|
@options.stage.removeEventListener 'stagemousedown', @onMouseDown
|
||||||
|
@ -18,6 +17,7 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
onMouseDown: (e) =>
|
onMouseDown: (e) =>
|
||||||
return unless key.shift
|
return unless key.shift
|
||||||
@firstPoint = @options.camera.canvasToWorld {x: e.stageX, y: e.stageY}
|
@firstPoint = @options.camera.canvasToWorld {x: e.stageX, y: e.stageY}
|
||||||
|
@options.camera.dragDisabled = true
|
||||||
|
|
||||||
onMouseMove: (e) =>
|
onMouseMove: (e) =>
|
||||||
return unless @firstPoint
|
return unless @firstPoint
|
||||||
|
@ -30,6 +30,7 @@ module.exports = class RegionChooser extends CocoClass
|
||||||
Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint]
|
Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint]
|
||||||
@firstPoint = null
|
@firstPoint = null
|
||||||
@secondPoint = null
|
@secondPoint = null
|
||||||
|
@options.camera.dragDisabled = false
|
||||||
|
|
||||||
restrictRegion: ->
|
restrictRegion: ->
|
||||||
RATIO = 1.56876 # 924 / 589
|
RATIO = 1.56876 # 924 / 589
|
||||||
|
|
|
@ -29,7 +29,8 @@ module.exports = class AdminView extends View
|
||||||
espionageSuccess: (model) ->
|
espionageSuccess: (model) ->
|
||||||
storage.save('whoami',model)
|
storage.save('whoami',model)
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
|
|
||||||
espionageFailure: (jqxhr, status,error)->
|
espionageFailure: (jqxhr, status,error)->
|
||||||
console.log "There was an error entering espionage mode: #{error}"
|
console.log "There was an error entering espionage mode: #{error}"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,6 @@ module.exports = class ThangsTabView extends View
|
||||||
@surface.playing = false
|
@surface.playing = false
|
||||||
@surface.setWorld @world
|
@surface.setWorld @world
|
||||||
@surface.camera.zoomTo({x:262, y:-164}, 1.66, 0)
|
@surface.camera.zoomTo({x:262, y:-164}, 1.66, 0)
|
||||||
@surface.camera.dragDisabled = true
|
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
@selectAddThangType null
|
@selectAddThangType null
|
||||||
|
@ -168,6 +167,7 @@ module.exports = class ThangsTabView extends View
|
||||||
|
|
||||||
onSpriteDragged: (e) ->
|
onSpriteDragged: (e) ->
|
||||||
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
||||||
|
@surface.camera.dragDisabled = true
|
||||||
{stageX, stageY} = e.originalEvent
|
{stageX, stageY} = e.originalEvent
|
||||||
wop = @surface.camera.canvasToWorld x: stageX, y: stageY
|
wop = @surface.camera.canvasToWorld x: stageX, y: stageY
|
||||||
wop.z = @selectedExtantThang.depth / 2
|
wop.z = @selectedExtantThang.depth / 2
|
||||||
|
@ -178,6 +178,7 @@ module.exports = class ThangsTabView extends View
|
||||||
onSpriteMouseUp: (e) ->
|
onSpriteMouseUp: (e) ->
|
||||||
clearInterval(@movementInterval) if @movementInterval?
|
clearInterval(@movementInterval) if @movementInterval?
|
||||||
@movementInterval = null
|
@movementInterval = null
|
||||||
|
@surface.camera.dragDisabled = false
|
||||||
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
|
||||||
pos = @selectedExtantThang.pos
|
pos = @selectedExtantThang.pos
|
||||||
physicalOriginal = componentOriginals["physics.Physical"]
|
physicalOriginal = componentOriginals["physics.Physical"]
|
||||||
|
|
|
@ -102,7 +102,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
@$el.find('.rank-button').each (i, el) =>
|
@$el.find('.rank-button').each (i, el) =>
|
||||||
button = $(el)
|
button = $(el)
|
||||||
sessionID = button.data('session-id')
|
sessionID = button.data('session-id')
|
||||||
session = _.find @sessions.models, { id: sessionID }
|
session = _.find @sessions.models, {id: sessionID}
|
||||||
rankingState = 'unavailable'
|
rankingState = 'unavailable'
|
||||||
if @readyToRank session
|
if @readyToRank session
|
||||||
rankingState = 'rank'
|
rankingState = 'rank'
|
||||||
|
@ -119,14 +119,14 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
rankSession: (e) ->
|
rankSession: (e) ->
|
||||||
button = $(e.target).closest('.rank-button')
|
button = $(e.target).closest('.rank-button')
|
||||||
sessionID = button.data('session-id')
|
sessionID = button.data('session-id')
|
||||||
session = _.find @sessions.models, { id: sessionID }
|
session = _.find @sessions.models, {id: sessionID}
|
||||||
return unless @readyToRank(session)
|
return unless @readyToRank(session)
|
||||||
|
|
||||||
@setRankingButtonText(button, 'submitting')
|
@setRankingButtonText(button, 'submitting')
|
||||||
success = => @setRankingButtonText(button, 'submitted')
|
success = => @setRankingButtonText(button, 'submitted')
|
||||||
failure = => @setRankingButtonText(button, 'failed')
|
failure = => @setRankingButtonText(button, 'failed')
|
||||||
|
|
||||||
ajaxData = { session: sessionID, levelID: @level.id, originalLevelID: @level.attributes.original, levelMajorVersion: @level.attributes.version.major }
|
ajaxData = {session: sessionID, levelID: @level.id, originalLevelID: @level.attributes.original, levelMajorVersion: @level.attributes.version.major}
|
||||||
console.log "Posting game for ranking from My Matches view."
|
console.log "Posting game for ranking from My Matches view."
|
||||||
$.ajax '/queue/scoring', {
|
$.ajax '/queue/scoring', {
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
|
|
|
@ -458,10 +458,6 @@ module.exports = class SpectateLevelView extends View
|
||||||
else
|
else
|
||||||
cb(null, $.parseJSON(jqxhr.responseText))
|
cb(null, $.parseJSON(jqxhr.responseText))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
destroy: ()->
|
destroy: ()->
|
||||||
@supermodel?.off 'error', @onLevelLoadError
|
@supermodel?.off 'error', @onLevelLoadError
|
||||||
@levelLoader?.off 'loaded-all', @onLevelLoaderLoaded
|
@levelLoader?.off 'loaded-all', @onLevelLoaderLoaded
|
||||||
|
|
|
@ -185,7 +185,8 @@ class MongoQueue extends events.EventEmitter
|
||||||
subscribe: (eventName, callback) -> @on eventName, callback
|
subscribe: (eventName, callback) -> @on eventName, callback
|
||||||
unsubscribe: (eventName, callback) -> @removeListener eventName, callback
|
unsubscribe: (eventName, callback) -> @removeListener eventName, callback
|
||||||
|
|
||||||
|
totalMessagesInQueue: (callback) -> @Message.count {}, callback
|
||||||
|
|
||||||
receiveMessage: (callback) ->
|
receiveMessage: (callback) ->
|
||||||
conditions =
|
conditions =
|
||||||
queue: @queueName
|
queue: @queueName
|
||||||
|
|
|
@ -24,6 +24,17 @@ connectToScoringQueue = ->
|
||||||
if error? then throw new Error "There was an error registering the scoring queue: #{error}"
|
if error? then throw new Error "There was an error registering the scoring queue: #{error}"
|
||||||
scoringTaskQueue = data
|
scoringTaskQueue = data
|
||||||
log.info "Connected to scoring task queue!"
|
log.info "Connected to scoring task queue!"
|
||||||
|
|
||||||
|
module.exports.messagesInQueueCount = (req, res) ->
|
||||||
|
scoringTaskQueue.totalMessagesInQueue (err, count) ->
|
||||||
|
if err? then return errors.serverError res, "There was an issue finding the Mongoose count:#{err}"
|
||||||
|
response =
|
||||||
|
point:
|
||||||
|
number: count
|
||||||
|
timestamp: Date.now()
|
||||||
|
res.send(response)
|
||||||
|
res.end()
|
||||||
|
|
||||||
|
|
||||||
module.exports.addPairwiseTaskToQueueFromRequest = (req, res) ->
|
module.exports.addPairwiseTaskToQueueFromRequest = (req, res) ->
|
||||||
taskPair = req.body.sessions
|
taskPair = req.body.sessions
|
||||||
|
|
|
@ -9,6 +9,11 @@ module.exports.setup = (app) ->
|
||||||
#app.post '/queue/scoring/pairwise', (req, res) ->
|
#app.post '/queue/scoring/pairwise', (req, res) ->
|
||||||
# handler = loadQueueHandler 'scoring'
|
# handler = loadQueueHandler 'scoring'
|
||||||
# handler.addPairwiseTaskToQueue req, res
|
# handler.addPairwiseTaskToQueue req, res
|
||||||
|
|
||||||
|
app.get '/queue/messagesInQueueCount', (req, res) ->
|
||||||
|
handler = loadQueueHandler 'scoring'
|
||||||
|
handler.messagesInQueueCount req, res
|
||||||
|
|
||||||
|
|
||||||
app.all '/queue/*', (req, res) ->
|
app.all '/queue/*', (req, res) ->
|
||||||
setResponseHeaderToJSONContentType res
|
setResponseHeaderToJSONContentType res
|
||||||
|
|
|
@ -20,7 +20,7 @@ config = require './server_config'
|
||||||
# self.emit('pass',message)
|
# self.emit('pass',message)
|
||||||
# next()
|
# next()
|
||||||
|
|
||||||
productionLogging = (tokens, req, res)->
|
productionLogging = (tokens, req, res) ->
|
||||||
status = res.statusCode
|
status = res.statusCode
|
||||||
color = 32
|
color = 32
|
||||||
if status >= 500 then color = 31
|
if status >= 500 then color = 31
|
||||||
|
|
Loading…
Reference in a new issue