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