mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Moved views/play/ladder_view to views/play/ladder/ladder_view and made a new views/play/ladder_home_view.
This commit is contained in:
parent
179702b0eb
commit
68a4483e91
12 changed files with 166 additions and 26 deletions
|
@ -17,7 +17,8 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
'editor/:model(/:slug_or_id)(/:subview)': 'editorModelView'
|
||||
|
||||
# Experimenting with direct links
|
||||
# 'play/ladder/:levelID/team/:team': go('play/ladder/team_view')
|
||||
'play/ladder/:levelID': go('play/ladder/ladder_view')
|
||||
'play/ladder': go('play/ladder_home')
|
||||
|
||||
# db and file urls call the server directly
|
||||
'db/*path': 'routeToServer'
|
||||
|
|
|
@ -214,7 +214,6 @@
|
|||
candidate_active: "Them?"
|
||||
|
||||
play_level:
|
||||
level_load_error: "Level could not be loaded: "
|
||||
done: "Done"
|
||||
grid: "Grid"
|
||||
customize_wizard: "Customize Wizard"
|
||||
|
|
|
@ -46,6 +46,3 @@
|
|||
color: black
|
||||
text-shadow: 0 1px 0 white
|
||||
|
||||
.alert-warning h2
|
||||
color: black
|
||||
text-align: center
|
||||
|
|
54
app/styles/play/ladder_home.sass
Normal file
54
app/styles/play/ladder_home.sass
Normal file
|
@ -0,0 +1,54 @@
|
|||
@import "app/styles/bootstrap/mixins"
|
||||
@import "app/styles/bootstrap/variables"
|
||||
|
||||
#ladder-home-view
|
||||
.level
|
||||
width: 100%
|
||||
position: relative
|
||||
margin-bottom: 20px
|
||||
text-shadow: 2px 2px 5px black
|
||||
|
||||
&:hover div
|
||||
color: lighten($yellow, 20%)
|
||||
|
||||
&:hover img
|
||||
filter: brightness(1.2)
|
||||
-webkit-filter: brightness(1.2)
|
||||
box-shadow: 0 0 5px black
|
||||
|
||||
.level-image
|
||||
width: 100%
|
||||
|
||||
.overlay-text
|
||||
color: $yellow
|
||||
font-family: Bangers
|
||||
@include transition(color .10s linear)
|
||||
|
||||
.level-difficulty
|
||||
position: absolute
|
||||
left: 0px
|
||||
bottom: 0px
|
||||
font-size: 25px
|
||||
padding-right: 10px
|
||||
background-color: rgba(255, 255, 255, 0.75)
|
||||
border-radius: 6px
|
||||
|
||||
.play-text-container
|
||||
position: absolute
|
||||
left: 50%
|
||||
bottom: -10px
|
||||
|
||||
.play-text
|
||||
margin-left: -50%
|
||||
font-size: 50px
|
||||
|
||||
a[disabled] .level
|
||||
opacity: 0.7
|
||||
|
||||
a.complete .level-difficulty:after
|
||||
content: " - Complete!"
|
||||
color: $yellow
|
||||
|
||||
a.started .level-difficulty:after
|
||||
content: " - Started"
|
||||
color: desaturate($yellow, 50%)
|
|
@ -50,7 +50,7 @@ block content
|
|||
h4(data-i18n="home.for_beginners") For Beginners
|
||||
.play-text(data-i18n="home.play") Play
|
||||
|
||||
a#multiplayer(href="/play/ladder/dungeon-arena")
|
||||
a#multiplayer(href="/play/ladder")
|
||||
div.game-mode-wrapper
|
||||
if isEnglish
|
||||
img(src="/images/pages/home/multiplayer.jpg").img-rounded
|
||||
|
|
|
@ -2,12 +2,6 @@ extends /templates/base
|
|||
|
||||
block content
|
||||
|
||||
if notFound
|
||||
div(class="alert alert-warning")
|
||||
h2
|
||||
span(data-i18n="play_level.level_load_error") Level could not be loaded:
|
||||
| #{notFound}
|
||||
|
||||
h1(data-i18n="play.choose_your_level") Choose Your Level
|
||||
p
|
||||
span(data-i18n="play.adventurer_prefix") You can jump to any level below, or discuss the levels on
|
||||
|
|
23
app/templates/play/ladder_home.jade
Normal file
23
app/templates/play/ladder_home.jade
Normal file
|
@ -0,0 +1,23 @@
|
|||
extends /templates/base
|
||||
|
||||
block content
|
||||
|
||||
each campaign in campaigns
|
||||
.campaign-container
|
||||
h1
|
||||
a(href="/play/#{campaign.levels[0].levelPath || 'level'}/#{campaign.levels[0].id}", data-i18n="play.campaign_#{campaign.id}")= campaign.name
|
||||
p.campaign-description(data-i18n="[html]play.campaign_#{campaign.id}_description")!= campaign.description
|
||||
each level in campaign.levels
|
||||
a(href=level.disabled ? "/play/ladder" : "/play/ladder/#{level.id}", disabled=level.disabled, class=levelStatusMap[level.id] || '', title=level.description)
|
||||
.level
|
||||
if level.image
|
||||
img.level-image(src="#{level.image}", alt="#{level.name}").img-rounded
|
||||
else
|
||||
img.level-image(src="/images/pages/home/multiplayer_notext.jpg", alt="#{level.name}").img-rounded
|
||||
//h3= level.name + (level.disabled ? " (Coming soon!)" : "")
|
||||
.overlay-text.level-difficulty
|
||||
span(data-i18n="play.level_difficulty") Difficulty:
|
||||
each i in Array(level.difficulty)
|
||||
| ★
|
||||
.play-text-container
|
||||
.overlay-text.play-text(data-i18n="home.play") Play
|
|
@ -2,14 +2,14 @@ RootView = require 'views/kinds/RootView'
|
|||
Level = require 'models/Level'
|
||||
LevelSession = require 'models/LevelSession'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
{teamDataFromLevel} = require './ladder/utils'
|
||||
{teamDataFromLevel} = require './utils'
|
||||
{me} = require 'lib/auth'
|
||||
application = require 'application'
|
||||
|
||||
LadderTabView = require './ladder/ladder_tab'
|
||||
MyMatchesTabView = require './ladder/my_matches_tab'
|
||||
SimulateTabView = require './ladder/simulate_tab'
|
||||
LadderPlayModal = require './ladder/play_modal'
|
||||
LadderTabView = require './ladder_tab'
|
||||
MyMatchesTabView = require './my_matches_tab'
|
||||
SimulateTabView = require './simulate_tab'
|
||||
LadderPlayModal = require './play_modal'
|
||||
CocoClass = require 'lib/CocoClass'
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ class LevelSessionsCollection extends CocoCollection
|
|||
|
||||
module.exports = class LadderView extends RootView
|
||||
id: 'ladder-view'
|
||||
template: require 'templates/play/ladder'
|
||||
template: require 'templates/play/ladder/ladder'
|
||||
|
||||
subscriptions:
|
||||
'application:idle-changed': 'onIdleChanged'
|
72
app/views/play/ladder_home.coffee
Normal file
72
app/views/play/ladder_home.coffee
Normal file
|
@ -0,0 +1,72 @@
|
|||
View = require 'views/kinds/RootView'
|
||||
template = require 'templates/play/ladder_home'
|
||||
LevelSession = require 'models/LevelSession'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
|
||||
class LevelSessionsCollection extends CocoCollection
|
||||
url: ''
|
||||
model: LevelSession
|
||||
|
||||
constructor: (model) ->
|
||||
super()
|
||||
@url = "/db/user/#{me.id}/level.sessions?project=state.complete,levelID"
|
||||
|
||||
module.exports = class LadderHomeView extends View
|
||||
id: "ladder-home-view"
|
||||
template: template
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@levelStatusMap = {}
|
||||
@sessions = new LevelSessionsCollection()
|
||||
@sessions.fetch()
|
||||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
|
||||
onSessionsLoaded: (e) ->
|
||||
for session in @sessions.models
|
||||
@levelStatusMap[session.get('levelID')] = if session.get('state')?.complete then 'complete' else 'started'
|
||||
@render()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
arenas = [
|
||||
{
|
||||
name: 'Greed'
|
||||
difficulty: 4
|
||||
id: 'greed'
|
||||
image: '/file/db/level/53558b5a9914f5a90d7ccddb/greed_banner.jpg'
|
||||
description: "Liked Dungeon Arena and Gold Rush? Put them together in this economic arena!"
|
||||
}
|
||||
{
|
||||
name: 'Dungeon Arena'
|
||||
difficulty: 3
|
||||
id: 'dungeon-arena'
|
||||
image: '/file/db/level/53173f76c269d400000543c2/Level%20Banner%20Dungeon%20Arena.jpg'
|
||||
description: "Play head-to-head against fellow Wizards in a dungeon melee!"
|
||||
}
|
||||
{
|
||||
name: 'Gold Rush'
|
||||
difficulty: 3
|
||||
id: 'gold-rush'
|
||||
image: '/file/db/level/533353722a61b7ca6832840c/Gold-Rush.png'
|
||||
description: "Prove you are better at collecting gold than your opponent!"
|
||||
}
|
||||
{
|
||||
name: 'Brawlwood'
|
||||
difficulty: 4
|
||||
id: 'brawlwood'
|
||||
image: '/file/db/level/52d97ecd32362bc86e004e87/Level%20Banner%20Brawlwood.jpg'
|
||||
description: "Combat the armies of other Wizards in a strategic forest arena! (Fast computer required.)"
|
||||
}
|
||||
]
|
||||
|
||||
context.campaigns = [
|
||||
{id: "multiplayer", name: "Multiplayer Arenas", description: "... in which you code head-to-head against other players.", levels: arenas}
|
||||
]
|
||||
context.levelStatusMap = @levelStatusMap
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
@$el.find('.modal').on 'shown.bs.modal', ->
|
||||
$('input:visible:first', @).focus()
|
|
@ -143,6 +143,14 @@ module.exports = class PlayView extends View
|
|||
]
|
||||
|
||||
arenas = [
|
||||
{
|
||||
name: 'Greed'
|
||||
difficulty: 4
|
||||
id: 'greed'
|
||||
image: '/file/db/level/526fd3043c637ece50001bb2/the_herd_icon.png'
|
||||
description: "Liked Dungeon Arena and Gold Rush? Put them together in this economic arena!"
|
||||
levelPath: 'ladder'
|
||||
}
|
||||
{
|
||||
name: 'Dungeon Arena'
|
||||
difficulty: 3
|
||||
|
@ -159,14 +167,6 @@ module.exports = class PlayView extends View
|
|||
description: "Prove you are better at collecting gold than your opponent!"
|
||||
levelPath: 'ladder'
|
||||
}
|
||||
{
|
||||
name: 'Greed'
|
||||
difficulty: 4
|
||||
id: 'greed'
|
||||
image: '/file/db/level/526fd3043c637ece50001bb2/the_herd_icon.png'
|
||||
description: "Liked Dungeon Arena and Gold Rush? Put them together in this economic arena!"
|
||||
levelPath: 'ladder'
|
||||
}
|
||||
{
|
||||
name: 'Brawlwood'
|
||||
difficulty: 4
|
||||
|
|
Loading…
Reference in a new issue