Implemented singleplayer and multiplayer games played on profile

This commit is contained in:
Ruben Vereecken 2014-07-29 20:11:45 +02:00
parent 30a6cf1cca
commit d4043ac3db
5 changed files with 66 additions and 25 deletions

View file

@ -37,4 +37,8 @@ module.exports = class LevelSession extends CocoModel
return true if c1[thang][spell] isnt c2[thang]?[spell] return true if c1[thang][spell] isnt c2[thang]?[spell]
false false
isMultiPlayer: -> @get('team')? # Only multiplayer level sessions have teams defined isMultiPlayer: ->
console.log @get 'levelName'
console.log @
console.log @get 'team'
@get('team')? # Only multiplayer level sessions have teams defined

View file

@ -21,10 +21,17 @@
background-color: #ffe4bc background-color: #ffe4bc
border: 4px solid white border: 4px solid white
> .name > .profile-info
background: white
.extra-info
padding-bottom: 3px
&:empty
display: none
.name
margin: 0px auto margin: 0px auto
padding: 10px inherit padding: 10px inherit
background: white
color: white color: white
text-shadow: 2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000, 1px 1px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000 text-shadow: 2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000, 1px 1px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000

View file

@ -110,8 +110,9 @@ block content
td td
a(href="/play/level/#{session.get('levelID')}")= session.get('levelName') a(href="/play/level/#{session.get('levelID')}")= session.get('levelName')
td= moment(session.get('changed')).fromNow() td= moment(session.get('changed')).fromNow()
td
if session.get('state').complete === true if session.get('state').complete === true
td Completed | Completed
else else
.panel.panel-default .panel.panel-default
.panel-body .panel-body

View file

@ -7,10 +7,11 @@ block append content
.left-column .left-column
.profile-wrapper .profile-wrapper
img.picture(src="#{me.getPhotoURL(150)}" alt="") img.picture(src="#{me.getPhotoURL(150)}" alt="")
div.profile-info
h3.name= user.get('name') h3.name= user.get('name')
if favoriteLanguage if favoriteLanguage
div.profile-info Favorite language is div.extra-info Favorite language is
span= favoriteLanguage strong.spl.spr= favoriteLanguage
.btn-group-vertical.profile-menu .btn-group-vertical.profile-menu
a.btn.btn-default(href="/user/#{user.get('slug') || user.get('_id')}/profile") a.btn.btn-default(href="/user/#{user.get('slug') || user.get('_id')}/profile")
i.glyphicon.glyphicon-briefcase i.glyphicon.glyphicon-briefcase
@ -57,9 +58,9 @@ block append content
.panel-body .panel-body
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
h3.panel-title S. Levels h3.panel-title Singleplayer Levels
.panel-body
if (!singlePlayerSessions) if (!singlePlayerSessions)
.panel-body
p Loading... p Loading...
else if (singlePlayerSessions.length) else if (singlePlayerSessions.length)
table.table table.table
@ -67,10 +68,39 @@ block append content
th Level th Level
th Last Played th Last Played
th Status th Status
each session in singlePlayerSessions
//each session in singlePlayerSessions tr
td
if session.get('levelName')
a(href="/play/level/#{session.get('levelID')}")= session.get('levelName')
td= moment(session.get('changed')).fromNow()
if session.get('state').complete === true
td Completed
else
td Unfinished
else
.panel-body
p No Singleplayer games played yet.
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
h3.panel-title M. Levels h3.panel-title Multiplayer Levels
if (!multiPlayerSessions)
.panel-body .panel-body
p Loading...
else if (multiPlayerSessions.length)
table.table
tr
th Level
th Team
th Last Played
each session in multiPlayerSessions
tr
td
a(href="/play/level/#{session.get('levelID')}")= session.get('levelName')
td= session.get('team')
td= moment(session.get('changed')).fromNow()
if session.get('state').complete === true
td Completed
else
.panel-body
p No Multiplayer games played yet.

View file

@ -8,7 +8,7 @@ class LevelSessionsCollection extends CocoCollection
model: LevelSession model: LevelSession
constructor: (userID) -> constructor: (userID) ->
@url = "/db/user/#{userID}/level.sessions?project=state.complete,levelID,levelName,changed,submittedCodeLanguage&order=-1" @url = "/db/user/#{userID}/level.sessions?project=state.complete,levelID,levelName,changed,team,submittedCodeLanguage&order=-1"
super() super()
module.exports = class MainUserView extends UserView module.exports = class MainUserView extends UserView
@ -35,11 +35,10 @@ module.exports = class MainUserView extends UserView
for language, count of languageCounts for language, count of languageCounts
if count > mostUsedCount if count > mostUsedCount
mostUsedCount = count mostUsedCount = count
language = favoriteLanguage favoriteLanguage = language
context.favoriteLanguage = favoriteLanguage
context.singlePlayerSessions = singlePlayerSessions context.singlePlayerSessions = singlePlayerSessions
context.multiPlayerSessions = multiPlayerSessions context.multiPlayerSessions = multiPlayerSessions
console.debug context context.favoriteLanguage = favoriteLanguage
context context
onUserLoaded: (user) -> onUserLoaded: (user) ->