mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-14 05:55:00 -04:00
Tweaks for ladder views.
This commit is contained in:
parent
284576521f
commit
97b6094fe8
6 changed files with 46 additions and 33 deletions
app
styles/play
templates/play
views/play
|
@ -4,7 +4,12 @@
|
|||
|
||||
.play-button
|
||||
margin-bottom: 10px
|
||||
background-image: none
|
||||
|
||||
.intro-button
|
||||
width: 45%
|
||||
margin: 0 2.5%
|
||||
|
||||
#simulation-status-text
|
||||
display: inline
|
||||
margin-left: 10px
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
margin-top: 15px
|
||||
|
||||
#competitors-column .well
|
||||
font-size: 16px
|
||||
font-weight: bold
|
||||
padding: 7px
|
||||
font-size: 18px
|
||||
padding: 7px
|
||||
|
|
|
@ -19,6 +19,7 @@ block content
|
|||
span= team.name
|
||||
|
||||
table.table.table-bordered.table-condensed.table-hover
|
||||
//(style="background-color: #{team.bgColor}")
|
||||
tr
|
||||
th(colspan=3, style="color: #{team.primaryColor}")
|
||||
span= team.name
|
||||
|
@ -34,9 +35,9 @@ block content
|
|||
td= session.get('creatorName') || "Anonymous"
|
||||
td
|
||||
if(!myRow)
|
||||
a(href="/play/level/#{level.get('slug') || level.id}/?team=#{team.otherTeam}&opponent=#{session.id}") Compete!
|
||||
a(href="/play/level/#{level.get('slug') || level.id}/?team=#{team.otherTeam}&opponent=#{session.id}") Battle as #{team.otherTeam}!
|
||||
else
|
||||
a(href="/play/ladder/#{levelID}/team/#{team.id}") View details
|
||||
a(href="/play/ladder/#{levelID}/team/#{team.id}") View your #{team.id} matches.
|
||||
|
||||
unless me.attributes.anonymous
|
||||
hr
|
||||
|
|
|
@ -11,7 +11,7 @@ block content
|
|||
p
|
||||
| In this level, you play against everyone who has ever written strategies for the opposing forces.
|
||||
| Choose from the suggested players on the right, playing as many and as long as you like,
|
||||
| and when you're ready to test your grand strategy against the whole ladder, return and click the rank button.
|
||||
| and when you are ready to test your grand strategy against the whole ladder, return and click the rank button.
|
||||
|
||||
p
|
||||
| After your first submission, your code will also continuously run against other players as they rank themselves.
|
||||
|
@ -30,6 +30,10 @@ block content
|
|||
|
||||
if matches.length
|
||||
table.table.table-bordered.table-condensed
|
||||
tr
|
||||
th Result
|
||||
th Opponent
|
||||
th When
|
||||
for match in matches
|
||||
tr
|
||||
td.state-cell
|
||||
|
@ -42,7 +46,8 @@ block content
|
|||
td.name-cell= match.opponentName || "Anonymous"
|
||||
td.time-cell= match.when
|
||||
td.battle-cell
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{match.sessionID}") Battle!
|
||||
- var text = match.state === 'win' ? 'Watch your victory' : 'Defeat the ' + otherTeamID
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{match.sessionID}")= text
|
||||
|
||||
else
|
||||
div.alert.alert-warning
|
||||
|
@ -61,7 +66,7 @@ block content
|
|||
span :
|
||||
div.col-md-10
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}")
|
||||
span.warmup Play vs Default
|
||||
span.warmup Play #{teamID} vs Default #{otherTeamID}
|
||||
|
||||
if challengers.easy
|
||||
.well
|
||||
|
@ -71,8 +76,9 @@ block content
|
|||
span :
|
||||
div.col-md-10
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.easy.sessionID}")
|
||||
span Play vs
|
||||
span= challengers.easy.opponentName
|
||||
span Play #{teamID} vs
|
||||
strong= challengers.easy.opponentName
|
||||
span #{otherTeamID}
|
||||
|
||||
if challengers.medium
|
||||
.well
|
||||
|
@ -82,8 +88,9 @@ block content
|
|||
span :
|
||||
div.col-md-10
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.medium.sessionID}")
|
||||
span Play vs
|
||||
span= challengers.medium.opponentName
|
||||
span Play #{teamID} vs
|
||||
strong= challengers.medium.opponentName
|
||||
span #{otherTeamID}
|
||||
|
||||
if challengers.hard
|
||||
.well
|
||||
|
@ -93,5 +100,6 @@ block content
|
|||
span :
|
||||
div.col-md-10
|
||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.hard.sessionID}")
|
||||
span Play vs
|
||||
span= challengers.hard.opponentName
|
||||
span Play #{teamID} vs
|
||||
strong= challengers.hard.opponentName
|
||||
span #{otherTeamID}
|
||||
|
|
|
@ -15,6 +15,7 @@ module.exports = class LadderTeamView extends RootView
|
|||
|
||||
constructor: (options, @levelID, @team) ->
|
||||
super(options)
|
||||
@otherTeam = if team is 'ogres' then 'humans' else 'ogres'
|
||||
@level = new Level(_id:@levelID)
|
||||
@level.fetch()
|
||||
@level.once 'sync', @onLevelLoaded, @
|
||||
|
@ -36,7 +37,7 @@ module.exports = class LadderTeamView extends RootView
|
|||
if matches?.length then @loadNames() else @loadChallengers()
|
||||
|
||||
loadChallengers: ->
|
||||
@challengers = new ChallengersData(@level, @team, @session)
|
||||
@challengers = new ChallengersData(@level, @team, @otherTeam, @session)
|
||||
@challengers.on 'sync', @loadNames, @
|
||||
|
||||
# PART 3: Loading the names of the other users
|
||||
|
@ -70,6 +71,7 @@ module.exports = class LadderTeamView extends RootView
|
|||
ctx.levelID = @levelID
|
||||
ctx.teamName = _.string.titleize @team
|
||||
ctx.teamID = @team
|
||||
ctx.otherTeamID = @otherTeam
|
||||
ctx.challengers = if not @startsLoading then @getChallengers() else {}
|
||||
ctx.readyToRank = @readyToRank()
|
||||
|
||||
|
@ -166,17 +168,16 @@ module.exports = class LadderTeamView extends RootView
|
|||
rankButton.toggleClass 'disabled', spanClass isnt 'rank'
|
||||
|
||||
class ChallengersData
|
||||
constructor: (@level, @team, @session) ->
|
||||
constructor: (@level, @team, @otherTeam, @session) ->
|
||||
_.extend @, Backbone.Events
|
||||
score = @session?.get('totalScore') or 25
|
||||
otherTeam = if @team is 'ogres' then 'humans' else 'ogres'
|
||||
@easyPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score - 5, limit: 1, team: otherTeam})
|
||||
@easyPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score - 5, limit: 1, team: @otherTeam})
|
||||
@easyPlayer.fetch()
|
||||
@easyPlayer.once 'sync', @challengerLoaded, @
|
||||
@mediumPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 1, team: otherTeam})
|
||||
@mediumPlayer = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 1, team: @otherTeam})
|
||||
@mediumPlayer.fetch()
|
||||
@mediumPlayer.once 'sync', @challengerLoaded, @
|
||||
@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.once 'sync', @challengerLoaded, @
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ HIGHEST_SCORE = 1000000
|
|||
class LevelSessionsCollection extends CocoCollection
|
||||
url: ''
|
||||
model: LevelSession
|
||||
|
||||
|
||||
constructor: (levelID) ->
|
||||
super()
|
||||
@url = "/db/level/#{levelID}/all_sessions"
|
||||
|
@ -56,7 +56,7 @@ module.exports = class LadderView extends RootView
|
|||
@simulationStatus += "..."
|
||||
catch e
|
||||
console.log "There was a problem with the named simulation status: #{e}"
|
||||
$("#simulationStatusText").text @simulationStatus
|
||||
$("#simulation-status-text").text @simulationStatus
|
||||
|
||||
|
||||
constructor: (options, @levelID) ->
|
||||
|
@ -66,7 +66,7 @@ module.exports = class LadderView extends RootView
|
|||
@level.once 'sync', @onLevelLoaded, @
|
||||
@simulator = new Simulator()
|
||||
@simulator.on 'statusUpdate', @updateSimulationStatus, @
|
||||
|
||||
|
||||
# @sessions = new LevelSessionsCollection(levelID)
|
||||
# @sessions.fetch({})
|
||||
# @sessions.once 'sync', @onMySessionsLoaded, @
|
||||
|
@ -78,7 +78,7 @@ module.exports = class LadderView extends RootView
|
|||
startLoadingPhaseTwoMaybe: ->
|
||||
return unless @level.loaded # and @sessions.loaded
|
||||
@loadPhaseTwo()
|
||||
|
||||
|
||||
loadPhaseTwo: ->
|
||||
alliedSystem = _.find @level.get('systems'), (value) -> value.config?.teams?
|
||||
teams = []
|
||||
|
@ -87,7 +87,7 @@ module.exports = class LadderView extends RootView
|
|||
teams.push teamName
|
||||
@teams = teams
|
||||
@teamConfigs = alliedSystem.config.teams
|
||||
|
||||
|
||||
@leaderboards = {}
|
||||
@challengers = {}
|
||||
for team in teams
|
||||
|
@ -96,7 +96,7 @@ module.exports = class LadderView extends RootView
|
|||
console.log "Team session: #{JSON.stringify teamSession}"
|
||||
@leaderboards[team] = new LeaderboardData(@level, team, teamSession)
|
||||
@leaderboards[team].once 'sync', @onLeaderboardLoaded, @
|
||||
|
||||
|
||||
onChallengersLoaded: -> @renderMaybe()
|
||||
onLeaderboardLoaded: -> @renderMaybe()
|
||||
|
||||
|
@ -105,7 +105,7 @@ module.exports = class LadderView extends RootView
|
|||
return unless _.every loaders, (loader) -> loader.loaded
|
||||
@startsLoading = false
|
||||
@render()
|
||||
|
||||
|
||||
getRenderData: ->
|
||||
ctx = super()
|
||||
ctx.level = @level
|
||||
|
@ -129,7 +129,7 @@ module.exports = class LadderView extends RootView
|
|||
primaryColor: primaryColor
|
||||
})
|
||||
ctx
|
||||
|
||||
|
||||
class LeaderboardData
|
||||
constructor: (@level, @team, @session) ->
|
||||
_.extend @, Backbone.Events
|
||||
|
@ -140,7 +140,7 @@ class LeaderboardData
|
|||
@topPlayers.sort()
|
||||
|
||||
@topPlayers.once 'sync', @leaderboardPartLoaded, @
|
||||
|
||||
|
||||
# if @session
|
||||
# score = @session.get('totalScore') or 25
|
||||
# @playersAbove = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 4, team: @team})
|
||||
|
@ -158,19 +158,19 @@ class LeaderboardData
|
|||
else
|
||||
@loaded = true
|
||||
@fetchNames()
|
||||
|
||||
|
||||
fetchNames: ->
|
||||
sessionCollections = [@topPlayers, @playersAbove, @playersBelow]
|
||||
sessionCollections = (s for s in sessionCollections when s)
|
||||
ids = []
|
||||
for collection in sessionCollections
|
||||
ids.push model.get('creator') for model in collection.models
|
||||
|
||||
|
||||
success = (nameMap) =>
|
||||
for collection in sessionCollections
|
||||
session.set('creatorName', nameMap[session.get('creator')]) for session in collection.models
|
||||
@trigger 'sync'
|
||||
|
||||
|
||||
$.ajax('/db/user/-/names', {
|
||||
data: {ids: ids}
|
||||
type: 'POST'
|
||||
|
@ -195,4 +195,3 @@ class ChallengersData
|
|||
if @easyPlayer.loaded and @mediumPlayer.loaded and @hardPlayer.loaded
|
||||
@loaded = true
|
||||
@trigger 'sync'
|
||||
|
Loading…
Add table
Reference in a new issue