From 7811bda6c32330cab41e6f1cee3933da1325da9e Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 16 May 2014 08:55:59 -0700 Subject: [PATCH 1/9] Use ace/mdoe/python for Python instead of ace/mode/lua. --- app/views/play/level/tome/spell_view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index 92bb0a8cd..e45869154 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -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 From 206d63231e0c87f22a0295b655e1a75de132c0d0 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 09:47:15 -0700 Subject: [PATCH 2/9] Fixed teamSpells instantiation --- app/views/play/level_view.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index 46b6804e0..8d45ddd10 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -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 From c1052d8d7e40c5d7a0b46b4c3b1cfb4520638f04 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 16 May 2014 10:03:45 -0700 Subject: [PATCH 3/9] Fixed bug with trying to play selection sound for nonexistent sprites. --- app/lib/surface/SpriteBoss.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/surface/SpriteBoss.coffee b/app/lib/surface/SpriteBoss.coffee index 1d174b46b..b23c37d03 100644 --- a/app/lib/surface/SpriteBoss.coffee +++ b/app/lib/surface/SpriteBoss.coffee @@ -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 From 60342cc40e93604091d1a0b5103bdba3dfb425a4 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 10:19:34 -0700 Subject: [PATCH 4/9] Hover debugger optimization for "this" --- .../play/level/tome/spell_debug_view.coffee | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/app/views/play/level/tome/spell_debug_view.coffee b/app/views/play/level/tome/spell_debug_view.coffee index dddd362fc..761e3e480 100644 --- a/app/views/play/level/tome/spell_debug_view.coffee +++ b/app/views/play/level/tome/spell_debug_view.coffee @@ -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) @@ -155,7 +157,40 @@ module.exports = class DebugView extends View else @notifyPropertyHovered() @updateMarker() + + stringifyValue: (value, depth) -> + return value if not value or _.isString value + if _.isFunction value + return if depth is 2 then undefined else "" + return "" 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 From 934c8537898d47183207879d266731c87acaafa9 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 13:16:35 -0700 Subject: [PATCH 5/9] Live simulation count and fixed double simulator leaderboard session --- app/templates/play/ladder/simulate_tab.jade | 5 ++++- app/views/play/ladder/simulate_tab.coffee | 12 +++++++++++- app/views/play/ladder_view.coffee | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/templates/play/ladder/simulate_tab.jade b/app/templates/play/ladder/simulate_tab.jade index e590c8c4c..fe266c6d9 100644 --- a/app/templates/play/ladder/simulate_tab.jade +++ b/app/templates/play/ladder/simulate_tab.jade @@ -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 diff --git a/app/views/play/ladder/simulate_tab.coffee b/app/views/play/ladder/simulate_tab.coffee index cb7d7dac0..58e559f6d 100644 --- a/app/views/play/ladder/simulate_tab.coffee +++ b/app/views/play/ladder/simulate_tab.coffee @@ -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 diff --git a/app/views/play/ladder_view.coffee b/app/views/play/ladder_view.coffee index 2a65d44c2..26038ea81 100644 --- a/app/views/play/ladder_view.coffee +++ b/app/views/play/ladder_view.coffee @@ -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 From bd1261802d0766fe1822d7eb52023f8fa3718caa Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 13:27:42 -0700 Subject: [PATCH 6/9] Fix rank for unranked sessions on ladder histogram --- app/views/play/ladder/ladder_tab.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/play/ladder/ladder_tab.coffee b/app/views/play/ladder/ladder_tab.coffee index c1213e541..6e12172d3 100644 --- a/app/views/play/ladder/ladder_tab.coffee +++ b/app/views/play/ladder/ladder_tab.coffee @@ -242,7 +242,8 @@ 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? and @leaderboards[teamName].myRank <= histogramData.length + message="##{@leaderboards[teamName].myRank} of #{histogramData.length}" svg.append("g") .append("text") .attr("class",rankClass) From ab1b0cac42f663d469bf23dd04713c693dc709ce Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 13:30:55 -0700 Subject: [PATCH 7/9] Added "Rank your session" message --- app/views/play/ladder/ladder_tab.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/play/ladder/ladder_tab.coffee b/app/views/play/ladder/ladder_tab.coffee index 6e12172d3..cbdd50da7 100644 --- a/app/views/play/ladder/ladder_tab.coffee +++ b/app/views/play/ladder/ladder_tab.coffee @@ -242,8 +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? and @leaderboards[teamName].myRank <= histogramData.length - 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) From 21ccaa2d8a2109ccb540bfffc1659a9ab3f01918 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 13:33:41 -0700 Subject: [PATCH 8/9] Adjust histogram height downwards Make room for ranking text --- app/views/play/ladder/ladder_tab.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/play/ladder/ladder_tab.coffee b/app/views/play/ladder/ladder_tab.coffee index cbdd50da7..af3c82ffb 100644 --- a/app/views/play/ladder/ladder_tab.coffee +++ b/app/views/play/ladder/ladder_tab.coffee @@ -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) From 2e36a3352e7a9558528fb5f6cb5a9d3c8eee652e Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 16 May 2014 14:13:59 -0700 Subject: [PATCH 9/9] Modified level session schema to log playtime, renormalize score and name in matches --- app/schemas/models/level_session.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/schemas/models/level_session.coffee b/app/schemas/models/level_session.coffee index c41c9a69a..d2a06a63b 100644 --- a/app/schemas/models/level_session.coffee +++ b/app/schemas/models/level_session.coffee @@ -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: