mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-11 08:11:21 -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
|
||||
sprite?.selected = true
|
||||
@selectedSprite = sprite
|
||||
alive = not (sprite?.thang.health < 0)
|
||||
alive = sprite and not (sprite.thang.health < 0)
|
||||
|
||||
Backbone.Mediator.publish 'surface:sprite-selected',
|
||||
thang: if sprite then sprite.thang else null
|
||||
|
|
|
@ -113,6 +113,12 @@ _.extend LevelSessionSchema.properties,
|
|||
type: 'string'
|
||||
default: 'javascript'
|
||||
|
||||
playtime:
|
||||
type: 'number'
|
||||
title: 'Playtime'
|
||||
default: 0
|
||||
description: 'The total playtime on this session'
|
||||
|
||||
teamSpells:
|
||||
type: 'object'
|
||||
additionalProperties:
|
||||
|
@ -193,6 +199,11 @@ _.extend LevelSessionSchema.properties,
|
|||
date: c.date
|
||||
title: 'Date 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:
|
||||
type: 'object'
|
||||
title: 'Metrics'
|
||||
|
@ -217,6 +228,14 @@ _.extend LevelSessionSchema.properties,
|
|||
title: 'Opponent User ID'
|
||||
description: 'The user ID of an opponent'
|
||||
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:
|
||||
type: 'object'
|
||||
properties:
|
||||
|
|
|
@ -15,7 +15,10 @@ p.simulation-count
|
|||
span(data-i18n="ladder.games_simulated_for") Games simulated for you:
|
||||
|
|
||||
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
|
||||
tr
|
||||
th
|
||||
|
|
|
@ -201,7 +201,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
x = d3.scale.linear().domain([-3000,6000]).range([0,width])
|
||||
|
||||
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
|
||||
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"
|
||||
|
||||
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")
|
||||
.append("text")
|
||||
.attr("class",rankClass)
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports = class SimulateTabView extends CocoView
|
|||
ctx = super()
|
||||
ctx.simulationStatus = @simulationStatus
|
||||
ctx.simulatorsLeaderboardData = @simulatorsLeaderboardData
|
||||
ctx.numberOfGamesInQueue = @simulatorsLeaderboardData.numberOfGamesInQueue
|
||||
ctx._ = _
|
||||
ctx
|
||||
|
||||
|
@ -44,6 +45,11 @@ module.exports = class SimulateTabView extends CocoView
|
|||
|
||||
@simulator.fetchAndSimulateTask()
|
||||
|
||||
refresh: ->
|
||||
success = (numberOfGamesInQueue) ->
|
||||
$("#games-in-queue").text numberOfGamesInQueue
|
||||
$.ajax "/queue/messagesInQueueCount", {success}
|
||||
|
||||
updateSimulationStatus: (simulationStatus, sessions) ->
|
||||
@simulationStatus = simulationStatus
|
||||
try
|
||||
|
@ -92,13 +98,17 @@ class SimulatorsLeaderboardData extends CocoClass
|
|||
promises.push @topSimulators.fetch()
|
||||
unless @me.get('anonymous')
|
||||
score = @me.get('simulatedBy') or 0
|
||||
queueSuccess = (@numberOfGamesInQueue) =>
|
||||
promises.push $.ajax "/queue/messagesInQueueCount", {success: queueSuccess}
|
||||
@playersAbove = new SimulatorsLeaderboardCollection({order:1, scoreOffset: score, limit: 4})
|
||||
promises.push @playersAbove.fetch()
|
||||
if score
|
||||
@playersBelow = new SimulatorsLeaderboardCollection({order:-1, scoreOffset: score, limit: 4})
|
||||
promises.push @playersBelow.fetch()
|
||||
success = (@myRank) =>
|
||||
|
||||
promises.push $.ajax "/db/user/me/simulator_leaderboard_rank?scoreOffset=#{score}", {success}
|
||||
|
||||
@promise = $.when(promises...)
|
||||
@promise.then @onLoad
|
||||
@promise.fail @onFail
|
||||
|
@ -121,7 +131,7 @@ class SimulatorsLeaderboardData extends CocoClass
|
|||
above = @playersAbove.models
|
||||
l = l.concat(above)
|
||||
l.reverse()
|
||||
l.push @me
|
||||
#l.push @me
|
||||
l = l.concat(@playersBelow.models) if @playersBelow
|
||||
if @myRank
|
||||
startRank = @myRank - 4
|
||||
|
|
|
@ -68,7 +68,7 @@ module.exports = class LadderView extends RootView
|
|||
@showPlayModal(hash) if @sessions.loaded
|
||||
|
||||
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})
|
||||
|
||||
refreshViews: =>
|
||||
|
@ -76,7 +76,7 @@ module.exports = class LadderView extends RootView
|
|||
@lastRefreshTime = new Date()
|
||||
@ladderTab.refreshLadder()
|
||||
@myMatchesTab.refreshMatches()
|
||||
console.log "Refreshed sessions for ladder and matches."
|
||||
@simulateTab.refresh()
|
||||
|
||||
onIdleChanged: (e) ->
|
||||
@fetchSessionsAndRefreshViews() unless e.idle
|
||||
|
|
|
@ -134,7 +134,9 @@ module.exports = class DebugView extends View
|
|||
|
||||
update: ->
|
||||
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...")
|
||||
else if @currentFrame is @lastFrameRequested and (cacheValue = @retrieveValueFromCache(@thang.id, @spell.name, @variableChain, @currentFrame))
|
||||
@setTooltipKeyAndValue(@variableChain.join("."),cacheValue)
|
||||
|
@ -156,6 +158,39 @@ module.exports = class DebugView extends View
|
|||
@notifyPropertyHovered()
|
||||
@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: =>
|
||||
clearTimeout @hoveredPropertyTimeout if @hoveredPropertyTimeout
|
||||
@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 {}
|
||||
unless _.isEqual oldHoveredProperty, @hoveredProperty
|
||||
Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty
|
||||
|
||||
updateMarker: ->
|
||||
if @marker
|
||||
@ace.getSession().removeMarker @marker
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = class SpellView extends View
|
|||
'coffeescript': 'ace/mode/coffee'
|
||||
'clojure': 'ace/mode/clojure'
|
||||
'lua': 'ace/mode/lua'
|
||||
'python': 'ace/mode/lua'
|
||||
'python': 'ace/mode/python'
|
||||
|
||||
keyBindings:
|
||||
'default': null
|
||||
|
|
|
@ -198,7 +198,8 @@ module.exports = class PlayLevelView extends View
|
|||
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
|
||||
continue if spellTeam is myTeam or not myTeam
|
||||
opponentSpells = opponentSpells.concat spells
|
||||
|
||||
if (not @session.get('teamSpells')) and @otherSession?.get('teamSpells')
|
||||
@session.set('teamSpells',@otherSession.get('teamSpells'))
|
||||
opponentCode = @otherSession?.get('transpiledCode') or {}
|
||||
myCode = @session.get('code') or {}
|
||||
for spell in opponentSpells
|
||||
|
|
Loading…
Reference in a new issue