This commit is contained in:
George Saines 2014-05-19 15:19:59 -07:00
commit 7c0d73e779
8 changed files with 32 additions and 24 deletions
app
server

View file

@ -656,6 +656,7 @@
rank_submitted: "Submitted for Ranking"
rank_failed: "Failed to Rank"
rank_being_ranked: "Game Being Ranked"
help_simulate: "Help simulate games?"
code_being_simulated: "Your new code is being simulated by other players for ranking. This will refresh as new matches come in."
no_ranked_matches_pre: "No ranked matches for the "
no_ranked_matches_post: " team! Play against some competitors and then come back here to get your game ranked."

View file

@ -235,7 +235,7 @@ _.extend LevelSessionSchema.properties,
totalScore:
title: 'Opponent total score'
description: 'The totalScore of a user when the match was computed'
type: 'number'
type: ['number','string']
metrics:
type: 'object'
properties:

View file

@ -1,3 +1,4 @@
.ladder-submission-view
h3
text-decoration: underline
.help-simulate
font-weight: normal
float: right

View file

@ -1,7 +1,9 @@
button.btn.btn-success.rank-button
span(data-i18n="ladder.rank_no_code").unavailable.hidden No New Code to Rank
span(data-i18n="ladder.rank_my_game").rank.hidden Rank My Game!
span(data-i18n="ladder.rank_submitting").submitting.hidden Submitting...
span(data-i18n="ladder.rank_submitted").submitted.hidden Submitted for Ranking
span(data-i18n="ladder.rank_failed").failed.hidden Failed to Rank
span(data-i18n="ladder.rank_being_ranked").ranking.hidden Game Being Ranked
span(data-i18n="ladder.rank_no_code").unavailable.secret No New Code to Rank
span(data-i18n="ladder.rank_my_game").rank.secret Rank My Game!
span(data-i18n="ladder.rank_submitting").submitting.secret Submitting...
span(data-i18n="ladder.rank_submitted").submitted.secret Submitted for Ranking
span(data-i18n="ladder.rank_failed").failed.secret Failed to Rank
span(data-i18n="ladder.rank_being_ranked").ranking.secret Game Being Ranked
a(href=simulateURL, data-i18n="ladder.help_simulate").help-simulate.secret Help simulate games?

View file

@ -2,11 +2,12 @@ CocoView = require 'views/kinds/CocoView'
template = require 'templates/play/common/ladder_submission'
module.exports = class LadderSubmissionView extends CocoView
class: "ladder-submission-view"
className: "ladder-submission-view"
template: template
events:
'click .rank-button': 'rankSession'
'click .help-simulate': 'onHelpSimulate'
constructor: (options) ->
super options
@ -16,9 +17,10 @@ module.exports = class LadderSubmissionView extends CocoView
getRenderData: ->
ctx = super()
ctx.readyToRank = @session?.readyToRank()
ctx.isRanking = @ession?.get('isRanking')
ctx.isRanking = @session?.get('isRanking')
ctx.simulateURL = "/play/ladder/#{@level.get('slug')}#simulate"
ctx
afterRender: ->
super()
return unless @supermodel.finished()
@ -34,9 +36,11 @@ module.exports = class LadderSubmissionView extends CocoView
@setRankingButtonText rankingState
setRankingButtonText: (spanClass) ->
@rankButton.find('span').addClass('hidden')
@rankButton.find(".#{spanClass}").removeClass('hidden')
@rankButton.find('span').hide()
@rankButton.find(".#{spanClass}").show()
@rankButton.toggleClass 'disabled', spanClass isnt 'rank'
helpSimulate = spanClass in ['submitted', 'ranking']
@$el.find('.help-simulate').toggle(helpSimulate, 'slow')
rankSession: (e) ->
return unless @session.readyToRank()
@ -86,3 +90,5 @@ module.exports = class LadderSubmissionView extends CocoView
transpiledCode[thang][spellID] = aether.transpile spell
transpiledCode
onHelpSimulate: ->
$('a[href="#simulate"]').tab('show')

View file

@ -91,7 +91,7 @@ module.exports = class MyMatchesTabView extends CocoView
session = _.find @sessions.models, {id: sessionID}
ladderSubmissionView = new LadderSubmissionView session: session, level: @level
@insertSubView ladderSubmissionView, placeholder
ladderSubmissionView.$el.find('.rank-button').addClass 'btn-block'
ladderSubmissionView.$el.find('.rank-button').addClass 'btn-block btn-lg'
@$el.find('.score-chart-wrapper').each (i, el) =>
scoreWrapper = $(el)

View file

@ -121,7 +121,7 @@ module.exports = class Handler
@modelClass.findOne(criteria, project).sort(sort).exec (err, document) ->
return done(err) if err
callback(null, document?.toObject() or null)
funcs = {}
for id in ids
return errors.badInput(res, "Given an invalid id: #{id}") unless Handler.isID(id)

View file

@ -103,7 +103,7 @@ module.exports.getTwoGames = (req, res) ->
#if userIsAnonymous req then return errors.unauthorized(res, "You need to be logged in to get games.")
humansGameID = req.body.humansGameID
ogresGameID = req.body.ogresGameID
unless ogresGameID and humansGameID
#fetch random games here
return errors.badInput(res, "You need to supply two games(for now)")
@ -121,10 +121,10 @@ module.exports.getTwoGames = (req, res) ->
"transpiledCode": session.transpiledCode
"teamSpells": session.teamSpells ? {}
"levelID": session.levelID
taskObject.sessions.push sessionInformation
sendResponseObject req, res, taskObject
module.exports.createNewTask = (req, res) ->
requestSessionID = req.body.session
originalLevelID = req.body.originalLevelID
@ -214,7 +214,7 @@ fetchInitialSessionsToRankAgainst = (levelMajorVersion, levelID, submittedSessio
submittedCode:
$exists: true
team: opposingTeam
sortParameters =
totalScore: 1
@ -663,9 +663,7 @@ retrieveOldSessionData = (sessionID, callback) ->
"totalScore":session.totalScore ? (25 - 1.8*(25/3))
"id": sessionID
callback err, oldScoreObject
markSessionAsDoneRanking = (sessionID, cb) ->
markSessionAsDoneRanking = (sessionID, cb) ->
#console.log "Marking session as done ranking..."
LevelSession.update {"_id":sessionID}, {"isRanking":false}, cb