From 5ddbbe7707f3cbab33012cf66f20d8d85b4cfdfc Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 18 Sep 2014 08:12:46 -0700 Subject: [PATCH] Fixed a bug with spectate not loading opponent code language. Improved Criss-Cross winners formatting. --- app/styles/play/ladder/ladder.sass | 4 ++++ app/templates/play/ladder/ladder.jade | 10 +++++++++- app/views/play/SpectateView.coffee | 2 +- app/views/play/ladder/LadderView.coffee | 2 +- app/views/play/level/tome/Spell.coffee | 5 +++-- app/views/play/level/tome/TomeView.coffee | 1 + 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/styles/play/ladder/ladder.sass b/app/styles/play/ladder/ladder.sass index 565db3a94..e64660fd2 100644 --- a/app/styles/play/ladder/ladder.sass +++ b/app/styles/play/ladder/ladder.sass @@ -137,6 +137,10 @@ color: #172 .loss color: #712 + .code-language-cell + padding: 0 10px + background: transparent url(/images/common/code_languages/javascript_icon.png) no-repeat center center + height: 16px @media only screen and (max-width: 800px) #ladder-view diff --git a/app/templates/play/ladder/ladder.jade b/app/templates/play/ladder/ladder.jade index e55ee9137..f0e07073d 100644 --- a/app/templates/play/ladder/ladder.jade +++ b/app/templates/play/ladder/ladder.jade @@ -48,7 +48,7 @@ block content if level.get('name') == 'Criss-Cross' .tournament-blurb h2 - span(data-i18n="ladder.tournament_ends") Tournament ends + span(data-i18n="ladder.tournament_ended") Tournament ended | #{tournamentTimeLeft} p span(data-i18n="ladder.tournament_blurb_criss_cross") Win bids, construct paths, outwit opponents, grab gems, and upgrade your career in our Criss-Cross tournament! Check out the details @@ -745,11 +745,15 @@ block content thead tr th(data-i18n="ladder_prizes.rank") Rank + if level.get('name') == 'Criss-Cross' + th th Human if level.get('name') == 'Greed' th Human wins/losses/ties else th Human score + if level.get('name') == 'Criss-Cross' + th th Ogre if level.get('name') == 'Greed' th Ogre wins/losses/ties @@ -761,6 +765,8 @@ block content - var ogre = winners.ogres[index] tr td= human.rank + if level.get('name') == 'Criss-Cross' + td.code-language-cell(style="background-image: url(/images/common/code_languages/" + human.codeLanguage + "_icon.png)" title=_.string.capitalize(human.codeLanguage)) td= human.name if level.get('name') == 'Greed' td @@ -773,6 +779,8 @@ block content td span= Math.round(100 * human.score) if ogre + if level.get('name') == 'Criss-Cross' + td.code-language-cell(style="background-image: url(/images/common/code_languages/" + ogre.codeLanguage + "_icon.png)" title=_.string.capitalize(ogre.codeLanguage)) td= ogre.name if level.get('name') == 'Greed' td diff --git a/app/views/play/SpectateView.coffee b/app/views/play/SpectateView.coffee index f4d7514ba..05f97f20e 100644 --- a/app/views/play/SpectateView.coffee +++ b/app/views/play/SpectateView.coffee @@ -183,7 +183,7 @@ module.exports = class SpectateLevelView extends RootView ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50) insertSubviews: -> - @insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, spectateView: true + @insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, spectateView: true, spectateOpponentCodeLanguage: @otherSession?.get('submittedCodeLanguage') @insertSubView new PlaybackView {} @insertSubView new GoldView {} diff --git a/app/views/play/ladder/LadderView.coffee b/app/views/play/ladder/LadderView.coffee index 2c70f3ba6..32b441ebd 100644 --- a/app/views/play/ladder/LadderView.coffee +++ b/app/views/play/ladder/LadderView.coffee @@ -65,7 +65,7 @@ module.exports = class LadderView extends RootView @insertSubView(@simulateTab = new SimulateTabView()) @refreshInterval = setInterval(@fetchSessionsAndRefreshViews.bind(@), 20 * 1000) hash = document.location.hash[1..] if document.location.hash - if hash and not (hash in ['my-matches', 'simulate', 'ladder', 'prizes', 'rules']) + if hash and not (hash in ['my-matches', 'simulate', 'ladder', 'prizes', 'rules', 'winners']) @showPlayModal(hash) if @sessions.loaded fetchSessionsAndRefreshViews: -> diff --git a/app/views/play/level/tome/Spell.coffee b/app/views/play/level/tome/Spell.coffee index 0b74cf6f7..da5bb7262 100644 --- a/app/views/play/level/tome/Spell.coffee +++ b/app/views/play/level/tome/Spell.coffee @@ -14,6 +14,7 @@ module.exports = class Spell @session = options.session @otherSession = options.otherSession @spectateView = options.spectateView + @spectateOpponentCodeLanguage = options.spectateOpponentCodeLanguage @supermodel = options.supermodel @skipProtectAPI = options.skipProtectAPI @worker = options.worker @@ -27,7 +28,7 @@ module.exports = class Spell if @canWrite() @setLanguage options.language else if @isEnemySpell() - @setLanguage options.otherSession.get 'submittedCodeLanguage' + @setLanguage @otherSession?.get('submittedCodeLanguage') ? @spectateOpponentCodeLanguage else @setLanguage 'javascript' @useTranspiledCode = @shouldUseTranspiledCode() @@ -150,7 +151,7 @@ module.exports = class Spell isEnemySpell: -> return false unless @permissions.readwrite.length - return false unless @otherSession + return false unless @otherSession or @spectateView teamSpells = @session.get('teamSpells') team = @session.get('team') ? 'humans' teamSpells and not _.contains(teamSpells[team], @spellKey) diff --git a/app/views/play/level/tome/TomeView.coffee b/app/views/play/level/tome/TomeView.coffee index 923c5a1ab..066fa9b71 100644 --- a/app/views/play/level/tome/TomeView.coffee +++ b/app/views/play/level/tome/TomeView.coffee @@ -133,6 +133,7 @@ module.exports = class TomeView extends CocoView worker: @worker language: language spectateView: @options.spectateView + spectateOpponentCodeLanguage: @options.spectateOpponentCodeLanguage levelID: @options.levelID for thangID, spellKeys of @thangSpells