mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Fixed some bugs with the new ladder view when you haven't played before.
This commit is contained in:
parent
5bb56ac818
commit
d3b6836a06
3 changed files with 41 additions and 37 deletions
|
@ -7,17 +7,17 @@
|
|||
div#columns.row
|
||||
for team in teams
|
||||
div.matches-column.col-md-6
|
||||
if team.matches.length
|
||||
table.table.table-bordered.table-condensed
|
||||
table.table.table-bordered.table-condensed
|
||||
|
||||
tr
|
||||
th(colspan=4, style="color: #{team.primaryColor}")
|
||||
span Your
|
||||
span
|
||||
span= team.name
|
||||
span
|
||||
span Matches
|
||||
tr
|
||||
th(colspan=4, style="color: #{team.primaryColor}")
|
||||
span Your
|
||||
span
|
||||
span= team.name
|
||||
span
|
||||
span Matches
|
||||
|
||||
if team.session
|
||||
button.btn.btn-sm.btn-warning.pull-right.rank-button(data-session-id=team.session.id)
|
||||
span.unavailable.hidden No New Code to Rank
|
||||
span.rank.hidden Rank My Game!
|
||||
|
@ -25,28 +25,29 @@ div#columns.row
|
|||
span.ranked.hidden Submitted for Ranking
|
||||
span.failed.hidden Failed to Rank
|
||||
|
||||
tr
|
||||
th Result
|
||||
th Opponent
|
||||
th When
|
||||
th
|
||||
for match in team.matches
|
||||
tr
|
||||
th Result
|
||||
th Opponent
|
||||
th When
|
||||
th
|
||||
for match in team.matches
|
||||
tr
|
||||
td.state-cell
|
||||
if match.state === 'win'
|
||||
span.win Win
|
||||
if match.state === 'loss'
|
||||
span.loss Loss
|
||||
if match.state === 'tie'
|
||||
span.tie Tie
|
||||
td.name-cell= match.opponentName || "Anonymous"
|
||||
td.time-cell= match.when
|
||||
td.battle-cell
|
||||
- var text = match.state === 'win' ? 'Watch your victory' : 'Defeat the ' + team.otherTeam
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{match.sessionID}")= text
|
||||
|
||||
else
|
||||
div.alert.alert-warning
|
||||
| No ranked matches played yet!
|
||||
| Play some competitors on the right and then come back to get your game ranked.
|
||||
td.state-cell
|
||||
if match.state === 'win'
|
||||
span.win Win
|
||||
if match.state === 'loss'
|
||||
span.loss Loss
|
||||
if match.state === 'tie'
|
||||
span.tie Tie
|
||||
td.name-cell= match.opponentName || "Anonymous"
|
||||
td.time-cell= match.when
|
||||
td.battle-cell
|
||||
- var text = match.state === 'win' ? 'Watch your victory' : 'Defeat the ' + team.otherTeam
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{match.sessionID}")= text
|
||||
|
||||
if !team.matches.length
|
||||
tr
|
||||
td(colspan=4).alert.alert-warning
|
||||
| No ranked matches for this team!
|
||||
| Play against some competitors and then come back here to get your game ranked.
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
for team in @teams
|
||||
team.session = (s for s in @sessions.models when s.get('team') is team.id)[0]
|
||||
team.readyToRank = @readyToRank(team.session)
|
||||
team.matches = (convertMatch(match) for match in team.session.get('matches') or [])
|
||||
team.matches = (convertMatch(match) for match in team.session?.get('matches') or [])
|
||||
team.matches.reverse()
|
||||
team.score = (team.session.get('totalScore') or 10).toFixed(2)
|
||||
team.score = (team.session?.get('totalScore') or 10).toFixed(2)
|
||||
|
||||
ctx
|
||||
|
||||
|
@ -77,8 +77,8 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
@setRankingButtonText button, if @readyToRank(session) then 'rank' else 'unavailable'
|
||||
|
||||
readyToRank: (session) ->
|
||||
c1 = session.get('code')
|
||||
c2 = session.get('submittedCode')
|
||||
c1 = session?.get('code')
|
||||
c2 = session?.get('submittedCode')
|
||||
c1 and not _.isEqual(c1, c2)
|
||||
|
||||
rankSession: (e) ->
|
||||
|
|
|
@ -2,6 +2,7 @@ View = require 'views/kinds/ModalView'
|
|||
template = require 'templates/play/ladder/play_modal'
|
||||
ThangType = require 'models/ThangType'
|
||||
{me} = require 'lib/auth'
|
||||
LeaderboardCollection = require 'collections/LeaderboardCollection'
|
||||
|
||||
module.exports = class LadderPlayModal extends View
|
||||
id: "ladder-play-modal"
|
||||
|
@ -19,7 +20,7 @@ module.exports = class LadderPlayModal extends View
|
|||
# PART 1: Load challengers from the db unless some are in the matches
|
||||
|
||||
startLoadingChallengersMaybe: ->
|
||||
matches = @session.get('matches')
|
||||
matches = @session?.get('matches')
|
||||
if matches?.length then @loadNames() else @loadChallengers()
|
||||
|
||||
loadChallengers: ->
|
||||
|
@ -126,8 +127,10 @@ class ChallengersData
|
|||
@hardPlayer = new LeaderboardCollection(@level, {order:-1, scoreOffset: score + 5, limit: 1, team: @otherTeam})
|
||||
@hardPlayer.fetch()
|
||||
@hardPlayer.once 'sync', @challengerLoaded, @
|
||||
console.log 'fetching challengers yes'
|
||||
|
||||
challengerLoaded: ->
|
||||
console.log 'challenger loaded'
|
||||
if @allLoaded()
|
||||
@loaded = true
|
||||
@trigger 'sync'
|
||||
|
|
Loading…
Reference in a new issue