mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
parent
c191f63c15
commit
c1f1b4a048
2 changed files with 68 additions and 84 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue