Merge branch 'master' into production

This commit is contained in:
phoenixeliot 2016-06-08 14:40:53 -07:00
commit 938be287b3
21 changed files with 157 additions and 152 deletions

View file

@ -30,3 +30,14 @@ before_script:
script:
- "./node_modules/karma/bin/karma start --browsers Firefox --single-run --reporters progress"
- "npm run jasmine"
notifications:
slack:
rooms:
- secure: dv1zozcLo/gGb1i1OeKKLQgjLagW3jqhkEIiZrVbubfRMrrHouZwtlg1HDVc2GOzP1yCaUOYOLBqT3lTE9CKt4pE8k3p0gJ77j1rHxTyeYny2ETq4w5sXak8ju8M3EDnj+Au2NWWrGiD0YkIUnF5vxzKUc1pkS+vDSWR2ORkOrU=
template:
- Tests failed <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository}@%{branch} by %{author} %{result} <!here>
on_success: never
on_failure: always
on_start: never
on_pull_requests: false

View file

@ -40,6 +40,7 @@ module.exports = class LevelLoader extends CocoClass
@worldNecessities = []
@listenTo @supermodel, 'resource-loaded', @onWorldNecessityLoaded
@listenTo @supermodel, 'failed', @onWorldNecessityLoadFailed
@loadLevel()
@loadAudio()
@playJingle()
@ -329,6 +330,9 @@ module.exports = class LevelLoader extends CocoClass
@worldNecessities = (r for r in @worldNecessities when r?)
@onWorldNecessitiesLoaded() if @checkAllWorldNecessitiesRegisteredAndLoaded()
onWorldNecessityLoadFailed: (resource) ->
@trigger('world-necessity-load-failed', resource: resource)
checkAllWorldNecessitiesRegisteredAndLoaded: ->
return false unless _.filter(@worldNecessities).length is 0
return false unless @thangNamesLoaded

View file

@ -255,6 +255,8 @@ module.exports = class ThangType extends CocoModel
"Samurai": "Hattori"
"Sorcerer": "Pender"
"Trapper": "Senick"
"Champion": "Ida"
"Duelist": "Nando"
}
map[@get('name')]

View file

@ -157,7 +157,7 @@ $UNVEIL_TIME: 1.2s
font-variant: small-caps
text-transform: none
.subscription-required, .course-membership-required
.subscription-required, .course-membership-required, .could-not-load
display: none
margin-top: -160px
color: black

View file

@ -1,13 +1,14 @@
.row
for contributor in contributors
.col-xs-6.col-md-3
.thumbnail
- var src = "/images/pages/contribute/" + contributorClassName + ".png";
- if(contributor.avatar)
- src = src.replace(contributorClassName, contributorClassName + "/" + contributor.avatar + "_small");
- if(contributor.id)
- src = "/db/user/" + contributor.id + "/avatar?s=100&fallback=" + src;
a(href=contributor.github ? "https://github.com/codecombat/codecombat/commits?author=" + contributor.github : null, class=contributor.github ? 'has-github' : '')
img.img-responsive(src=src, alt=contributor.name)
.caption
h4= contributor.name
if contributors
for contributor in contributors
.col-xs-6.col-md-3
.thumbnail
- var src = "/images/pages/contribute/" + contributorClassName + ".png";
- if(contributor.avatar)
- src = src.replace(contributorClassName, contributorClassName + "/" + contributor.avatar + "_small");
- if(contributor.id)
- src = "/db/user/" + contributor.id + "/avatar?s=100&fallback=" + src;
a(href=contributor.github ? "https://github.com/codecombat/codecombat/commits?author=" + contributor.github : null, class=contributor.github ? 'has-github' : '')
img.img-responsive(src=src, alt=contributor.name)
.caption
h4= contributor.name

View file

@ -1,16 +1,21 @@
- var league = view.options.league
.row
for team, teamIndex in teams
for team, teamIndex in view.teams
div.column.col-md-6
div(id="histogram-display-#{team.name}", class="histogram-display", data-team-name=team.name)
table.table.table-bordered.table-condensed.table-hover.ladder-table(data-team=team.id)
- var levelType = view.level.get('type', true)
- var topSessions = team.leaderboard.topPlayers.models;
- var showJustTop = team.leaderboard.inTopSessions() || me.get('anonymous');
- if(!showJustTop && topSessions.length == 20) topSessions = topSessions.slice(0, 10);
thead
tr
th(colspan=level.get('type', true) == 'hero-ladder' ? 3 : 2)
th(colspan=levelType == 'hero-ladder' ? 3 : 2)
th(colspan=4, style="color: #{team.primaryColor}")
span= team.displayName
span.spl(data-i18n="ladder.leaderboard") Leaderboard
tr
th(colspan=level.get('type', true) == 'hero-ladder' ? 3 : 2)
th(colspan=levelType == 'hero-ladder' ? 3 : 2)
th(data-i18n="general.score") Score
th(data-i18n="general.name").name-col-cell Name
th(data-i18n="general.when") When
@ -18,23 +23,20 @@
th.iconic-cell
.glyphicon.glyphicon-eye-open
tbody
- var topSessions = team.leaderboard.topPlayers.models;
- var showJustTop = team.leaderboard.inTopSessions() || me.get('anonymous');
- if(!showJustTop && topSessions.length == 20) topSessions = topSessions.slice(0, 10);
tbody
for session, rank in topSessions
- var myRow = session.get('creator') == me.id
- var sessionStats = league ? (_.find(session.get('leagues') || [], {leagueID: league.id}) || {}).stats || {} : session.attributes;
tr(class=myRow ? "success" : "", data-player-id=session.get('creator'), data-session-id=session.id)
td.code-language-cell(style="background-image: url(/images/common/code_languages/" + session.get('submittedCodeLanguage') + "_icon.png)" title=capitalize(session.get('submittedCodeLanguage')))
if level.get('type', true) == 'hero-ladder'
td.code-language-cell(style="background-image: url(/images/common/code_languages/" + session.get('submittedCodeLanguage') + "_icon.png)" title=view.capitalize(session.get('submittedCodeLanguage')))
if levelType == 'hero-ladder'
td.hero-portrait-cell(style="background-image: url(/file/db/thang.type/#{(session.get('heroConfig') || {}).thangType || '529ffbf1cf1818f2be000001'}/portrait.png)")
td.rank-cell= rank + 1
td.score-cell= Math.round((sessionStats.totalScore || session.get('totalScore') / 2) * 100)
td(class='name-col-cell' + ((new RegExp('(Simple|Shaman|Brawler|Chieftain|Thoktar) CPU')).test(session.get('creatorName')) ? ' ai' : ''))= session.get('creatorName') || "Anonymous"
td.age-cell= moment(session.get('submitDate')).fromNow().replace('a few ', '')
td.fight-cell
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
a(href="/play/level/#{view.level.get('slug') || view.level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
span(data-i18n="ladder.fight") Fight!
td.spectate-cell.iconic-cell
.glyphicon.glyphicon-eye-open
@ -47,14 +49,14 @@
- var sessionStats = league ? (_.find(session.get('leagues'), {leagueID: league.id}) || {}).stats || {} : session.attributes;
tr(class=myRow ? "success" : "", data-player-id=session.get('creator'), data-session-id=session.id)
td.code-language-cell(style="background-image: url(/images/common/code_languages/" + session.get('submittedCodeLanguage') + "_icon.png)")
if level.get('type', true) == 'hero-ladder'
if levelType == 'hero-ladder'
td.hero-portrait-cell(style="background-image: url(/file/db/thang.type/#{(session.get('heroConfig') || {}).thangType || '529ffbf1cf1818f2be000001'}/portrait.png)")
td.rank-cell= session.rank
td.score-cell= Math.round((sessionStats.totalScore || session.get('totalScore') / 2) * 100)
td(class='name-col-cell' + ((new RegExp('(Simple|Shaman|Brawler|Chieftain|Thoktar) CPU')).test(session.get('creatorName')) ? ' ai' : ''))= session.get('creatorName') || "Anonymous"
td.age-cell= moment(session.get('submitDate')).fromNow().replace('a few ', '')
td.fight-cell
a(href="/play/level/#{level.get('slug') || level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
a(href="/play/level/#{view.level.get('slug') || view.level.id}?team=#{team.otherTeam}&opponent=#{session.id}" + (league ? "&league=" + league.id : ""))
span(data-i18n="ladder.fight") Fight!
td.spectate-cell.iconic-cell
.glyphicon.glyphicon-eye-open
@ -77,8 +79,8 @@
if !onGPlus
button.btn.btn-sm.connect-google-plus(data-i18n="community.gplus") Google+
if friends.length
for friend in friends
if view.friends
for friend in view.friends
p.friend-entry
img(src=friend.imageSource).img-thumbnail
span= friend.creatorName + ' (' + friend.name + ')'
@ -87,7 +89,7 @@
span :
span= friend.team
br
a(href="/play/level/#{level.get('slug') || level.id}/?team=#{friend.otherTeam}&opponent=#{friend._id}" + (league ? "&league=" + league.id : ""))
a(href="/play/level/#{view.level.get('slug') || view.level.id}/?team=#{friend.otherTeam}&opponent=#{friend._id}" + (league ? "&league=" + league.id : ""))
span(data-i18n="ladder.fight") Fight!
else if onFacebook || onGPlus

View file

@ -9,81 +9,81 @@ block modal-body-content
h4.language-selection(data-i18n="ladder.select_your_language") Select your language!
.form-group.select-group
select#tome-language(name="language")
for option in languages
option(value=option.id selected=(language === option.id))= option.name
for option in view.languages
option(value=option.id selected=(view.language === option.id))= option.name
div#noob-view.secret
a(href="/play/level/#{levelID}-tutorial" + (league ? "?league=" + league.id : "")).btn.btn-success.btn-block.btn-lg
a(href="/play/level/#{view.levelID}-tutorial" + (view.options.league ? "?league=" + view.options.league.id : "")).btn.btn-success.btn-block.btn-lg
p
strong(data-i18n="ladder.tutorial_play") Play Tutorial
span(data-i18n="ladder.tutorial_recommended") Recommended if you've never played before
span.btn.btn-primary.btn-block.btn-lg#skip-tutorial-button(data-i18n="ladder.tutorial_skip") Skip Tutorial
div#normal-view
if tutorialLevelExists
if view.tutorialLevelExists
p.tutorial-suggestion
strong(data-i18n="ladder.tutorial_not_sure") Not sure what's going on?
|
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}" + (league ? "&league=" + league.id : ""))
a(href="/play/level/#{view.levelID}-tutorial" + (view.options.league ? "?league=" + view.options.league.id : ""), data-i18n="ladder.tutorial_play_first") Play the tutorial first.
a(href="/play/level/#{view.levelID}?team=#{view.team}" + (view.options.league ? "&league=" + view.options.league.id : ""))
div.play-option
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=genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/"+otherTeamID+"_ladder_tutorial.png", style="border: 1px solid #{opponentTeamColor}; background: #{opponentTeamBackgroundColor}").opponent-team-icon.img-circle
img(src=view.myPortrait).my-icon.only-one
img(src="/images/pages/play/ladder/#{view.team}_ladder_tutorial.png", style="border: 1px solid #{view.teamColor}; background: #{view.teamBackgroundColor}").my-team-icon.img-circle.only-one
img(src=view.genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/#{view.otherTeam}_ladder_tutorial.png", style="border: 1px solid #{view.opponentTeamColor}; background: #{view.opponentTeamBackgroundColor}").opponent-team-icon.img-circle
div.my-name.name-label.only-one
span= myName
span= view.myName
div.opponent-name.name-label
span(data-i18n="ladder.simple_ai")
//span.code-language(style="background-image: url(/images/common/code_languages/javascript_small.png)")
div.difficulty
span(data-i18n="ladder.warmup") Warmup
if challengers.easy
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.easy.sessionID}" + (league ? "&league=" + league.id : ""))
if view.challengers && view.challengers.easy
a(href="/play/level/#{view.levelID}?team=#{view.team}&opponent=#{view.challengers.easy.sessionID}" + (view.options.league ? "&league=" + view.options.league.id : ""))
div.play-option.easy-option
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=challengers.easy.opponentImageSource||genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/"+otherTeamID+"_ladder_easy.png", style="border: 1px solid #{opponentTeamColor}; background: #{opponentTeamBackgroundColor}").opponent-team-icon.img-circle
img(src=view.myPortrait).my-icon.only-one
img(src="/images/pages/play/ladder/#{view.team}_ladder_easy.png", style="border: 1px solid #{view.teamColor}; background: #{view.teamBackgroundColor}").my-team-icon.img-circle.only-one
img(src=view.challengers.easy.opponentImageSource||view.genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/#{view.otherTeam}_ladder_easy.png", style="border: 1px solid #{view.opponentTeamColor}; background: #{view.opponentTeamBackgroundColor}").opponent-team-icon.img-circle
div.my-name.name-label.only-one
span= myName
span= view.myName
div.opponent-name.name-label
span= challengers.easy.opponentName
if challengers.easy.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/" + challengers.easy.codeLanguage + "_small.png)")
span= view.challengers.easy.opponentName
if view.challengers.easy.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/#{view.challengers.easy.codeLanguage}_small.png)")
div.difficulty
span(data-i18n="general.easy") Easy
if challengers.medium
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.medium.sessionID}" + (league ? "&league=" + league.id : ""))
if view.challengers && view.challengers.medium
a(href="/play/level/#{view.levelID}?team=#{view.team}&opponent=#{view.challengers.medium.sessionID}" + (view.options.league ? "&league=" + view.options.league.id : ""))
div.play-option.medium-option
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=challengers.medium.opponentImageSource||genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/"+otherTeamID+"_ladder_medium.png", style="border: 1px solid #{opponentTeamColor}; background: #{opponentTeamBackgroundColor}").opponent-team-icon.img-circle
img(src=view.myPortrait).my-icon.only-one
img(src="/images/pages/play/ladder/#{view.team}_ladder_medium.png", style="border: 1px solid #{view.teamColor}; background: #{view.teamBackgroundColor}").my-team-icon.img-circle.only-one
img(src=view.challengers.medium.opponentImageSource||view.genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/#{view.otherTeam}_ladder_medium.png", style="border: 1px solid #{view.opponentTeamColor}; background: #{view.opponentTeamBackgroundColor}").opponent-team-icon.img-circle
div.my-name.name-label.only-one
span= myName
span= view.myName
div.opponent-name.name-label
span= challengers.medium.opponentName
if challengers.medium.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/" + challengers.medium.codeLanguage + "_small.png)")
span= view.challengers.medium.opponentName
if view.challengers.medium.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/#{view.challengers.medium.codeLanguage}_small.png)")
div.difficulty
span(data-i18n="general.medium") Medium
if challengers.hard
a(href="/play/level/#{levelID}?team=#{teamID}&opponent=#{challengers.hard.sessionID}" + (league ? "&league=" + league.id : ""))
if view.challengers && view.challengers.hard
a(href="/play/level/#{view.levelID}?team=#{view.team}&opponent=#{view.challengers.hard.sessionID}" + (view.options.league ? "&league=" + view.options.league.id : ""))
div.play-option.hard-option
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=challengers.hard.opponentImageSource||genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/"+otherTeamID+"_ladder_hard.png", style="border: 1px solid #{opponentTeamColor}; background: #{opponentTeamBackgroundColor}").opponent-team-icon.img-circle
img(src=view.myPortrait).my-icon.only-one
img(src="/images/pages/play/ladder/#{view.team}_ladder_hard.png", style="border: 1px solid #{view.teamColor}; background: #{view.teamBackgroundColor}").my-team-icon.img-circle.only-one
img(src=view.challengers.hard.opponentImageSource||view.genericPortrait).opponent-icon
img(src="/images/pages/play/ladder/#{view.otherTeam}_ladder_hard.png", style="border: 1px solid #{view.opponentTeamColor}; background: #{view.opponentTeamBackgroundColor}").opponent-team-icon.img-circle
div.my-name.name-label.only-one
span= myName
span= view.myName
div.opponent-name.name-label
span= challengers.hard.opponentName
if challengers.hard.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/" + challengers.hard.codeLanguage + "_small.png)")
span= view.challengers.hard.opponentName
if view.challengers.hard.codeLanguage
span.code-language(style="background-image: url(/images/common/code_languages/#{view.challengers.hard.codeLanguage}_small.png)")
div.difficulty
span(data-i18n="general.hard") Hard

