codecombat/app/templates/game-menu/multiplayer-view.jade
Matt Lott 68cca74b43 Real-time multiplayer initial commit
Simple matchmaking, synchronous multiplayer PVP, flags!

Rough matchmaking is under the game menu multiplayer tab, for ladder
games only.  After creating a 2-person game there, you can exit that
modal and real-time cast to play against each other.

If you’re the first person to cast, you’ll sit at the real-time level
playback view waiting until the other player casts.  When they do, you
both should start the real-time playback (and start placing flags like
crazy people).

If in a multiplayer session, the real-time simulation runs the players’
code against each other.  Your multiplayer opponent’s name should be up
near the level name.

Multiplayer sessions are stored completely in Firebase for now, and
removed if both players leave the game.  There’s plenty of bugs,
synchronization issues, and minimal polish to add before we push it to
master.
2014-08-28 23:34:07 -07:00

89 lines
3.5 KiB
Text

if !ladderGame
.form
.form-group.checkbox
label(for="multiplayer")
input#multiplayer(name="multiplayer", type="checkbox", checked=multiplayer)
span(data-i18n="multiplayer.multiplayer_toggle") Enable multiplayer
span.help-block(data-i18n="multiplayer.multiplayer_toggle_description") Allow others to join your game.
hr
div#link-area
p(data-i18n="multiplayer.multiplayer_link_description") Give this link to anyone to have them join you.
textarea.well#multiplayer-join-link(readonly=true)= joinLink
p
strong(data-i18n="multiplayer.multiplayer_hint_label") Hint:
span(data-i18n="multiplayer.multiplayer_hint") Click the link to select all, then press ⌘-C or Ctrl-C to copy the link.
p(data-i18n="multiplayer.multiplayer_coming_soon") More multiplayer features to come!
if ladderGame
if me.get('anonymous')
p(data-i18n="multiplayer.multiplayer_sign_in_leaderboard") Sign in or create an account and get your solution on the leaderboard.
else if readyToRank
button#create-game-button Create Game
hr
div#created-multiplayer-session
h3 Your Game
if currentMultiplayerSession
div
span(style="margin:10px")= currentMultiplayerSession.get('levelID')
span(style="margin:10px")= currentMultiplayerSession.get('creatorName')
span(style="margin:10px")= currentMultiplayerSession.get('state')
span(style="margin:10px")= currentMultiplayerSession.id
button#leave-game-button(data-item=item) Leave Game
div
- var players = playersCollections[currentMultiplayerSession.id]
span(style="margin:10px") Players:
- for (var i=0; i < players.length; i++) {
- var name = players.at(i).get('name')
- var team = players.at(i).get('team')
span(style="margin:10px")= name
span(style="margin:10px")= team
- }
else
div Click something above to create a game.
hr
div#open-games
h3 Open Games
- var noOpenGames = true
if multiplayerSessions
- for (var i=0; i < multiplayerSessions.length; i++) {
if levelID === multiplayerSessions[i].get('levelID') && multiplayerSessions[i].get('state') === 'creating'
- var id = multiplayerSessions[i].get('id')
- var players = playersCollections[id]
if players && players.length < 2
- noOpenGames = false
- var creatorName = multiplayerSessions[i].get('creatorName')
- var creator = multiplayerSessions[i].get('creator')
- var state = multiplayerSessions[i].get('state')
- var item = multiplayerSessions[i]
div
button#join-game-button(data-item=item) Join Game
span(style="margin:10px")= levelID
span(style="margin:10px")= creatorName
span(style="margin:10px")= state
span(style="margin:10px")= id
div
span(style="margin:10px") Players:
- for (var j=0; j < players.length; j++) {
- var name = players.at(j).get('name')
- var team = players.at(j).get('team')
span(style="margin:10px")= name
span(style="margin:10px")= team
- }
- }
if noOpenGames
div No games available.
hr
.ladder-submission-view
else
a.btn.btn-primary(href="/play/ladder/#{levelSlug}#my-matches", data-i18n="multiplayer.victory_go_ladder") Return to Ladder