mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
commit
20a5ae1b8c
9 changed files with 51 additions and 48 deletions
|
@ -710,3 +710,4 @@
|
||||||
user_names: "User Names"
|
user_names: "User Names"
|
||||||
files: "Files"
|
files: "Files"
|
||||||
top_simulators: "Top Simulators"
|
top_simulators: "Top Simulators"
|
||||||
|
source_document: "Source Document"
|
|
@ -10,6 +10,8 @@
|
||||||
display: none
|
display: none
|
||||||
#docs-button
|
#docs-button
|
||||||
display: none
|
display: none
|
||||||
|
#gold-view
|
||||||
|
right: 1%
|
||||||
|
|
||||||
#control-bar-view
|
#control-bar-view
|
||||||
width: 100%
|
width: 100%
|
||||||
|
@ -41,7 +43,7 @@
|
||||||
margin: 0 auto
|
margin: 0 auto
|
||||||
|
|
||||||
canvas#surface
|
canvas#surface
|
||||||
background-color: #ddd
|
background-color: #333
|
||||||
max-height: 93%
|
max-height: 93%
|
||||||
max-height: -webkit-calc(100% - 60px)
|
max-height: -webkit-calc(100% - 60px)
|
||||||
max-height: calc(100% - 60px)
|
max-height: calc(100% - 60px)
|
||||||
|
|
|
@ -17,14 +17,11 @@ module.exports = class PatchModal extends ModalView
|
||||||
constructor: (@patch, @targetModel, options) ->
|
constructor: (@patch, @targetModel, options) ->
|
||||||
super(options)
|
super(options)
|
||||||
targetID = @patch.get('target').id
|
targetID = @patch.get('target').id
|
||||||
if false
|
if targetID is @targetModel.id
|
||||||
@originalSource = targetModel.clone(false)
|
@originalSource = @targetModel.clone(false)
|
||||||
@onOriginalLoaded()
|
|
||||||
else
|
else
|
||||||
@originalSource = new targetModel.constructor({_id:targetID})
|
@originalSource = new @targetModel.constructor({_id:targetID})
|
||||||
@originalSource.fetch()
|
@supermodel.loadModel @originalSource, 'source_document'
|
||||||
@listenToOnce @originalSource, 'sync', @onOriginalLoaded
|
|
||||||
@addResourceToLoad(@originalSource)
|
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
c = super()
|
c = super()
|
||||||
|
@ -35,7 +32,7 @@ module.exports = class PatchModal extends ModalView
|
||||||
c
|
c
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
return if @originalSource.loading
|
return unless @supermodel.finished()
|
||||||
headModel = null
|
headModel = null
|
||||||
if @targetModel.hasWriteAccess()
|
if @targetModel.hasWriteAccess()
|
||||||
headModel = @originalSource.clone(false)
|
headModel = @originalSource.clone(false)
|
||||||
|
|
|
@ -45,7 +45,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
checkFriends: ->
|
checkFriends: ->
|
||||||
return if @checked or (not window.FB) or (not window.gapi)
|
return if @checked or (not window.FB) or (not window.gapi)
|
||||||
@checked = true
|
@checked = true
|
||||||
|
|
||||||
# @addSomethingToLoad("facebook_status")
|
# @addSomethingToLoad("facebook_status")
|
||||||
|
|
||||||
@fbStatusRes = @supermodel.addSomethingResource("facebook_status", 0)
|
@fbStatusRes = @supermodel.addSomethingResource("facebook_status", 0)
|
||||||
|
@ -78,7 +78,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
@fbFriendRes.load()
|
@fbFriendRes.load()
|
||||||
|
|
||||||
FB.api '/me/friends', @onFacebookFriendsLoaded
|
FB.api '/me/friends', @onFacebookFriendsLoaded
|
||||||
|
|
||||||
onFacebookFriendsLoaded: (response) =>
|
onFacebookFriendsLoaded: (response) =>
|
||||||
@facebookData = response.data
|
@facebookData = response.data
|
||||||
@loadFacebookFriendSessions()
|
@loadFacebookFriendSessions()
|
||||||
|
@ -104,7 +104,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
||||||
friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture"
|
friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture"
|
||||||
@facebookFriendSessions = result
|
@facebookFriendSessions = result
|
||||||
|
|
||||||
# GOOGLE PLUS
|
# GOOGLE PLUS
|
||||||
|
|
||||||
onConnectGPlus: ->
|
onConnectGPlus: ->
|
||||||
|
@ -113,7 +113,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
application.gplusHandler.reauthorize()
|
application.gplusHandler.reauthorize()
|
||||||
|
|
||||||
onConnectedWithGPlus: -> location.reload() if @connecting
|
onConnectedWithGPlus: -> location.reload() if @connecting
|
||||||
|
|
||||||
gplusSessionStateLoaded: ->
|
gplusSessionStateLoaded: ->
|
||||||
if application.gplusHandler.loggedIn
|
if application.gplusHandler.loggedIn
|
||||||
#@addSomethingToLoad("gplus_friends")
|
#@addSomethingToLoad("gplus_friends")
|
||||||
|
@ -146,7 +146,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
||||||
friend.imageSource = friendsMap[friend.gplusID].image.url
|
friend.imageSource = friendsMap[friend.gplusID].image.url
|
||||||
@gplusFriendSessions = result
|
@gplusFriendSessions = result
|
||||||
|
|
||||||
# LADDER LOADING
|
# LADDER LOADING
|
||||||
|
|
||||||
refreshLadder: ->
|
refreshLadder: ->
|
||||||
|
@ -160,7 +160,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@$el.find('.histogram-display').each (i, el) =>
|
@$el.find('.histogram-display').each (i, el) =>
|
||||||
histogramWrapper = $(el)
|
histogramWrapper = $(el)
|
||||||
team = _.find @teams, name: histogramWrapper.data('team-name')
|
team = _.find @teams, name: histogramWrapper.data('team-name')
|
||||||
|
@ -168,8 +168,8 @@ module.exports = class LadderTabView extends CocoView
|
||||||
$.when(
|
$.when(
|
||||||
$.get("/db/level/#{@level.get('slug')}/histogram_data?team=#{team.name.toLowerCase()}", (data) -> histogramData = data)
|
$.get("/db/level/#{@level.get('slug')}/histogram_data?team=#{team.name.toLowerCase()}", (data) -> histogramData = data)
|
||||||
).then =>
|
).then =>
|
||||||
@generateHistogram(histogramWrapper, histogramData, team.name.toLowerCase())
|
@generateHistogram(histogramWrapper, histogramData, team.name.toLowerCase()) unless @destroyed
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
ctx = super()
|
ctx = super()
|
||||||
ctx.level = @level
|
ctx.level = @level
|
||||||
|
@ -186,7 +186,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
#renders twice, hack fix
|
#renders twice, hack fix
|
||||||
if $("#"+histogramElement.attr("id")).has("svg").length then return
|
if $("#"+histogramElement.attr("id")).has("svg").length then return
|
||||||
histogramData = histogramData.map (d) -> d*100
|
histogramData = histogramData.map (d) -> d*100
|
||||||
|
|
||||||
margin =
|
margin =
|
||||||
top: 20
|
top: 20
|
||||||
right: 20
|
right: 20
|
||||||
|
@ -195,17 +195,17 @@ module.exports = class LadderTabView extends CocoView
|
||||||
|
|
||||||
width = 300 - margin.left - margin.right
|
width = 300 - margin.left - margin.right
|
||||||
height = 125 - margin.top - margin.bottom
|
height = 125 - margin.top - margin.bottom
|
||||||
|
|
||||||
formatCount = d3.format(",.0")
|
formatCount = d3.format(",.0")
|
||||||
|
|
||||||
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,0])
|
||||||
|
|
||||||
#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)
|
||||||
|
|
||||||
svg = d3.select("#"+histogramElement.attr("id")).append("svg")
|
svg = d3.select("#"+histogramElement.attr("id")).append("svg")
|
||||||
.attr("width", width + margin.left + margin.right)
|
.attr("width", width + margin.left + margin.right)
|
||||||
.attr("height", height + margin.top + margin.bottom)
|
.attr("height", height + margin.top + margin.bottom)
|
||||||
|
@ -214,13 +214,13 @@ module.exports = class LadderTabView extends CocoView
|
||||||
barClass = "bar"
|
barClass = "bar"
|
||||||
if teamName.toLowerCase() is "ogres" then barClass = "ogres-bar"
|
if teamName.toLowerCase() is "ogres" then barClass = "ogres-bar"
|
||||||
if teamName.toLowerCase() is "humans" then barClass = "humans-bar"
|
if teamName.toLowerCase() is "humans" then barClass = "humans-bar"
|
||||||
|
|
||||||
bar = svg.selectAll(".bar")
|
bar = svg.selectAll(".bar")
|
||||||
.data(data)
|
.data(data)
|
||||||
.enter().append("g")
|
.enter().append("g")
|
||||||
.attr("class",barClass)
|
.attr("class",barClass)
|
||||||
.attr("transform", (d) -> "translate(#{x(d.x)},#{y(d.y)})")
|
.attr("transform", (d) -> "translate(#{x(d.x)},#{y(d.y)})")
|
||||||
|
|
||||||
bar.append("rect")
|
bar.append("rect")
|
||||||
.attr("x",1)
|
.attr("x",1)
|
||||||
.attr("width",width/20)
|
.attr("width",width/20)
|
||||||
|
@ -232,7 +232,7 @@ module.exports = class LadderTabView extends CocoView
|
||||||
.enter().append("g")
|
.enter().append("g")
|
||||||
.attr("class","specialbar")
|
.attr("class","specialbar")
|
||||||
.attr("transform", "translate(#{x(playerScore)},#{y(9001)})")
|
.attr("transform", "translate(#{x(playerScore)},#{y(9001)})")
|
||||||
|
|
||||||
scorebar.append("rect")
|
scorebar.append("rect")
|
||||||
.attr("x",1)
|
.attr("x",1)
|
||||||
.attr("width",3)
|
.attr("width",3)
|
||||||
|
@ -240,9 +240,9 @@ module.exports = class LadderTabView extends CocoView
|
||||||
rankClass = "rank-text"
|
rankClass = "rank-text"
|
||||||
if teamName.toLowerCase() is "ogres" then rankClass = "rank-text ogres-rank-text"
|
if teamName.toLowerCase() is "ogres" then rankClass = "rank-text ogres-rank-text"
|
||||||
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}/#{histogramData.length}"
|
if @leaderboards[teamName].session? then message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
||||||
svg.append("g")
|
svg.append("g")
|
||||||
.append("text")
|
.append("text")
|
||||||
.attr("class",rankClass)
|
.attr("class",rankClass)
|
||||||
|
@ -250,14 +250,14 @@ module.exports = class LadderTabView extends CocoView
|
||||||
.attr("text-anchor","end")
|
.attr("text-anchor","end")
|
||||||
.attr("x",width)
|
.attr("x",width)
|
||||||
.text(message)
|
.text(message)
|
||||||
|
|
||||||
#Translate the x-axis up
|
#Translate the x-axis up
|
||||||
svg.append("g")
|
svg.append("g")
|
||||||
.attr("class", "x axis")
|
.attr("class", "x axis")
|
||||||
.attr("transform","translate(0," + height + ")")
|
.attr("transform","translate(0," + height + ")")
|
||||||
.call(xAxis)
|
.call(xAxis)
|
||||||
|
|
||||||
|
|
||||||
consolidateFriends: ->
|
consolidateFriends: ->
|
||||||
allFriendSessions = (@facebookFriendSessions or []).concat(@gplusFriendSessions or [])
|
allFriendSessions = (@facebookFriendSessions or []).concat(@gplusFriendSessions or [])
|
||||||
sessions = _.uniq allFriendSessions, false, (session) -> session._id
|
sessions = _.uniq allFriendSessions, false, (session) -> session._id
|
||||||
|
@ -312,7 +312,7 @@ class LeaderboardData extends CocoClass
|
||||||
@trigger 'sync', @
|
@trigger 'sync', @
|
||||||
# TODO: cache user ids -> names mapping, and load them here as needed,
|
# TODO: cache user ids -> names mapping, and load them here as needed,
|
||||||
# and apply them to sessions. Fetching each and every time is too costly.
|
# and apply them to sessions. Fetching each and every time is too costly.
|
||||||
|
|
||||||
onFail: (resource, jqxhr) =>
|
onFail: (resource, jqxhr) =>
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
@trigger 'error', @, jqxhr
|
@trigger 'error', @, jqxhr
|
||||||
|
|
|
@ -35,7 +35,6 @@ module.exports = class ControlBarView extends View
|
||||||
@session = options.session
|
@session = options.session
|
||||||
@level = options.level
|
@level = options.level
|
||||||
@playableTeams = options.playableTeams
|
@playableTeams = options.playableTeams
|
||||||
@ladderGame = options.ladderGame
|
|
||||||
@spectateGame = options.spectateGame ? false
|
@spectateGame = options.spectateGame ? false
|
||||||
super options
|
super options
|
||||||
|
|
||||||
|
@ -55,13 +54,13 @@ module.exports = class ControlBarView extends View
|
||||||
super c
|
super c
|
||||||
c.worldName = @worldName
|
c.worldName = @worldName
|
||||||
c.multiplayerEnabled = @session.get('multiplayer')
|
c.multiplayerEnabled = @session.get('multiplayer')
|
||||||
c.ladderGame = @ladderGame
|
c.ladderGame = @level.get('type') is 'ladder'
|
||||||
c.spectateGame = @spectateGame
|
c.spectateGame = @spectateGame
|
||||||
c.homeLink = "/"
|
console.log "level type is", @level.get('type')
|
||||||
levelID = @level.get('slug')
|
if @level.get('type') in ['ladder', 'ladder-tutorial']
|
||||||
if levelID in ["brawlwood", "brawlwood-tutorial", "dungeon-arena", "dungeon-arena-tutorial"]
|
c.homeLink = '/play/ladder/' + @level.get('slug').replace /\-tutorial$/, ''
|
||||||
levelID = 'brawlwood' if levelID is 'brawlwood-tutorial'
|
else
|
||||||
c.homeLink = "/play/ladder/" + levelID
|
c.homeLink = '/'
|
||||||
c
|
c
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
|
|
|
@ -97,8 +97,12 @@ module.exports = class SpellView extends View
|
||||||
aceCommands.push c.name
|
aceCommands.push c.name
|
||||||
addCommand
|
addCommand
|
||||||
name: 'run-code'
|
name: 'run-code'
|
||||||
bindKey: {win: 'Shift-Enter|Ctrl-Enter|Ctrl-S', mac: 'Shift-Enter|Command-Enter|Ctrl-Enter|Command-S|Ctrl-S'}
|
bindKey: {win: 'Shift-Enter|Ctrl-Enter', mac: 'Shift-Enter|Command-Enter|Ctrl-Enter'}
|
||||||
exec: -> Backbone.Mediator.publish 'tome:manual-cast', {}
|
exec: -> Backbone.Mediator.publish 'tome:manual-cast', {}
|
||||||
|
addCommand
|
||||||
|
name: 'no-op'
|
||||||
|
bindKey: {win: 'Ctrl-S', mac: 'Command-S|Ctrl-S'}
|
||||||
|
exec: -> # just prevent page save call
|
||||||
addCommand
|
addCommand
|
||||||
name: 'toggle-playing'
|
name: 'toggle-playing'
|
||||||
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
||||||
|
|
|
@ -174,7 +174,7 @@ module.exports = class PlayLevelView extends View
|
||||||
@initSurface()
|
@initSurface()
|
||||||
@initGoalManager()
|
@initGoalManager()
|
||||||
@initScriptManager()
|
@initScriptManager()
|
||||||
@insertSubviews ladderGame: (@level.get('type') is "ladder")
|
@insertSubviews()
|
||||||
@initVolume()
|
@initVolume()
|
||||||
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
|
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
|
||||||
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
||||||
|
@ -238,15 +238,15 @@ module.exports = class PlayLevelView extends View
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
||||||
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
||||||
|
|
||||||
insertSubviews: (subviewOptions) ->
|
insertSubviews: ->
|
||||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, ladderGame: subviewOptions.ladderGame
|
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel
|
||||||
@insertSubView new PlaybackView {}
|
@insertSubView new PlaybackView {}
|
||||||
@insertSubView new GoalsView {}
|
@insertSubView new GoalsView {}
|
||||||
@insertSubView new GoldView {}
|
@insertSubView new GoldView {}
|
||||||
@insertSubView new HUDView {}
|
@insertSubView new HUDView {}
|
||||||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||||
worldName = utils.i18n @level.attributes, 'name'
|
worldName = utils.i18n @level.attributes, 'name'
|
||||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, ladderGame: subviewOptions.ladderGame}
|
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams}
|
||||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
||||||
|
|
||||||
afterInsert: ->
|
afterInsert: ->
|
||||||
|
|
|
@ -161,7 +161,7 @@ module.exports = class SpectateLevelView extends View
|
||||||
@initSurface()
|
@initSurface()
|
||||||
@initGoalManager()
|
@initGoalManager()
|
||||||
@initScriptManager()
|
@initScriptManager()
|
||||||
@insertSubviews ladderGame: @otherSession?
|
@insertSubviews()
|
||||||
@initVolume()
|
@initVolume()
|
||||||
|
|
||||||
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
||||||
|
@ -229,8 +229,8 @@ module.exports = class SpectateLevelView extends View
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
||||||
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
||||||
|
|
||||||
insertSubviews: (subviewOptions) ->
|
insertSubviews: ->
|
||||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, ladderGame: subviewOptions.ladderGame
|
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel
|
||||||
@insertSubView new PlaybackView {}
|
@insertSubView new PlaybackView {}
|
||||||
|
|
||||||
@insertSubView new GoldView {}
|
@insertSubView new GoldView {}
|
||||||
|
|
|
@ -108,7 +108,7 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
|
||||||
context =
|
context =
|
||||||
email_id: sendwithus.templates.ladder_update_email
|
email_id: sendwithus.templates.ladder_update_email
|
||||||
recipient:
|
recipient:
|
||||||
address: if DEBUGGING then 'nick@codecombat.com' else user.email
|
address: if DEBUGGING then 'nick@codecombat.com' else user.get('email')
|
||||||
name: name
|
name: name
|
||||||
email_data:
|
email_data:
|
||||||
name: name
|
name: name
|
||||||
|
|
Loading…
Reference in a new issue