mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Trimmed down the ladder view for now.
This commit is contained in:
parent
ccbb521b59
commit
32337df156
2 changed files with 31 additions and 29 deletions
|
@ -20,12 +20,12 @@ block content
|
||||||
table.table
|
table.table
|
||||||
for session in team.leaderboard.topPlayers.models
|
for session in team.leaderboard.topPlayers.models
|
||||||
tr= session.get('creatorName')
|
tr= session.get('creatorName')
|
||||||
.challengers
|
//.challengers
|
||||||
h4 Challengers
|
// h4 Challengers
|
||||||
|
//
|
||||||
if team.easyChallenger
|
// if team.easyChallenger
|
||||||
div.challenger-select
|
// div.challenger-select
|
||||||
| Easy challenger:
|
// | Easy challenger:
|
||||||
button
|
// button
|
||||||
a(href=link+'?team='+team.id+'&opponent='+team.easyChallenger.id)
|
// a(href=link+'?team='+team.id+'&opponent='+team.easyChallenger.id)
|
||||||
//TODO: finish once the scoring system is finished
|
// TODO: finish once the scoring system is finished
|
|
@ -33,15 +33,15 @@ module.exports = class LadderView extends RootView
|
||||||
@level.fetch()
|
@level.fetch()
|
||||||
@level.once 'sync', @onLevelLoaded, @
|
@level.once 'sync', @onLevelLoaded, @
|
||||||
|
|
||||||
@sessions = new LevelSessionsCollection(levelID)
|
# @sessions = new LevelSessionsCollection(levelID)
|
||||||
@sessions.fetch({})
|
# @sessions.fetch({})
|
||||||
@sessions.once 'sync', @onMySessionsLoaded, @
|
# @sessions.once 'sync', @onMySessionsLoaded, @
|
||||||
|
|
||||||
onLevelLoaded: -> @startLoadingPhaseTwoMaybe()
|
onLevelLoaded: -> @startLoadingPhaseTwoMaybe()
|
||||||
onMySessionsLoaded: -> @startLoadingPhaseTwoMaybe()
|
onMySessionsLoaded: -> @startLoadingPhaseTwoMaybe()
|
||||||
|
|
||||||
startLoadingPhaseTwoMaybe: ->
|
startLoadingPhaseTwoMaybe: ->
|
||||||
return unless @level.loaded and @sessions.loaded
|
return unless @level.loaded # and @sessions.loaded
|
||||||
@loadPhaseTwo()
|
@loadPhaseTwo()
|
||||||
|
|
||||||
loadPhaseTwo: ->
|
loadPhaseTwo: ->
|
||||||
|
@ -55,17 +55,18 @@ module.exports = class LadderView extends RootView
|
||||||
@leaderboards = {}
|
@leaderboards = {}
|
||||||
@challengers = {}
|
@challengers = {}
|
||||||
for team in teams
|
for team in teams
|
||||||
teamSession = _.find @sessions.models, (session) -> session.get('team') is team
|
# teamSession = _.find @sessions.models, (session) -> session.get('team') is team
|
||||||
|
teamSession = null
|
||||||
@leaderboards[team] = new LeaderboardData(@level, team, teamSession)
|
@leaderboards[team] = new LeaderboardData(@level, team, teamSession)
|
||||||
@leaderboards[team].once 'sync', @onLeaderboardLoaded, @
|
@leaderboards[team].once 'sync', @onLeaderboardLoaded, @
|
||||||
@challengers[team] = new ChallengersData(@level, team, teamSession)
|
# @challengers[team] = new ChallengersData(@level, team, teamSession)
|
||||||
@challengers[team].once 'sync', @onChallengersLoaded, @
|
# @challengers[team].once 'sync', @onChallengersLoaded, @
|
||||||
|
|
||||||
onChallengersLoaded: -> @renderMaybe()
|
onChallengersLoaded: -> @renderMaybe()
|
||||||
onLeaderboardLoaded: -> @renderMaybe()
|
onLeaderboardLoaded: -> @renderMaybe()
|
||||||
|
|
||||||
renderMaybe: ->
|
renderMaybe: ->
|
||||||
loaders = _.values(@leaderboards).concat(_.values(@challengers))
|
loaders = _.values(@leaderboards) # .concat(_.values(@challengers))
|
||||||
return unless _.every loaders, (loader) -> loader.loaded
|
return unless _.every loaders, (loader) -> loader.loaded
|
||||||
@startsLoading = false
|
@startsLoading = false
|
||||||
@render()
|
@render()
|
||||||
|
@ -82,9 +83,9 @@ module.exports = class LadderView extends RootView
|
||||||
id: team
|
id: team
|
||||||
name: _.string.titleize(team)
|
name: _.string.titleize(team)
|
||||||
leaderboard: @leaderboards[team]
|
leaderboard: @leaderboards[team]
|
||||||
easyChallenger: @challengers[team].easyPlayer.models[0]
|
# easyChallenger: @challengers[team].easyPlayer.models[0]
|
||||||
mediumChallenger: @challengers[team].mediumPlayer.models[0]
|
# mediumChallenger: @challengers[team].mediumPlayer.models[0]
|
||||||
hardChallenger: @challengers[team].hardPlayer.models[0]
|
# hardChallenger: @challengers[team].hardPlayer.models[0]
|
||||||
})
|
})
|
||||||
ctx
|
ctx
|
||||||
|
|
||||||
|
@ -94,23 +95,24 @@ module.exports = class LadderView extends RootView
|
||||||
|
|
||||||
class LeaderboardData
|
class LeaderboardData
|
||||||
constructor: (@level, @team, @session) ->
|
constructor: (@level, @team, @session) ->
|
||||||
|
console.log 'creating leaderboard data', @level, @team, @session
|
||||||
_.extend @, Backbone.Events
|
_.extend @, Backbone.Events
|
||||||
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: if @session then 10 else 20})
|
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: if @session then 10 else 20})
|
||||||
@topPlayers.fetch()
|
@topPlayers.fetch()
|
||||||
@topPlayers.once 'sync', @leaderboardPartLoaded, @
|
@topPlayers.once 'sync', @leaderboardPartLoaded, @
|
||||||
|
|
||||||
if @session
|
# if @session
|
||||||
score = @session.get('score') or 25
|
# score = @session.get('score') or 25
|
||||||
@playersAbove = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 4, team: @team})
|
# @playersAbove = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 4, team: @team})
|
||||||
@playersAbove.fetch()
|
# @playersAbove.fetch()
|
||||||
@playersAbove.once 'sync', @leaderboardPartLoaded, @
|
# @playersAbove.once 'sync', @leaderboardPartLoaded, @
|
||||||
@playersBelow = new LeaderboardCollection(@level, {order:-1, scoreOffset: score, limit: 4, team: @team})
|
# @playersBelow = new LeaderboardCollection(@level, {order:-1, scoreOffset: score, limit: 4, team: @team})
|
||||||
@playersBelow.fetch()
|
# @playersBelow.fetch()
|
||||||
@playersBelow.once 'sync', @leaderboardPartLoaded, @
|
# @playersBelow.once 'sync', @leaderboardPartLoaded, @
|
||||||
|
|
||||||
leaderboardPartLoaded: ->
|
leaderboardPartLoaded: ->
|
||||||
if @session
|
if @session
|
||||||
if @topPlayers.loaded and @playersAbove.loaded and @playersBelow.loaded
|
if @topPlayers.loaded # and @playersAbove.loaded and @playersBelow.loaded
|
||||||
@loaded = true
|
@loaded = true
|
||||||
@trigger 'sync'
|
@trigger 'sync'
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue