Fixed playback victory message for spectate mode. Spectate mode now opens in new tabs.

This commit is contained in:
Nick Winter 2015-09-03 15:04:57 -07:00
parent 58880b23af
commit 98b0bcfc75
5 changed files with 25 additions and 12 deletions

View file

@ -56,7 +56,7 @@ module.exports = class PlaybackOverScreen extends CocoClass
incomplete = not success and not failure and not timedOut
color = if failure then 'rgba(255, 128, 128, 0.4)' else 'rgba(255, 255, 255, 0.4)'
@updateColor color
@updateText success, timedOut, incomplete
@updateText e
updateColor: (color) ->
return if color is @color
@ -67,19 +67,29 @@ module.exports = class PlaybackOverScreen extends CocoClass
@dimLayer.cache 0, 0, @camera.canvasWidth, @camera.canvasHeight
@color = color
updateText: (success, timedOut, incomplete) ->
updateText: (goalEvent) ->
return unless _.size @playerNames # Only on multiplayer levels
teamOverallStatuses = {}
goals = if goalEvent.goalStates then _.values goalEvent.goalStates else []
goals = (g for g in goals when not g.optional)
for team in ['humans', 'ogres']
teamGoals = (g for g in goals when g.team in [undefined, team])
statuses = (goal.status for goal in teamGoals)
overallStatus = 'success' if statuses.length > 0 and _.every(statuses, (s) -> s is 'success')
overallStatus = 'failure' if statuses.length > 0 and 'failure' in statuses
teamOverallStatuses[team] = overallStatus
@makeVictoryText() unless @text
# TODO: i18n this
if (success and me.team is 'humans') or (not success and me.team is 'ogres')
if teamOverallStatuses.humans is 'success'
@text.color = '#E62B1E'
@text.text = (@playerNames.humans ? 'HUMAN AI').toLocaleUpperCase() + ' WINS'
else if (success and me.team is 'ogres') or (not success and me.team is 'humans')
@text.text = ((@playerNames.humans ? $.i18n.t('ladder.red_ai')) + ' ' + $.i18n.t('ladder.wins')).toLocaleUpperCase()
else if teamOverallStatuses.ogres is 'success'
@text.color = '#0597FF'
@text.text = (@playerNames.ogres ? 'OGRE AI').toLocaleUpperCase() + ' WINS'
@text.text = ((@playerNames.ogres ? $.i18n.t('ladder.blue_ai')) + ' ' + $.i18n.t('ladder.wins')).toLocaleUpperCase()
else
@text.color = '#F7B42C'
if timedOut
if goalEvent.timedOut
@text.text = 'TIMED OUT'
else
@text.text = 'INCOMPLETE'

View file

@ -120,7 +120,7 @@ module.exports = class GoalManager extends CocoClass
goals = if @goalStates then _.values @goalStates else []
goals = (g for g in goals when not g.optional)
goals = (g for g in goals when g.team in [undefined, @team]) if @team
statuses = if @goalStates then (goal.status for goal in goals) else []
statuses = (goal.status for goal in goals)
overallStatus = 'success' if statuses.length > 0 and _.every(statuses, (s) -> s is 'success' or (ignoreIncomplete and s is null))
overallStatus = 'failure' if statuses.length > 0 and 'failure' in statuses
#console.log 'got overallStatus', overallStatus, 'from goals', goals, 'goalStates', @goalStates, 'statuses', statuses

View file

@ -1081,6 +1081,9 @@
rules: "Rules"
winners: "Winners"
league: "League"
red_ai: "Red AI" # "Red AI Wins", at end of multiplayer match playback
blue_ai: "Blue AI"
wins: "Wins" # At end of multiplayer match playback
user:
stats: "Stats"

View file

@ -104,12 +104,12 @@ module.exports = class LadderView extends RootView
onClickSpectateButton: (e) ->
humanSession = @ladderTab.spectateTargets?.humans
ogreSession = @ladderTab.spectateTargets?.ogres
console.log humanSession, ogreSession
return unless humanSession and ogreSession
e.preventDefault()
e.stopImmediatePropagation()
url = "/play/spectate/#{@level.get('slug')}?session-one=#{humanSession}&session-two=#{ogreSession}"
Backbone.Mediator.publish 'router:navigate', route: url
window.open url, if key.command then '_blank' else 'spectate' # New tab for spectating specific matches
#Backbone.Mediator.publish 'router:navigate', route: url
showPlayModal: (teamID) ->
session = (s for s in @sessions.models when s.get('team') is teamID)[0]

View file

@ -66,7 +66,7 @@ getRandomSessions = (user, callback) ->
# Sampling by level: we pick a level, then find a human and ogre session for that level, one at random, one biased towards recent submissions.
#ladderLevelIDs = ['greed', 'criss-cross', 'brawlwood', 'dungeon-arena', 'gold-rush', 'sky-span'] # Let's not give any extra simulations to old ladders.
ladderLevelIDs = ['dueling-grounds', 'cavern-survival', 'multiplayer-treasure-grove', 'harrowland', 'zero-sum']
ladderLevelIDs = ['dueling-grounds', 'cavern-survival', 'multiplayer-treasure-grove', 'harrowland', 'zero-sum', 'ace-of-coders']
sampleByLevel = (callback) ->
levelID = _.sample ladderLevelIDs
favorRecentHumans = Math.random() < 0.5 # We pick one session favoring recent submissions, then find another one uniformly to play against