mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-04 12:51:12 -05:00
commit
8544939b35
9 changed files with 83 additions and 10 deletions
|
@ -273,7 +273,7 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
@selectedSprite?.selected = false
|
@selectedSprite?.selected = false
|
||||||
sprite?.selected = true
|
sprite?.selected = true
|
||||||
@selectedSprite = sprite
|
@selectedSprite = sprite
|
||||||
alive = not (sprite?.thang.health < 0)
|
alive = sprite and not (sprite.thang.health < 0)
|
||||||
|
|
||||||
Backbone.Mediator.publish 'surface:sprite-selected',
|
Backbone.Mediator.publish 'surface:sprite-selected',
|
||||||
thang: if sprite then sprite.thang else null
|
thang: if sprite then sprite.thang else null
|
||||||
|
|
|
@ -113,6 +113,12 @@ _.extend LevelSessionSchema.properties,
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: 'javascript'
|
default: 'javascript'
|
||||||
|
|
||||||
|
playtime:
|
||||||
|
type: 'number'
|
||||||
|
title: 'Playtime'
|
||||||
|
default: 0
|
||||||
|
description: 'The total playtime on this session'
|
||||||
|
|
||||||
teamSpells:
|
teamSpells:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
|
@ -193,6 +199,11 @@ _.extend LevelSessionSchema.properties,
|
||||||
date: c.date
|
date: c.date
|
||||||
title: 'Date computed'
|
title: 'Date computed'
|
||||||
description: 'The date a match was computed.'
|
description: 'The date a match was computed.'
|
||||||
|
playtime:
|
||||||
|
title: 'Playtime so far'
|
||||||
|
description: 'The total seconds of playtime on this session when the match was computed.'
|
||||||
|
type: 'number'
|
||||||
|
|
||||||
metrics:
|
metrics:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
title: 'Metrics'
|
title: 'Metrics'
|
||||||
|
@ -217,6 +228,14 @@ _.extend LevelSessionSchema.properties,
|
||||||
title: 'Opponent User ID'
|
title: 'Opponent User ID'
|
||||||
description: 'The user ID of an opponent'
|
description: 'The user ID of an opponent'
|
||||||
type: ['object','string']
|
type: ['object','string']
|
||||||
|
name:
|
||||||
|
title: 'Opponent name'
|
||||||
|
description: 'The name of the opponent'
|
||||||
|
type: 'string'
|
||||||
|
totalScore:
|
||||||
|
title: 'Opponent total score'
|
||||||
|
description: 'The totalScore of a user when the match was computed'
|
||||||
|
type: 'number'
|
||||||
metrics:
|
metrics:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
properties:
|
properties:
|
||||||
|
|
|
@ -15,7 +15,10 @@ p.simulation-count
|
||||||
span(data-i18n="ladder.games_simulated_for") Games simulated for you:
|
span(data-i18n="ladder.games_simulated_for") Games simulated for you:
|
||||||
|
|
|
|
||||||
span#simulated-for-you= me.get('simulatedFor') || 0
|
span#simulated-for-you= me.get('simulatedFor') || 0
|
||||||
|
p.simulation-count
|
||||||
|
span(data-i18n="ladder.games_in_queue") Games currently in the queue:
|
||||||
|
|
|
||||||
|
span#games-in-queue= numberOfGamesInQueue || 0
|
||||||
table.table.table-bordered.table-condensed.table-hover
|
table.table.table-bordered.table-condensed.table-hover
|
||||||
tr
|
tr
|
||||||
th
|
th
|
||||||
|
|
|
@ -201,7 +201,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
x = d3.scale.linear().domain([-3000,6000]).range([0,width])
|
x = d3.scale.linear().domain([-3000,6000]).range([0,width])
|
||||||
|
|
||||||
data = d3.layout.histogram().bins(x.ticks(20))(histogramData)
|
data = d3.layout.histogram().bins(x.ticks(20))(histogramData)
|
||||||
y = d3.scale.linear().domain([0,d3.max(data, (d) -> d.y)]).range([height,0])
|
y = d3.scale.linear().domain([0,d3.max(data, (d) -> d.y)]).range([height,10])
|
||||||
|
|
||||||
#create the x axis
|
#create the x axis
|
||||||
xAxis = d3.svg.axis().scale(x).orient("bottom").ticks(5).outerTickSize(0)
|
xAxis = d3.svg.axis().scale(x).orient("bottom").ticks(5).outerTickSize(0)
|
||||||
|
@ -242,7 +242,11 @@ module.exports = class LadderTabView extends CocoView
|
||||||
if teamName.toLowerCase() is "humans" then rankClass = "rank-text humans-rank-text"
|
if teamName.toLowerCase() is "humans" then rankClass = "rank-text humans-rank-text"
|
||||||
|
|
||||||
message = "#{histogramData.length} players"
|
message = "#{histogramData.length} players"
|
||||||
if @leaderboards[teamName].session? then message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
if @leaderboards[teamName].session?
|
||||||
|
if @leaderboards[teamName].myRank <= histogramData.length
|
||||||
|
message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
||||||
|
else
|
||||||
|
message="Rank your session!"
|
||||||
svg.append("g")
|
svg.append("g")
|
||||||
.append("text")
|
.append("text")
|
||||||
.attr("class",rankClass)
|
.attr("class",rankClass)
|
||||||
|
|
|
@ -29,6 +29,7 @@ module.exports = class SimulateTabView extends CocoView
|
||||||
ctx = super()
|
ctx = super()
|
||||||
ctx.simulationStatus = @simulationStatus
|
ctx.simulationStatus = @simulationStatus
|
||||||
ctx.simulatorsLeaderboardData = @simulatorsLeaderboardData
|
ctx.simulatorsLeaderboardData = @simulatorsLeaderboardData
|
||||||
|
ctx.numberOfGamesInQueue = @simulatorsLeaderboardData.numberOfGamesInQueue
|
||||||
ctx._ = _
|
ctx._ = _
|
||||||
ctx
|
ctx
|
||||||
|
|
||||||
|
@ -44,6 +45,11 @@ module.exports = class SimulateTabView extends CocoView
|
||||||
|
|
||||||
@simulator.fetchAndSimulateTask()
|
@simulator.fetchAndSimulateTask()
|
||||||
|
|
||||||
|
refresh: ->
|
||||||
|
success = (numberOfGamesInQueue) ->
|
||||||
|
$("#games-in-queue").text numberOfGamesInQueue
|
||||||
|
$.ajax "/queue/messagesInQueueCount", {success}
|
||||||
|
|
||||||
updateSimulationStatus: (simulationStatus, sessions) ->
|
updateSimulationStatus: (simulationStatus, sessions) ->
|
||||||
@simulationStatus = simulationStatus
|
@simulationStatus = simulationStatus
|
||||||
try
|
try
|
||||||
|
@ -92,13 +98,17 @@ class SimulatorsLeaderboardData extends CocoClass
|
||||||
promises.push @topSimulators.fetch()
|
promises.push @topSimulators.fetch()
|
||||||
unless @me.get('anonymous')
|
unless @me.get('anonymous')
|
||||||
score = @me.get('simulatedBy') or 0
|
score = @me.get('simulatedBy') or 0
|
||||||
|
queueSuccess = (@numberOfGamesInQueue) =>
|
||||||
|
promises.push $.ajax "/queue/messagesInQueueCount", {success: queueSuccess}
|
||||||
@playersAbove = new SimulatorsLeaderboardCollection({order:1, scoreOffset: score, limit: 4})
|
@playersAbove = new SimulatorsLeaderboardCollection({order:1, scoreOffset: score, limit: 4})
|
||||||
promises.push @playersAbove.fetch()
|
promises.push @playersAbove.fetch()
|
||||||
if score
|
if score
|
||||||
@playersBelow = new SimulatorsLeaderboardCollection({order:-1, scoreOffset: score, limit: 4})
|
@playersBelow = new SimulatorsLeaderboardCollection({order:-1, scoreOffset: score, limit: 4})
|
||||||
promises.push @playersBelow.fetch()
|
promises.push @playersBelow.fetch()
|
||||||
success = (@myRank) =>
|
success = (@myRank) =>
|
||||||
|
|
||||||
promises.push $.ajax "/db/user/me/simulator_leaderboard_rank?scoreOffset=#{score}", {success}
|
promises.push $.ajax "/db/user/me/simulator_leaderboard_rank?scoreOffset=#{score}", {success}
|
||||||
|
|
||||||
@promise = $.when(promises...)
|
@promise = $.when(promises...)
|
||||||
@promise.then @onLoad
|
@promise.then @onLoad
|
||||||
@promise.fail @onFail
|
@promise.fail @onFail
|
||||||
|
@ -121,7 +131,7 @@ class SimulatorsLeaderboardData extends CocoClass
|
||||||
above = @playersAbove.models
|
above = @playersAbove.models
|
||||||
l = l.concat(above)
|
l = l.concat(above)
|
||||||
l.reverse()
|
l.reverse()
|
||||||
l.push @me
|
#l.push @me
|
||||||
l = l.concat(@playersBelow.models) if @playersBelow
|
l = l.concat(@playersBelow.models) if @playersBelow
|
||||||
if @myRank
|
if @myRank
|
||||||
startRank = @myRank - 4
|
startRank = @myRank - 4
|
||||||
|
|
|
@ -68,7 +68,7 @@ module.exports = class LadderView extends RootView
|
||||||
@showPlayModal(hash) if @sessions.loaded
|
@showPlayModal(hash) if @sessions.loaded
|
||||||
|
|
||||||
fetchSessionsAndRefreshViews: ->
|
fetchSessionsAndRefreshViews: ->
|
||||||
return if @destroyed or application.userIsIdle or @$el.find('#simulate.active').length or (new Date() - 2000 < @lastRefreshTime) or not @supermodel.finished()
|
return if @destroyed or application.userIsIdle or (new Date() - 2000 < @lastRefreshTime) or not @supermodel.finished()
|
||||||
@sessions.fetch({"success": @refreshViews})
|
@sessions.fetch({"success": @refreshViews})
|
||||||
|
|
||||||
refreshViews: =>
|
refreshViews: =>
|
||||||
|
@ -76,7 +76,7 @@ module.exports = class LadderView extends RootView
|
||||||
@lastRefreshTime = new Date()
|
@lastRefreshTime = new Date()
|
||||||
@ladderTab.refreshLadder()
|
@ladderTab.refreshLadder()
|
||||||
@myMatchesTab.refreshMatches()
|
@myMatchesTab.refreshMatches()
|
||||||
console.log "Refreshed sessions for ladder and matches."
|
@simulateTab.refresh()
|
||||||
|
|
||||||
onIdleChanged: (e) ->
|
onIdleChanged: (e) ->
|
||||||
@fetchSessionsAndRefreshViews() unless e.idle
|
@fetchSessionsAndRefreshViews() unless e.idle
|
||||||
|
|
|
@ -134,7 +134,9 @@ module.exports = class DebugView extends View
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
if @variableChain
|
if @variableChain
|
||||||
if @workerIsSimulating
|
if @variableChain.length is 2 and @variableChain[0] is "this"
|
||||||
|
@setTooltipKeyAndValue(@variableChain.join("."),@stringifyValue(@thang[@variableChain[1]],0))
|
||||||
|
else if @workerIsSimulating
|
||||||
@setTooltipText("World is simulating, please wait...")
|
@setTooltipText("World is simulating, please wait...")
|
||||||
else if @currentFrame is @lastFrameRequested and (cacheValue = @retrieveValueFromCache(@thang.id, @spell.name, @variableChain, @currentFrame))
|
else if @currentFrame is @lastFrameRequested and (cacheValue = @retrieveValueFromCache(@thang.id, @spell.name, @variableChain, @currentFrame))
|
||||||
@setTooltipKeyAndValue(@variableChain.join("."),cacheValue)
|
@setTooltipKeyAndValue(@variableChain.join("."),cacheValue)
|
||||||
|
@ -156,6 +158,39 @@ module.exports = class DebugView extends View
|
||||||
@notifyPropertyHovered()
|
@notifyPropertyHovered()
|
||||||
@updateMarker()
|
@updateMarker()
|
||||||
|
|
||||||
|
stringifyValue: (value, depth) ->
|
||||||
|
return value if not value or _.isString value
|
||||||
|
if _.isFunction value
|
||||||
|
return if depth is 2 then undefined else "<Function>"
|
||||||
|
return "<this #{value.id}>" if value is @thang and depth
|
||||||
|
if depth is 2
|
||||||
|
if value.constructor?.className is "Thang"
|
||||||
|
value = "<#{value.type or value.spriteName} - #{value.id}, #{if value.pos then value.pos.toString() else 'non-physical'}>"
|
||||||
|
else
|
||||||
|
value = value.toString()
|
||||||
|
return value
|
||||||
|
|
||||||
|
isArray = _.isArray value
|
||||||
|
isObject = _.isObject value
|
||||||
|
return value.toString() unless isArray or isObject
|
||||||
|
brackets = if isArray then ["[", "]"] else ["{", "}"]
|
||||||
|
size = _.size value
|
||||||
|
return brackets.join "" unless size
|
||||||
|
values = []
|
||||||
|
if isArray
|
||||||
|
for v in value
|
||||||
|
s = @stringifyValue(v, depth + 1)
|
||||||
|
values.push "" + s unless s is undefined
|
||||||
|
else
|
||||||
|
for key in value.apiProperties ? _.keys value
|
||||||
|
s = @stringifyValue(value[key], depth + 1)
|
||||||
|
values.push key + ": " + s unless s is undefined
|
||||||
|
sep = '\n' + (" " for i in [0 ... depth]).join('')
|
||||||
|
prefix = value.constructor?.className
|
||||||
|
prefix ?= "Array" if isArray
|
||||||
|
prefix ?= "Object" if isObject
|
||||||
|
prefix = if prefix then prefix + " " else ""
|
||||||
|
return "#{prefix}#{brackets[0]}#{sep} #{values.join(sep + ' ')}#{sep}#{brackets[1]}"
|
||||||
notifyPropertyHovered: =>
|
notifyPropertyHovered: =>
|
||||||
clearTimeout @hoveredPropertyTimeout if @hoveredPropertyTimeout
|
clearTimeout @hoveredPropertyTimeout if @hoveredPropertyTimeout
|
||||||
@hoveredPropertyTimeout = null
|
@hoveredPropertyTimeout = null
|
||||||
|
@ -163,6 +198,7 @@ module.exports = class DebugView extends View
|
||||||
@hoveredProperty = if @variableChain?.length is 2 then owner: @variableChain[0], property: @variableChain[1] else {}
|
@hoveredProperty = if @variableChain?.length is 2 then owner: @variableChain[0], property: @variableChain[1] else {}
|
||||||
unless _.isEqual oldHoveredProperty, @hoveredProperty
|
unless _.isEqual oldHoveredProperty, @hoveredProperty
|
||||||
Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty
|
Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty
|
||||||
|
|
||||||
updateMarker: ->
|
updateMarker: ->
|
||||||
if @marker
|
if @marker
|
||||||
@ace.getSession().removeMarker @marker
|
@ace.getSession().removeMarker @marker
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = class SpellView extends View
|
||||||
'coffeescript': 'ace/mode/coffee'
|
'coffeescript': 'ace/mode/coffee'
|
||||||
'clojure': 'ace/mode/clojure'
|
'clojure': 'ace/mode/clojure'
|
||||||
'lua': 'ace/mode/lua'
|
'lua': 'ace/mode/lua'
|
||||||
'python': 'ace/mode/lua'
|
'python': 'ace/mode/python'
|
||||||
|
|
||||||
keyBindings:
|
keyBindings:
|
||||||
'default': null
|
'default': null
|
||||||
|
|
|
@ -198,7 +198,8 @@ module.exports = class PlayLevelView extends View
|
||||||
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
|
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
|
||||||
continue if spellTeam is myTeam or not myTeam
|
continue if spellTeam is myTeam or not myTeam
|
||||||
opponentSpells = opponentSpells.concat spells
|
opponentSpells = opponentSpells.concat spells
|
||||||
|
if (not @session.get('teamSpells')) and @otherSession?.get('teamSpells')
|
||||||
|
@session.set('teamSpells',@otherSession.get('teamSpells'))
|
||||||
opponentCode = @otherSession?.get('transpiledCode') or {}
|
opponentCode = @otherSession?.get('transpiledCode') or {}
|
||||||
myCode = @session.get('code') or {}
|
myCode = @session.get('code') or {}
|
||||||
for spell in opponentSpells
|
for spell in opponentSpells
|
||||||
|
|
Loading…
Reference in a new issue