2014-08-08 14:36:41 -04:00
|
|
|
CocoView = require 'views/kinds/CocoView'
|
|
|
|
template = require 'templates/game-menu/multiplayer-view'
|
|
|
|
{me} = require 'lib/auth'
|
|
|
|
ThangType = require 'models/ThangType'
|
2014-08-10 20:26:30 -04:00
|
|
|
LadderSubmissionView = require 'views/play/common/LadderSubmissionView'
|
2014-10-31 19:33:43 -04:00
|
|
|
RealTimeModel = require 'models/RealTimeModel'
|
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-29 02:34:07 -04:00
|
|
|
RealTimeCollection = require 'collections/RealTimeCollection'
|
2014-08-08 14:36:41 -04:00
|
|
|
|
|
|
|
module.exports = class MultiplayerView extends CocoView
|
|
|
|
id: 'multiplayer-view'
|
|
|
|
className: 'tab-pane'
|
|
|
|
template: template
|
|
|
|
|
2014-08-10 20:26:30 -04:00
|
|
|
subscriptions:
|
|
|
|
'ladder:game-submitted': 'onGameSubmitted'
|
|
|
|
|
|
|
|
events:
|
|
|
|
'click textarea': 'onClickLink'
|
|
|
|
'change #multiplayer': 'updateLinkSection'
|
2014-10-31 19:33:43 -04:00
|
|
|
'click #create-game-button': 'onCreateRealTimeGame'
|
|
|
|
'click #join-game-button': 'onJoinRealTimeGame'
|
|
|
|
'click #leave-game-button': 'onLeaveRealTimeGame'
|
2014-08-10 20:26:30 -04:00
|
|
|
|
|
|
|
constructor: (options) ->
|
|
|
|
super(options)
|
|
|
|
@level = options.level
|
|
|
|
@session = options.session
|
|
|
|
@listenTo @session, 'change:multiplayer', @updateLinkSection
|
2014-11-17 18:07:10 -05:00
|
|
|
@watchRealTimeSessions() if @level?.get('type') in ['hero-ladder']
|
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-29 02:34:07 -04:00
|
|
|
|
|
|
|
destroy: ->
|
2014-10-31 19:33:43 -04:00
|
|
|
@realTimeSessions?.off 'add', @onRealTimeSessionAdded
|
|
|
|
@currentRealTimeSession?.off 'change', @onCurrentRealTimeSessionChanged
|
|
|
|
collection.off() for id, collection of @realTimeSessionsPlayers
|
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-29 02:34:07 -04:00
|
|
|
super()
|
|
|
|
|
2014-08-10 20:26:30 -04:00
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
c.joinLink = "#{document.location.href.replace(/\?.*/, '').replace('#', '')}?session=#{@session.id}"
|
|
|
|
c.multiplayer = @session.get 'multiplayer'
|
|
|
|
c.team = @session.get 'team'
|
|
|
|
c.levelSlug = @level?.get 'slug'
|
|
|
|
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
|
2014-10-18 17:51:43 -04:00
|
|
|
if @level?.get('type') in ['ladder', 'hero-ladder']
|
2014-08-10 20:26:30 -04:00
|
|
|
c.ladderGame = true
|
|
|
|
c.readyToRank = @session?.readyToRank()
|
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-29 02:34:07 -04:00
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
# Real-time multiplayer stuff
|
2014-11-17 18:07:10 -05:00
|
|
|
if @level?.get('type') in ['hero-ladder']
|
|
|
|
c.levelID = @session.get('levelID')
|
|
|
|
c.realTimeSessions = @realTimeSessions
|
|
|
|
c.currentRealTimeSession = @currentRealTimeSession if @currentRealTimeSession
|
|
|
|
c.realTimeSessionsPlayers = @realTimeSessionsPlayers if @realTimeSessionsPlayers
|
|
|
|
# console.log 'MultiplayerView getRenderData', c.levelID
|
|
|
|
# console.log 'realTimeSessions', c.realTimeSessions
|
|
|
|
# console.log c.realTimeSessions.at(c.realTimeSessions.length - 1).get('state') if c.realTimeSessions.length > 0
|
|
|
|
# console.log 'currentRealTimeSession', c.currentRealTimeSession
|
|
|
|
# console.log 'realTimeSessionPlayers', c.realTimeSessionsPlayers
|
2014-10-31 19:33:43 -04:00
|
|
|
|
2014-08-10 20:26:30 -04:00
|
|
|
c
|
2014-08-08 14:36:41 -04:00
|
|
|
|
|
|
|
afterRender: ->
|
|
|
|
super()
|
2014-08-10 20:26:30 -04:00
|
|
|
@updateLinkSection()
|
|
|
|
@ladderSubmissionView = new LadderSubmissionView session: @session, level: @level
|
|
|
|
@insertSubView @ladderSubmissionView, @$el.find('.ladder-submission-view')
|
2014-10-31 19:33:43 -04:00
|
|
|
@$el.find('#created-multiplayer-session').toggle Boolean(@currentRealTimeSession?)
|
|
|
|
@$el.find('#create-game-button').toggle Boolean(not (@currentRealTimeSession?))
|
2014-08-10 20:26:30 -04:00
|
|
|
|
|
|
|
onClickLink: (e) ->
|
|
|
|
e.target.select()
|
|
|
|
|
|
|
|
onGameSubmitted: (e) ->
|
|
|
|
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
|
|
|
|
Backbone.Mediator.publish 'router:navigate', route: ladderURL
|
|
|
|
|
|
|
|
updateLinkSection: ->
|
|
|
|
multiplayer = @$el.find('#multiplayer').prop('checked')
|
|
|
|
la = @$el.find('#link-area')
|
2014-10-18 17:51:43 -04:00
|
|
|
la.toggle if @level?.get('type') in ['ladder', 'hero-ladder'] then false else Boolean(multiplayer)
|
2014-08-10 20:26:30 -04:00
|
|
|
true
|
|
|
|
|
|
|
|
onHidden: ->
|
|
|
|
multiplayer = Boolean(@$el.find('#multiplayer').prop('checked'))
|
|
|
|
@session.set('multiplayer', multiplayer)
|
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-29 02:34:07 -04:00
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
# Real-time Multiplayer ######################################################
|
|
|
|
#
|
|
|
|
# This view is responsible for joining and leaving real-time multiplayer games.
|
|
|
|
#
|
|
|
|
# It performs these actions:
|
|
|
|
# Display your current game (level, players)
|
|
|
|
# Display open games
|
|
|
|
# Create game button, if not in a game
|
|
|
|
# Join game button
|
|
|
|
# Leave game button, if in a game
|
|
|
|
#
|
|
|
|
# It monitors these:
|
|
|
|
# Real-time multiplayer sessions (for open games, player states)
|
|
|
|
# Current real-time multiplayer game session for changes
|
|
|
|
# Players for real-time multiplayer game session
|
|
|
|
#
|
|
|
|
# Real-time state variables:
|
|
|
|
# @realTimeSessionsPlayers - Collection of player lists for active real-time multiplayer sessions
|
|
|
|
# @realTimeSessions - Active real-time multiplayer sessions
|
|
|
|
# @currentRealTimeSession - Our current real-time multiplayer session
|
|
|
|
|
|
|
|
watchRealTimeSessions: ->
|
|
|
|
# Setup monitoring of real-time multiplayer level sessions
|
|
|
|
@realTimeSessionsPlayers = {}
|
2014-08-30 00:46:26 -04:00
|
|
|
# TODO: only request sessions for this level, !team, etc.
|
2014-10-31 19:33:43 -04:00
|
|
|
# TODO: move this to multiplayer_level_sessions/#{levelID}/
|
|
|
|
@realTimeSessions = new RealTimeCollection('multiplayer_level_sessions/')
|
|
|
|
@realTimeSessions.on 'add', @onRealTimeSessionAdded
|
|
|
|
@realTimeSessions.each (rts) => @watchRealTimeSession rts
|
|
|
|
|
|
|
|
watchRealTimeSession: (rts) ->
|
|
|
|
return if rts.get('state') is 'finished'
|
|
|
|
return if rts.get('levelID') isnt @session.get('levelID')
|
|
|
|
# console.log 'MultiplayerView watchRealTimeSession', rts
|
|
|
|
# Setup monitoring of players for given session
|
|
|
|
# TODO: verify we need this
|
|
|
|
realTimeSession = new RealTimeModel('multiplayer_level_sessions/' + rts.id)
|
|
|
|
realTimeSession.on 'change', @onRealTimeSessionChanged
|
|
|
|
@realTimeSessionsPlayers[rts.id] = new RealTimeCollection('multiplayer_level_sessions/' + rts.id + '/players')
|
|
|
|
@realTimeSessionsPlayers[rts.id].on 'add', @onRealTimePlayerAdded
|
|
|
|
@findCurrentRealTimeSession rts
|
|
|
|
|
|
|
|
findCurrentRealTimeSession: (rts) ->
|
|
|
|
# Look for our current real-time session (level, level state, member player)
|
|
|
|
return if @currentRealTimeSession or not @realTimeSessionsPlayers?
|
|
|
|
if rts.get('levelID') is @session.get('levelID') and rts.get('state') isnt 'finished'
|
|
|
|
@realTimeSessionsPlayers[rts.id].each (player) =>
|
|
|
|
if player.id is me.id and player.get('state') isnt 'left'
|
|
|
|
# console.log 'MultiplayerView found current real-time session', rts
|
|
|
|
@currentRealTimeSession = new RealTimeModel('multiplayer_level_sessions/' + rts.id)
|
|
|
|
@currentRealTimeSession.on 'change', @onCurrentRealTimeSessionChanged
|
2014-11-17 18:07:10 -05:00
|
|
|
|
|
|
|
# TODO: Is this necessary? Shouldn't everyone already know we joined a game at this point?
|
|
|
|
Backbone.Mediator.publish 'real-time-multiplayer:joined-game', realTimeSessionID: @currentRealTimeSession.id
|
2014-10-31 19:33:43 -04:00
|
|
|
|
|
|
|
onRealTimeSessionAdded: (rts) =>
|
|
|
|
@watchRealTimeSession rts
|
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-29 02:34:07 -04:00
|
|
|
@render()
|
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onRealTimeSessionChanged: (rts) =>
|
|
|
|
# console.log 'MultiplayerView onRealTimeSessionChanged', rts.get('state')
|
|
|
|
# TODO: @realTimeSessions isn't updated before we call render() here
|
|
|
|
# TODO: so this game isn't updated in open games list
|
|
|
|
@render?()
|
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-29 02:34:07 -04:00
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onCurrentRealTimeSessionChanged: (rts) =>
|
|
|
|
# console.log 'MultiplayerView onCurrentRealTimeSessionChanged', rts
|
|
|
|
if rts.get('state') is 'finished'
|
|
|
|
@currentRealTimeSession.off 'change', @onCurrentRealTimeSessionChanged
|
|
|
|
@currentRealTimeSession = null
|
2014-08-29 18:10:04 -04:00
|
|
|
@render?()
|
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-29 02:34:07 -04:00
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onRealTimePlayerAdded: (e) =>
|
2014-08-29 18:10:04 -04:00
|
|
|
@render?()
|
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-29 02:34:07 -04:00
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onCreateRealTimeGame: ->
|
|
|
|
s = @realTimeSessions.create {
|
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-29 02:34:07 -04:00
|
|
|
creator: @session.get('creator')
|
|
|
|
creatorName: @session.get('creatorName')
|
|
|
|
levelID: @session.get('levelID')
|
2014-08-29 18:10:04 -04:00
|
|
|
created: (new Date()).toISOString()
|
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-29 02:34:07 -04:00
|
|
|
state: 'creating'
|
|
|
|
}
|
2014-10-31 19:33:43 -04:00
|
|
|
@currentRealTimeSession = @realTimeSessions.get(s.id)
|
|
|
|
@currentRealTimeSession.on 'change', @onCurrentRealTimeSessionChanged
|
|
|
|
# TODO: s.id === @currentRealTimeSession.id ?
|
|
|
|
players = new RealTimeCollection('multiplayer_level_sessions/' + @currentRealTimeSession.id + '/players')
|
2014-11-17 18:07:10 -05:00
|
|
|
players.create
|
|
|
|
id: me.id
|
|
|
|
state: 'coding'
|
|
|
|
name: @session.get('creatorName')
|
|
|
|
team: @session.get('team')
|
|
|
|
level_session: @session.id
|
|
|
|
Backbone.Mediator.publish 'real-time-multiplayer:created-game', realTimeSessionID: @currentRealTimeSession.id
|
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-29 02:34:07 -04:00
|
|
|
@render()
|
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onJoinRealTimeGame: (e) ->
|
|
|
|
return if @currentRealTimeSession
|
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-29 02:34:07 -04:00
|
|
|
item = @$el.find(e.target).data('item')
|
2014-10-31 19:33:43 -04:00
|
|
|
@currentRealTimeSession = @realTimeSessions.get(item.id)
|
|
|
|
@currentRealTimeSession.on 'change', @onCurrentRealTimeSessionChanged
|
|
|
|
if @realTimeSessionsPlayers[item.id]
|
2014-11-17 18:07:10 -05:00
|
|
|
|
|
|
|
# TODO: SpellView updateTeam() should take care of this team swap update in the real-time multiplayer session
|
|
|
|
creatorID = @currentRealTimeSession.get('creator')
|
|
|
|
creator = @realTimeSessionsPlayers[item.id].get(creatorID)
|
|
|
|
creatorTeam = creator.get('team')
|
|
|
|
myTeam = @session.get('team')
|
|
|
|
if myTeam is creatorTeam
|
|
|
|
myTeam = if creatorTeam is 'humans' then 'ogres' else 'humans'
|
|
|
|
|
|
|
|
@realTimeSessionsPlayers[item.id].create
|
|
|
|
id: me.id
|
|
|
|
state: 'coding'
|
|
|
|
name: me.get('name')
|
|
|
|
team: myTeam
|
|
|
|
level_session: @session.id
|
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-29 02:34:07 -04:00
|
|
|
else
|
2014-10-31 19:33:43 -04:00
|
|
|
console.error 'MultiplayerView onJoinRealTimeGame did not have a players collection', @currentRealTimeSession
|
2014-11-17 18:07:10 -05:00
|
|
|
Backbone.Mediator.publish 'real-time-multiplayer:joined-game', realTimeSessionID: @currentRealTimeSession.id
|
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-29 02:34:07 -04:00
|
|
|
@render()
|
|
|
|
|
2014-10-31 19:33:43 -04:00
|
|
|
onLeaveRealTimeGame: (e) ->
|
|
|
|
if @currentRealTimeSession
|
|
|
|
@currentRealTimeSession.off 'change', @onCurrentRealTimeSessionChanged
|
|
|
|
@currentRealTimeSession = null
|
2014-11-17 18:07:10 -05:00
|
|
|
Backbone.Mediator.publish 'real-time-multiplayer:left-game', userID: me.id
|
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-29 02:34:07 -04:00
|
|
|
else
|
|
|
|
console.error "Tried to leave a game with no currentMultiplayerSession"
|
|
|
|
@render()
|