View file

@ -25,6 +25,9 @@
.progress-bar.progress-bar-success
.rim
.could-not-load
span(data-i18n="loading_error.could_not_load") Error loading from server
.subscription-required
span(data-i18n="subscribe.subscription_required_to_play") You'll need a subscription to play this level.
button.start-subscription-button.btn.btn-lg.btn-warning(data-i18n="subscribe.subscribe") Subscribe

View file

@ -5,4 +5,6 @@ template = require 'templates/contribute/adventurer'
module.exports = class AdventurerView extends ContributeClassView
id: 'adventurer-view'
template: template
contributorClassName: 'adventurer'
initialize: ->
@contributorClassName = 'adventurer'

View file

@ -5,4 +5,6 @@ template = require 'templates/contribute/ambassador'
module.exports = class AmbassadorView extends ContributeClassView
id: 'ambassador-view'
template: template
contributorClassName: 'ambassador'
initialize: ->
@contributorClassName = 'ambassador'

View file

@ -4,7 +4,9 @@ template = require 'templates/contribute/archmage'
module.exports = class ArchmageView extends ContributeClassView
id: 'archmage-view'
template: template
contributorClassName: 'archmage'
initialize: ->
@contributorClassName = 'archmage'
contributors: [
{id: '547acbb2af18b03c0563fdb3', name: 'David Liu', github: 'trotod'}

View file

@ -5,7 +5,9 @@ template = require 'templates/contribute/artisan'
module.exports = class ArtisanView extends ContributeClassView
id: 'artisan-view'
template: template
contributorClassName: 'artisan'
initialize: ->
@contributorClassName = 'artisan'
contributors: [
{id: '5276ad5dcf83207a2801d3b4', name: 'Zach Martin', github: 'zachster01'}

View file

@ -6,17 +6,10 @@ contributorSignupTemplate = require 'templates/contribute/contributor_signup'
contributorListTemplate = require 'templates/contribute/contributor_list'
module.exports = class ContributeClassView extends RootView
navPrefix: '/contribute'
events:
'change input[type="checkbox"]': 'onCheckboxChanged'
getRenderData: ->
c = super()
c.navPrefix = @navPrefix
c.contributors = @contributors
c
afterRender: ->
super()
@$el.find('.contributor-signup-anonymous').replaceWith(contributorSignupAnonymousTemplate(me: me))
@ -39,5 +32,3 @@ module.exports = class ContributeClassView extends RootView
me.patch()
@openModalView new CreateAccountModal() if me.get 'anonymous'
el.parent().find('.saved-notification').finish().show('fast').delay(3000).fadeOut(2000)
contributors: []

View file

@ -60,7 +60,9 @@ require("locale/et")
module.exports = class DiplomatView extends ContributeClassView
id: 'diplomat-view'
template: template
contributorClassName: 'diplomat'
initialize: ->
@contributorClassName = 'diplomat'
calculateSpokenLanguageStats: ->
@locale ?= require 'locale/locale'

View file

@ -4,7 +4,6 @@ template = require 'templates/contribute/contribute'
module.exports = class MainContributeView extends ContributeClassView
id: 'contribute-view'
template: template
navPrefix: ''
events:
'change input[type="checkbox"]': 'onCheckboxChanged'

View file

@ -5,7 +5,9 @@ template = require 'templates/contribute/scribe'
module.exports = class ScribeView extends ContributeClassView
id: 'scribe-view'
template: template
contributorClassName: 'scribe'
initialize: ->
@contributorClassName = 'scribe'
contributors: [
{name: 'Ryan Faidley'}

View file

@ -24,12 +24,27 @@ module.exports = class LadderPlayModal extends ModalView
behaviors: false
liveCompletion: true
constructor: (options, @level, @session, @team) ->
super(options)
@nameMap = {}
initialize: (options, @level, @session, @team) ->
@otherTeam = if @team is 'ogres' then 'humans' else 'ogres'
@startLoadingChallengersMaybe()
@wizardType = ThangType.loadUniversalWizard()
@levelID = @level.get('slug') or @level.id
@language = @session?.get('codeLanguage') ? me.get('aceConfig')?.language ? 'python'
@languages = [
{id: 'python', name: 'Python'}
{id: 'javascript', name: 'JavaScript'}
{id: 'coffeescript', name: 'CoffeeScript (Experimental)'}
{id: 'lua', name: 'Lua'}
{id: 'java', name: 'Java'}
]
@myName = me.get('name') || 'Newcomer'
teams = []
teams[t.id] = t for t in teamDataFromLevel @level
@teamColor = teams[@team].primaryColor
@teamBackgroundColor = teams[@team].bgColor
@opponentTeamColor = teams[@otherTeam].primaryColor
@opponentTeamBackgroundColor = teams[@otherTeam].bgColor
updateLanguage: ->
aceConfig = _.cloneDeep me.get('aceConfig') ? {}
@ -59,6 +74,12 @@ module.exports = class LadderPlayModal extends ModalView
@challengers = @getChallengers()
ids = (challenger.opponentID for challenger in _.values @challengers)
for challenger in _.values @challengers
continue unless challenger and @wizardType.loaded
if (not challenger.opponentImageSource) and challenger.opponentWizard?.colorConfig
challenger.opponentImageSource = @wizardType.getPortraitSource(
{colorConfig: challenger.opponentWizard.colorConfig})
success = (@nameMap) =>
for challenger in _.values(@challengers)
challenger.opponentName = @nameMap[challenger.opponentID]?.name or 'Anonymous'
@ -86,46 +107,9 @@ module.exports = class LadderPlayModal extends ModalView
@tutorialLevelExists = exists
@render()
@maybeShowTutorialButtons()
getRenderData: ->
ctx = super()
ctx.level = @level
ctx.levelID = @level.get('slug') or @level.id
ctx.teamName = _.string.titleize @team
ctx.teamID = @team
ctx.otherTeamID = @otherTeam
ctx.tutorialLevelExists = @tutorialLevelExists
ctx.language = @session?.get('codeLanguage') ? me.get('aceConfig')?.language ? 'python'
ctx.languages = [
{id: 'python', name: 'Python'}
{id: 'javascript', name: 'JavaScript'}
{id: 'coffeescript', name: 'CoffeeScript (Experimental)'}
{id: 'lua', name: 'Lua'}
{id: 'java', name: 'Java'}
]
ctx.league = @options.league
teamsList = teamDataFromLevel @level
teams = {}
teams[team.id] = team for team in teamsList
ctx.teamColor = teams[@team].primaryColor
ctx.teamBackgroundColor = teams[@team].bgColor
ctx.opponentTeamColor = teams[@otherTeam].primaryColor
ctx.opponentTeamBackgroundColor = teams[@otherTeam].bgColor
ctx.challengers = @challengers or {}
for challenger in _.values ctx.challengers
continue unless challenger and @wizardType.loaded
if (not challenger.opponentImageSource) and challenger.opponentWizard?.colorConfig
challenger.opponentImageSource = @wizardType.getPortraitSource(
{colorConfig: challenger.opponentWizard.colorConfig})
if @wizardType.loaded
ctx.genericPortrait = @wizardType.getPortraitSource()
myColorConfig = me.get('wizard')?.colorConfig
ctx.myPortrait = if myColorConfig then @wizardType.getPortraitSource({colorConfig: myColorConfig}) else ctx.genericPortrait
ctx.myName = me.get('name') || 'Newcomer'
ctx
@genericPortrait = @wizardType.getPortraitSource()
myColorConfig = me.get('wizard')?.colorConfig
@myPortrait = if myColorConfig then @wizardType.getPortraitSource({colorConfig: myColorConfig}) else @genericPortrait
maybeShowTutorialButtons: ->
return if @session or LadderPlayModal.shownTutorialButton or not @tutorialLevelExists

View file

@ -29,11 +29,13 @@ module.exports = class LadderTabView extends CocoView
# 'auth:logged-in-with-facebook': 'onConnectedWithFacebook'
# 'auth:logged-in-with-gplus': 'onConnectedWithGPlus'
constructor: (options, @level, @sessions) ->
super(options)
initialize: (options, @level, @sessions) ->
@teams = teamDataFromLevel @level
@leaderboards = {}
@leaderboards = []
@refreshLadder()
@capitalize = _.string.capitalize
# Trying not loading the FP/G+ stuff for now to see if anyone complains they were using it so we can have just two columns.
#@socialNetworkRes = @supermodel.addSomethingResource('social_network_apis', 0)
#@checkFriends()
@ -51,7 +53,8 @@ module.exports = class LadderTabView extends CocoView
FB.getLoginStatus (response) =>
return if @destroyed
@facebookStatus = response.status
@loadFacebookFriends() if @facebookStatus is 'connected'
@onFacebook = view.facebookStatus is 'connected'
@loadFacebookFriends() if @onFacebook
@fbStatusRes.markLoaded()
if application.gplusHandler.loggedIn is undefined
@ -102,6 +105,7 @@ module.exports = class LadderTabView extends CocoView
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture"
@facebookFriendSessions = result
@friends = @consolidateFriends()
@render() # because the ladder tab renders before waiting for fb to finish
# GOOGLE PLUS
@ -115,6 +119,7 @@ module.exports = class LadderTabView extends CocoView
gplusSessionStateLoaded: ->
if application.gplusHandler.loggedIn
@onGPlus = true
#@addSomethingToLoad('gplus_friends')
@gpFriendRes = @supermodel.addSomethingResource('gplus_friends', 0)
@gpFriendRes.load()
@ -145,6 +150,7 @@ module.exports = class LadderTabView extends CocoView
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
friend.imageSource = friendsMap[friend.gplusID].image.url
@gplusFriendSessions = result
@friends = @consolidateFriends()
@render() # because the ladder tab renders before waiting for gplus to finish
# LADDER LOADING
@ -161,6 +167,7 @@ module.exports = class LadderTabView extends CocoView
oldLeaderboard.destroy()
teamSession = _.find @sessions.models, (session) -> session.get('team') is team.id
@leaderboards[team.id] = new LeaderboardData(@level, team.id, teamSession, @ladderLimit, @options.league)
team.leaderboard = @leaderboards[team.id]
@leaderboardRes = @supermodel.addModelResource(@leaderboards[team.id], 'leaderboard', {cache: false}, 3)
@leaderboardRes.load()
@ -179,22 +186,6 @@ module.exports = class LadderTabView extends CocoView
).then =>
@generateHistogram(histogramWrapper, histogramData, team.name.toLowerCase()) unless @destroyed
getRenderData: ->
ctx = super()
ctx.level = @level
ctx.link = "/play/level/#{@level.get('name')}"
ctx.teams = @teams
team.leaderboard = @leaderboards[team.id] for team in @teams
ctx.levelID = @levelID
ctx.friends = @consolidateFriends()
ctx.onFacebook = @facebookStatus is 'connected'
ctx.onGPlus = application.gplusHandler.loggedIn
ctx.capitalize = _.string.capitalize
ctx.league = @options.league
ctx._ = _
ctx.moment = moment
ctx
generateHistogram: (histogramElement, histogramData, teamName) ->
#renders twice, hack fix
if $('#' + histogramElement.attr('id')).has('svg').length then return

View file

@ -43,6 +43,7 @@ module.exports = class LadderView extends RootView
@level = @supermodel.loadModel(new Level(_id: @levelID)).model
@level.once 'sync', =>
@levelDescription = marked(@level.get('description')) if @level.get('description')
@teams = teamDataFromLevel @level
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(@levelID), 'your_sessions', {cache: false}).model
@winners = require('./tournament_results')[@levelID]
@ -70,10 +71,6 @@ module.exports = class LadderView extends RootView
@course = @supermodel.loadModel(course).model
@listenToOnce @course, 'sync', @render
onLoaded: ->
@teams = teamDataFromLevel @level
super()
afterRender: ->
super()
return unless @supermodel.finished()

View file

@ -204,6 +204,10 @@ module.exports = class LevelLoadingView extends CocoView
@$el.find('.level-loading-goals, .tip, .load-progress').hide()
@$el.find('.course-membership-required').show()
onLoadError: (resource) ->
@$el.find('.level-loading-goals, .tip, .load-progress').hide()
@$el.find('.could-not-load').show()
onClickStartSubscription: (e) ->
@openModalView new SubscribeModal()
levelSlug = @level?.get('slug') or @options.level?.get('slug')

View file

@ -141,6 +141,7 @@ module.exports = class PlayLevelView extends RootView
levelLoaderOptions.fakeSessionConfig = {}
@levelLoader = new LevelLoader levelLoaderOptions
@listenToOnce @levelLoader, 'world-necessities-loaded', @onWorldNecessitiesLoaded
@listenTo @levelLoader, 'world-necessity-load-failed', @onWorldNecessityLoadFailed
trackLevelLoadEnd: ->
return if @isEditorPreview
@ -195,6 +196,9 @@ module.exports = class PlayLevelView extends RootView
@controlBar.setBus(@bus)
@initScriptManager()
onWorldNecessityLoadFailed: (resource) ->
@loadingView.onLoadError(resource)
grabLevelLoaderData: ->
@session = @levelLoader.session
@world = @levelLoader.world