mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
League now preserved throughout ladder navigation flow. Mirror match support for submitting to both sides at once.
This commit is contained in:
parent
765627a627
commit
73f3e7cdd9
17 changed files with 106 additions and 33 deletions
|
@ -54,13 +54,24 @@
|
||||||
border-image: url(/images/level/code_toolbar_run_button_active_pressed.png) 14 20 20 20 fill round
|
border-image: url(/images/level/code_toolbar_run_button_active_pressed.png) 14 20 20 20 fill round
|
||||||
padding: 2px 0 0 2px
|
padding: 2px 0 0 2px
|
||||||
|
|
||||||
&.submit-button, &.done-button
|
&.submit-button, &.done-button, &.rank-button
|
||||||
margin-left: 10px
|
margin-left: 10px
|
||||||
border-image: url(/images/level/code_toolbar_submit_button_active.png) 14 20 20 20 fill round
|
border-image: url(/images/level/code_toolbar_submit_button_active.png) 14 20 20 20 fill round
|
||||||
|
|
||||||
&:active
|
&:active
|
||||||
border-image: url(/images/level/code_toolbar_submit_button_active_pressed.png) 14 20 20 20 fill round
|
border-image: url(/images/level/code_toolbar_submit_button_active_pressed.png) 14 20 20 20 fill round
|
||||||
|
|
||||||
|
.ladder-submission-view
|
||||||
|
width: 45%
|
||||||
|
width: -webkit-calc(50% - 10px)
|
||||||
|
width: calc(50% - 10px)
|
||||||
|
display: inline-block
|
||||||
|
|
||||||
|
.btn.btn-illustrated
|
||||||
|
width: 100%
|
||||||
|
font-size: 18px
|
||||||
|
|
||||||
|
|
||||||
.cast-button
|
.cast-button
|
||||||
@include opacity(0.77)
|
@include opacity(0.77)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ div#columns.row
|
||||||
td.score-cell= Math.round(sessionStats.totalScore * 100)
|
td.score-cell= Math.round(sessionStats.totalScore * 100)
|
||||||
td.name-col-cell= session.get('creatorName') || "Anonymous"
|
td.name-col-cell= session.get('creatorName') || "Anonymous"
|
||||||
td.fight-cell
|
td.fight-cell
|
||||||
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}")
|
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
|
||||||
span(data-i18n="ladder.fight") Fight!
|
span(data-i18n="ladder.fight") Fight!
|
||||||
td.spectate-cell.iconic-cell
|
td.spectate-cell.iconic-cell
|
||||||
.glyphicon.glyphicon-eye-open
|
.glyphicon.glyphicon-eye-open
|
||||||
|
@ -51,7 +51,7 @@ div#columns.row
|
||||||
td.score-cell= Math.round(sessionStats.totalScore * 100)
|
td.score-cell= Math.round(sessionStats.totalScore * 100)
|
||||||
td.name-col-cell= session.get('creatorName') || "Anonymous"
|
td.name-col-cell= session.get('creatorName') || "Anonymous"
|
||||||
td.fight-cell
|
td.fight-cell
|
||||||
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}")
|
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
|
||||||
span(data-i18n="ladder.fight") Fight!
|
span(data-i18n="ladder.fight") Fight!
|
||||||
td.spectate-cell.iconic-cell
|
td.spectate-cell.iconic-cell
|
||||||
.glyphicon.glyphicon-eye-open
|
.glyphicon.glyphicon-eye-open
|
||||||
|
@ -84,7 +84,7 @@ div#columns.row
|
||||||
span :
|
span :
|
||||||
span= friend.team
|
span= friend.team
|
||||||
br
|
br
|
||||||
a(href="/play/level/#{level.get('slug') || level.id}/?team=#{friend.otherTeam}&opponent=#{friend._id}")
|
a(href="/play/level/#{level.get('slug') || level.id}/?team=#{friend.otherTeam}&opponent=#{friend._id}" + (league ? "&league=" + league.id : ""))
|
||||||
span(data-i18n="ladder.fight") Fight!
|
span(data-i18n="ladder.fight") Fight!
|
||||||
|
|
||||||
else if onFacebook || onGPlus
|
else if onFacebook || onGPlus
|
||||||
|
|
|
@ -109,7 +109,7 @@ block content
|
||||||
div.column.col-md-2
|
div.column.col-md-2
|
||||||
|
|
||||||
.spectate-button-container
|
.spectate-button-container
|
||||||
a(href="/play/spectate/#{level.get('slug')}").spectate-button.btn.btn-illustrated.btn-info.center
|
a(href="/play/spectate/#{level.get('slug')}" + (league ? "?league=" + league.id : "")).spectate-button.btn.btn-illustrated.btn-info.center
|
||||||
span(data-i18n="play.spectate") Spectate
|
span(data-i18n="play.spectate") Spectate
|
||||||
|
|
||||||
ul.nav.nav-pills
|
ul.nav.nav-pills
|
||||||
|
|
|
@ -43,7 +43,7 @@ div#columns.row
|
||||||
td.name-cell= match.opponentName || "Anonymous"
|
td.name-cell= match.opponentName || "Anonymous"
|
||||||
td.time-cell= match.when
|
td.time-cell= match.when
|
||||||
td.battle-cell
|
td.battle-cell
|
||||||
a(href="/play/level/#{levelID}?team=#{team.id}&opponent=#{match.sessionID}")
|
a(href="/play/level/#{levelID}?team=#{team.id}&opponent=#{match.sessionID}" + (league ? "&league=" + league.id : ""))
|
||||||
if (match.state === 'win')
|
if (match.state === 'win')
|
||||||
span(data-i18n="ladder.watch_victory") Watch your victory
|
span(data-i18n="ladder.watch_victory") Watch your victory
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,7 +12,7 @@ block modal-body-content
|
||||||
option(value=option.id selected=(language === option.id))= option.name
|
option(value=option.id selected=(language === option.id))= option.name
|
||||||
|
|
||||||
div#noob-view.secret
|
div#noob-view.secret
|
||||||
a(href="/play/level/#{levelID}-tutorial").btn.btn-success.btn-block.btn-lg
|
a(href="/play/level/#{levelID}-tutorial" + (league ? "?league=" + league.id : "")).btn.btn-success.btn-block.btn-lg
|
||||||
p
|
p
|
||||||
strong(data-i18n="ladder.tutorial_play") Play Tutorial
|
strong(data-i18n="ladder.tutorial_play") Play Tutorial
|
||||||
span(data-i18n="ladder.tutorial_recommended") Recommended if you've never played before
|
span(data-i18n="ladder.tutorial_recommended") Recommended if you've never played before
|
||||||
|
@ -23,8 +23,8 @@ block modal-body-content
|
||||||
p.tutorial-suggestion
|
p.tutorial-suggestion
|
||||||
strong(data-i18n="ladder.tutorial_not_sure") Not sure what's going on?
|
strong(data-i18n="ladder.tutorial_not_sure") Not sure what's going on?
|
||||||
|
|
|
|
||||||
a(href="/play/level/#{levelID}-tutorial", data-i18n="ladder.tutorial_play_first") Play the tutorial first.
|
a(href="/play/level/#{levelID}-tutorial" + (league ? "?league=" + league.id : ""), data-i18n="ladder.tutorial_play_first") Play the tutorial first.
|
||||||
a(href="/play/level/#{levelID}?team=#{teamID}")
|
a(href="/play/level/#{levelID}?team=#{teamID}" + (league ? "&league=" + league.id : ""))
|
||||||
div.play-option
|
div.play-option
|
||||||
img(src=myPortrait).my-icon.only-one
|
img(src=myPortrait).my-icon.only-one
|
||||||
img(src="/images/pages/play/ladder/"+teamID+"_ladder_tutorial.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
img(src="/images/pages/play/ladder/"+teamID+"_ladder_tutorial.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
||||||
|
@ -39,7 +39,7 @@ block modal-body-content
|
||||||
span(data-i18n="ladder.warmup") Warmup
|
span(data-i18n="ladder.warmup") Warmup
|
||||||
|
|
||||||
if challengers.easy
|
if challengers.easy
|
||||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.easy.sessionID}")
|
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.easy.sessionID}" + (league ? "&league=" + league.id : ""))
|
||||||
div.play-option.easy-option
|
div.play-option.easy-option
|
||||||
img(src=myPortrait).my-icon.only-one
|
img(src=myPortrait).my-icon.only-one
|
||||||
img(src="/images/pages/play/ladder/"+teamID+"_ladder_easy.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
img(src="/images/pages/play/ladder/"+teamID+"_ladder_easy.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
||||||
|
@ -55,7 +55,7 @@ block modal-body-content
|
||||||
span(data-i18n="general.easy") Easy
|
span(data-i18n="general.easy") Easy
|
||||||
|
|
||||||
if challengers.medium
|
if challengers.medium
|
||||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.medium.sessionID}")
|
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.medium.sessionID}" + (league ? "&league=" + league.id : ""))
|
||||||
div.play-option.medium-option
|
div.play-option.medium-option
|
||||||
img(src=myPortrait).my-icon.only-one
|
img(src=myPortrait).my-icon.only-one
|
||||||
img(src="/images/pages/play/ladder/"+teamID+"_ladder_medium.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
img(src="/images/pages/play/ladder/"+teamID+"_ladder_medium.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
||||||
|
@ -71,7 +71,7 @@ block modal-body-content
|
||||||
span(data-i18n="general.medium") Medium
|
span(data-i18n="general.medium") Medium
|
||||||
|
|
||||||
if challengers.hard
|
if challengers.hard
|
||||||
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.hard.sessionID}")
|
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.hard.sessionID}" + (league ? "&league=" + league.id : ""))
|
||||||
div.play-option.hard-option
|
div.play-option.hard-option
|
||||||
img(src=myPortrait).my-icon.only-one
|
img(src=myPortrait).my-icon.only-one
|
||||||
img(src="/images/pages/play/ladder/"+teamID+"_ladder_hard.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
img(src="/images/pages/play/ladder/"+teamID+"_ladder_hard.png", style="border: 1px solid #{teamColor}; background: #{teamBackgroundColor}").my-team-icon.img-circle.only-one
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
.levels-link-area
|
.levels-link-area
|
||||||
a.levels-link(href=homeLink || "/")
|
a.levels-link(href=homeLink || "/")
|
||||||
.glyphicon.glyphicon-play
|
.glyphicon.glyphicon-play
|
||||||
span(data-i18n="nav.play").home-text Levels
|
span(data-i18n=ladderGame ? "general.ladder" : "nav.play").home-text Levels
|
||||||
|
|
||||||
if isMultiplayerLevel && !observing
|
if isMultiplayerLevel && !observing
|
||||||
.multiplayer-area-container
|
.multiplayer-area-container
|
||||||
|
|
|
@ -2,6 +2,9 @@ button.btn.btn-lg.btn-illustrated.cast-button(title=castVerbose)
|
||||||
span(data-i18n="play_level.tome_run_button_ran") Ran
|
span(data-i18n="play_level.tome_run_button_ran") Ran
|
||||||
|
|
||||||
if !observing
|
if !observing
|
||||||
|
if mirror
|
||||||
|
.ladder-submission-view
|
||||||
|
else
|
||||||
button.btn.btn-lg.btn-illustrated.submit-button(title=castRealTimeVerbose)
|
button.btn.btn-lg.btn-illustrated.submit-button(title=castRealTimeVerbose)
|
||||||
span(data-i18n="play_level.tome_submit_button") Submit
|
span(data-i18n="play_level.tome_submit_button") Submit
|
||||||
span.spl.secret.submit-again-time
|
span.spl.secret.submit-again-time
|
||||||
|
|
|
@ -103,6 +103,7 @@ module.exports = class LadderPlayModal extends ModalView
|
||||||
{id: 'lua', name: 'Lua'}
|
{id: 'lua', name: 'Lua'}
|
||||||
{id: 'io', name: 'Io (Experimental)'}
|
{id: 'io', name: 'Io (Experimental)'}
|
||||||
]
|
]
|
||||||
|
ctx.league = @options.league
|
||||||
teamsList = teamDataFromLevel @level
|
teamsList = teamDataFromLevel @level
|
||||||
teams = {}
|
teams = {}
|
||||||
teams[team.id] = team for team in teamsList
|
teams[team.id] = team for team in teamsList
|
||||||
|
|
|
@ -108,6 +108,8 @@ module.exports = class LadderView extends RootView
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopImmediatePropagation()
|
e.stopImmediatePropagation()
|
||||||
url = "/play/spectate/#{@level.get('slug')}?session-one=#{humanSession}&session-two=#{ogreSession}"
|
url = "/play/spectate/#{@level.get('slug')}?session-one=#{humanSession}&session-two=#{ogreSession}"
|
||||||
|
url += '&league=' + @league.id if @league
|
||||||
|
url += '&autoplay=false' if key.command
|
||||||
window.open url, if key.command then '_blank' else 'spectate' # New tab for spectating specific matches
|
window.open url, if key.command then '_blank' else 'spectate' # New tab for spectating specific matches
|
||||||
#Backbone.Mediator.publish 'router:navigate', route: url
|
#Backbone.Mediator.publish 'router:navigate', route: url
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
ctx.level = @level
|
ctx.level = @level
|
||||||
ctx.levelID = @level.get('slug') or @level.id
|
ctx.levelID = @level.get('slug') or @level.id
|
||||||
ctx.teams = @teams
|
ctx.teams = @teams
|
||||||
|
ctx.league = @options.league
|
||||||
|
|
||||||
convertMatch = (match, submitDate) =>
|
convertMatch = (match, submitDate) =>
|
||||||
opponent = match.opponents[0]
|
opponent = match.opponents[0]
|
||||||
|
@ -116,7 +117,9 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
placeholder = $(el)
|
placeholder = $(el)
|
||||||
sessionID = placeholder.data('session-id')
|
sessionID = placeholder.data('session-id')
|
||||||
session = _.find @sessions.models, {id: sessionID}
|
session = _.find @sessions.models, {id: sessionID}
|
||||||
ladderSubmissionView = new LadderSubmissionView session: session, level: @level
|
if @level.get('slug') in ['ace-of-coders']
|
||||||
|
mirrorSession = (s for s in @sessions.models when s.get('team') isnt session.get('team'))[0]
|
||||||
|
ladderSubmissionView = new LadderSubmissionView session: session, level: @level, mirrorSession: mirrorSession
|
||||||
@insertSubView ladderSubmissionView, placeholder
|
@insertSubView ladderSubmissionView, placeholder
|
||||||
|
|
||||||
@$el.find('.score-chart-wrapper').each (i, el) =>
|
@$el.find('.score-chart-wrapper').each (i, el) =>
|
||||||
|
|
|
@ -257,6 +257,7 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
startFrame = @lastWorldFramesLoaded ? 0
|
startFrame = @lastWorldFramesLoaded ? 0
|
||||||
if @world.frames.length is @world.totalFrames # Finished loading
|
if @world.frames.length is @world.totalFrames # Finished loading
|
||||||
@lastWorldFramesLoaded = 0
|
@lastWorldFramesLoaded = 0
|
||||||
|
unless @getQueryVariable('autoplay') is false
|
||||||
Backbone.Mediator.publish 'level:set-playing', playing: true # Since we paused at first, now we autostart playback.
|
Backbone.Mediator.publish 'level:set-playing', playing: true # Since we paused at first, now we autostart playback.
|
||||||
else
|
else
|
||||||
@lastWorldFramesLoaded = @world.frames.length
|
@lastWorldFramesLoaded = @world.frames.length
|
||||||
|
@ -271,6 +272,8 @@ module.exports = class SpectateLevelView extends RootView
|
||||||
@sessionOne = data[0]._id
|
@sessionOne = data[0]._id
|
||||||
@sessionTwo = data[1]._id
|
@sessionTwo = data[1]._id
|
||||||
url = "/play/spectate/#{@levelID}?session-one=#{@sessionOne}&session-two=#{@sessionTwo}"
|
url = "/play/spectate/#{@levelID}?session-one=#{@sessionOne}&session-two=#{@sessionTwo}"
|
||||||
|
if leagueID = @getQueryVariable 'league'
|
||||||
|
url += "&league=" + leagueID
|
||||||
Backbone.Mediator.publish 'router:navigate', {
|
Backbone.Mediator.publish 'router:navigate', {
|
||||||
route: url,
|
route: url,
|
||||||
viewClass: SpectateLevelView,
|
viewClass: SpectateLevelView,
|
||||||
|
|
|
@ -13,6 +13,7 @@ module.exports = class LadderSubmissionView extends CocoView
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super options
|
super options
|
||||||
@session = options.session
|
@session = options.session
|
||||||
|
@mirrorSession = options.mirrorSession
|
||||||
@level = options.level
|
@level = options.level
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
|
@ -62,20 +63,31 @@ module.exports = class LadderSubmissionView extends CocoView
|
||||||
console.log jqxhr.responseText
|
console.log jqxhr.responseText
|
||||||
@setRankingButtonText 'failed' unless @destroyed
|
@setRankingButtonText 'failed' unless @destroyed
|
||||||
@transpileSession (transpiledCode) =>
|
@transpileSession (transpiledCode) =>
|
||||||
|
|
||||||
ajaxData =
|
ajaxData =
|
||||||
session: @session.id
|
session: @session.id
|
||||||
levelID: @level.id
|
levelID: @level.id
|
||||||
originalLevelID: @level.get('original')
|
originalLevelID: @level.get('original')
|
||||||
levelMajorVersion: @level.get('version').major
|
levelMajorVersion: @level.get('version').major
|
||||||
transpiledCode: transpiledCode
|
transpiledCode: transpiledCode
|
||||||
|
ajaxOptions =
|
||||||
$.ajax '/queue/scoring', {
|
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
data: ajaxData
|
data: ajaxData
|
||||||
success: success
|
success: success
|
||||||
error: failure
|
error: failure
|
||||||
}
|
if @mirrorSession
|
||||||
|
# Also submit the mirrorSession after the main session submits successfully.
|
||||||
|
mirrorAjaxData = _.clone ajaxData
|
||||||
|
mirrorAjaxData.session = @mirrorSession.id
|
||||||
|
if @session.get('team') is 'humans'
|
||||||
|
mirrorAjaxData.transpiledCode = 'hero-placeholder-1': transpiledCode['hero-placeholder']
|
||||||
|
else
|
||||||
|
mirrorAjaxData.transpiledCode = 'hero-placeholder': transpiledCode['hero-placeholder-1']
|
||||||
|
mirrorAjaxOptions = _.clone ajaxOptions
|
||||||
|
mirrorAjaxOptions.data = mirrorAjaxData
|
||||||
|
ajaxOptions.success = ->
|
||||||
|
$.ajax '/queue/scoring', mirrorAjaxOptions
|
||||||
|
|
||||||
|
$.ajax '/queue/scoring', ajaxOptions
|
||||||
|
|
||||||
transpileSession: (callback) ->
|
transpileSession: (callback) ->
|
||||||
submittedCode = @session.get('code')
|
submittedCode = @session.get('code')
|
||||||
|
|
|
@ -76,13 +76,18 @@ module.exports = class ControlBarView extends CocoView
|
||||||
@homeLink = '/play/ladder/' + levelID
|
@homeLink = '/play/ladder/' + levelID
|
||||||
@homeViewClass = 'views/ladder/LadderView'
|
@homeViewClass = 'views/ladder/LadderView'
|
||||||
@homeViewArgs.push levelID
|
@homeViewArgs.push levelID
|
||||||
|
if leagueID = @getQueryVariable 'league'
|
||||||
|
leagueType = if @level.get('type') is 'course-ladder' then 'course' else 'clan'
|
||||||
|
@homeViewArgs.push leagueType
|
||||||
|
@homeViewArgs.push leagueID
|
||||||
|
@homeLink += "/#{leagueType}/#{leagueID}"
|
||||||
else if @level.get('type', true) in ['hero', 'hero-coop']
|
else if @level.get('type', true) in ['hero', 'hero-coop']
|
||||||
@homeLink = '/play'
|
@homeLink = '/play'
|
||||||
@homeViewClass = 'views/play/CampaignView'
|
@homeViewClass = 'views/play/CampaignView'
|
||||||
campaign = @level.get 'campaign'
|
campaign = @level.get 'campaign'
|
||||||
@homeLink += '/' + campaign
|
@homeLink += '/' + campaign
|
||||||
@homeViewArgs.push campaign
|
@homeViewArgs.push campaign
|
||||||
else if @level.get('type', true) in ['course', 'course-ladder']
|
else if @level.get('type', true) in ['course']
|
||||||
@homeLink = '/courses/mock1'
|
@homeLink = '/courses/mock1'
|
||||||
@homeViewClass = 'views/courses/mock1/CourseDetailsView'
|
@homeViewClass = 'views/courses/mock1/CourseDetailsView'
|
||||||
#campaign = @level.get 'campaign'
|
#campaign = @level.get 'campaign'
|
||||||
|
|
|
@ -369,9 +369,18 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
@$el.find('.sign-up-poke').toggleClass('hide', not @readyToContinue)
|
@$el.find('.sign-up-poke').toggleClass('hide', not @readyToContinue)
|
||||||
|
|
||||||
onGameSubmitted: (e) ->
|
onGameSubmitted: (e) ->
|
||||||
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
|
@returnToLadder()
|
||||||
|
|
||||||
|
returnToLadder: ->
|
||||||
# Preserve the supermodel as we navigate back to the ladder.
|
# Preserve the supermodel as we navigate back to the ladder.
|
||||||
Backbone.Mediator.publish 'router:navigate', route: ladderURL, viewClass: 'views/ladder/LadderView', viewArgs: [{supermodel: @supermodel}, @level.get('slug')]
|
viewArgs = [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @level.get('slug')]
|
||||||
|
ladderURL = "/play/ladder/#{@level.get('slug') || @level.id}#my-matches"
|
||||||
|
if leagueID = @getQueryVariable 'league'
|
||||||
|
leagueType = if @level.get('type') is 'course-ladder' then 'course' else 'clan'
|
||||||
|
viewArgs.push leagueType
|
||||||
|
viewArgs.push leagueID
|
||||||
|
ladderURL += "/#{leagueType}/#{leagueID}"
|
||||||
|
Backbone.Mediator.publish 'router:navigate', route: ladderURL, viewClass: 'views/ladder/LadderView', viewArgs: viewArgs
|
||||||
|
|
||||||
playSelectionSound: (hero, preload=false) ->
|
playSelectionSound: (hero, preload=false) ->
|
||||||
return unless sounds = hero.get('soundTriggers')?.selected
|
return unless sounds = hero.get('soundTriggers')?.selected
|
||||||
|
@ -433,9 +442,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
||||||
onClickReturnToLadder: (e) ->
|
onClickReturnToLadder: (e) ->
|
||||||
@playSound 'menu-button-click'
|
@playSound 'menu-button-click'
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
route = $(e.target).data('href')
|
@returnToLadder()
|
||||||
# Preserve the supermodel as we navigate back to the ladder.
|
|
||||||
Backbone.Mediator.publish 'router:navigate', route: route, viewClass: 'views/ladder/LadderView', viewArgs: [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @level.get('slug')]
|
|
||||||
|
|
||||||
onClickSignupButton: (e) ->
|
onClickSignupButton: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
CocoView = require 'views/core/CocoView'
|
CocoView = require 'views/core/CocoView'
|
||||||
template = require 'templates/play/level/tome/cast_button'
|
template = require 'templates/play/level/tome/cast_button'
|
||||||
{me} = require 'core/auth'
|
{me} = require 'core/auth'
|
||||||
|
LadderSubmissionView = require 'views/play/common/LadderSubmissionView'
|
||||||
|
LevelSession = require 'models/LevelSession'
|
||||||
|
|
||||||
module.exports = class CastButtonView extends CocoView
|
module.exports = class CastButtonView extends CocoView
|
||||||
id: 'cast-button-view'
|
id: 'cast-button-view'
|
||||||
|
@ -28,6 +30,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
@castShortcut = '⇧↵'
|
@castShortcut = '⇧↵'
|
||||||
@updateReplayabilityInterval = setInterval @updateReplayability, 1000
|
@updateReplayabilityInterval = setInterval @updateReplayability, 1000
|
||||||
@observing = options.session.get('creator') isnt me.id
|
@observing = options.session.get('creator') isnt me.id
|
||||||
|
@loadMirrorSession() if @options.level.get('slug') in ['ace-of-coders']
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
clearInterval @updateReplayabilityInterval
|
clearInterval @updateReplayabilityInterval
|
||||||
|
@ -42,6 +45,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
context.castVerbose = castShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_code')
|
context.castVerbose = castShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_code')
|
||||||
context.castRealTimeVerbose = castRealTimeShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_real_time')
|
context.castRealTimeVerbose = castRealTimeShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_real_time')
|
||||||
context.observing = @observing
|
context.observing = @observing
|
||||||
|
context.mirror = @mirrorSession?
|
||||||
context
|
context
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
|
@ -55,6 +59,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
if @options.level.get('slug') is 'thornbush-farm'# and not @options.session.get('state')?.complete
|
if @options.level.get('slug') is 'thornbush-farm'# and not @options.session.get('state')?.complete
|
||||||
@$el.find('.submit-button').hide() # Hide submit until first win so that script can explain it.
|
@$el.find('.submit-button').hide() # Hide submit until first win so that script can explain it.
|
||||||
@updateReplayability()
|
@updateReplayability()
|
||||||
|
@updateLadderSubmissionViews()
|
||||||
|
|
||||||
attachTo: (spellView) ->
|
attachTo: (spellView) ->
|
||||||
@$el.detach().prependTo(spellView.toolbarView.$el).show()
|
@$el.detach().prependTo(spellView.toolbarView.$el).show()
|
||||||
|
@ -96,6 +101,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
@casting = false
|
@casting = false
|
||||||
if @hasCastOnce # Don't play this sound the first time
|
if @hasCastOnce # Don't play this sound the first time
|
||||||
@playSound 'cast-end', 0.5
|
@playSound 'cast-end', 0.5
|
||||||
|
_.delay (=> @ladderSubmissionView?.rankSession()), 1000 if @ladderSubmissionView
|
||||||
@hasCastOnce = true
|
@hasCastOnce = true
|
||||||
@updateCastButton()
|
@updateCastButton()
|
||||||
@world = e.world
|
@world = e.world
|
||||||
|
@ -136,6 +142,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
castText = $.i18n.t('play_level.tome_cast_button_ran')
|
castText = $.i18n.t('play_level.tome_cast_button_ran')
|
||||||
@castButton.text castText
|
@castButton.text castText
|
||||||
#@castButton.prop 'disabled', not castable
|
#@castButton.prop 'disabled', not castable
|
||||||
|
@ladderSubmissionView?.updateButton()
|
||||||
|
|
||||||
updateReplayability: =>
|
updateReplayability: =>
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
|
@ -148,6 +155,18 @@ module.exports = class CastButtonView extends CocoView
|
||||||
waitTime = moment().add(timeUntilResubmit, 'ms').fromNow()
|
waitTime = moment().add(timeUntilResubmit, 'ms').fromNow()
|
||||||
submitAgainLabel.text waitTime
|
submitAgainLabel.text waitTime
|
||||||
|
|
||||||
|
loadMirrorSession: ->
|
||||||
|
url = "/db/level/#{@options.level.get('slug') or @options.level.id}/session"
|
||||||
|
url += "?team=#{if me.team is 'humans' then 'ogres' else 'humans'}"
|
||||||
|
mirrorSession = new LevelSession().setURL url
|
||||||
|
@mirrorSession = @supermodel.loadModel(mirrorSession, 'level_session', {cache: false}).model
|
||||||
|
|
||||||
|
updateLadderSubmissionViews: ->
|
||||||
|
@removeSubView subview for key, subview of @subviews when subview instanceof LadderSubmissionView
|
||||||
|
placeholder = @$el.find('.ladder-submission-view')
|
||||||
|
@ladderSubmissionView = new LadderSubmissionView session: @options.session, level: @options.level, mirrorSession: @mirrorSession
|
||||||
|
@insertSubView @ladderSubmissionView, placeholder
|
||||||
|
|
||||||
onJoinedRealTimeMultiplayerGame: (e) ->
|
onJoinedRealTimeMultiplayerGame: (e) ->
|
||||||
@inRealTimeMultiplayerSession = true
|
@inRealTimeMultiplayerSession = true
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = class GameMenuModal extends ModalView
|
||||||
submenus = ['guide', 'options', 'save-load', 'multiplayer']
|
submenus = ['guide', 'options', 'save-load', 'multiplayer']
|
||||||
submenus = _.without submenus, 'guide' unless docs.specificArticles?.length or docs.generalArticles?.length
|
submenus = _.without submenus, 'guide' unless docs.specificArticles?.length or docs.generalArticles?.length
|
||||||
submenus = _.without submenus, 'save-load' unless me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
|
submenus = _.without submenus, 'save-load' unless me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
|
||||||
submenus = _.without submenus, 'multiplayer' unless me.isAdmin() or @level?.get('type') in ['ladder', 'hero-ladder', 'course-ladder']
|
submenus = _.without submenus, 'multiplayer' unless me.isAdmin() or (@level?.get('type') in ['ladder', 'hero-ladder', 'course-ladder'] and @level.get('slug') not in ['ace-of-coders'])
|
||||||
@includedSubmenus = submenus
|
@includedSubmenus = submenus
|
||||||
context.showTab = @options.showTab ? submenus[0]
|
context.showTab = @options.showTab ? submenus[0]
|
||||||
context.submenus = submenus
|
context.submenus = submenus
|
||||||
|
|
|
@ -72,8 +72,15 @@ module.exports = class MultiplayerView extends CocoView
|
||||||
e.target.select()
|
e.target.select()
|
||||||
|
|
||||||
onGameSubmitted: (e) ->
|
onGameSubmitted: (e) ->
|
||||||
|
# Preserve the supermodel as we navigate back to the ladder.
|
||||||
|
viewArgs = [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @levelID]
|
||||||
ladderURL = "/play/ladder/#{@levelID}#my-matches"
|
ladderURL = "/play/ladder/#{@levelID}#my-matches"
|
||||||
Backbone.Mediator.publish 'router:navigate', route: ladderURL
|
if leagueID = @getQueryVariable 'league'
|
||||||
|
leagueType = if @level?.get('type') is 'course-ladder' then 'course' else 'clan'
|
||||||
|
viewArgs.push leagueType
|
||||||
|
viewArgs.push leagueID
|
||||||
|
ladderURL += "/#{leagueType}/#{leagueID}"
|
||||||
|
Backbone.Mediator.publish 'router:navigate', route: ladderURL, viewClass: 'views/ladder/LadderView', viewArgs: viewArgs
|
||||||
|
|
||||||
updateLinkSection: ->
|
updateLinkSection: ->
|
||||||
multiplayer = @$el.find('#multiplayer').prop('checked')
|
multiplayer = @$el.find('#multiplayer').prop('checked')
|
||||||
|
|
Loading…
Reference in a new issue