-
Notifications
You must be signed in to change notification settings - Fork 1
/
controllers.js
33 lines (28 loc) · 1.26 KB
/
controllers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
app.controller('MainController',
function ($scope, GameEvents, GameEventHandlers, ConnectionEventHandlers, Storage, Connection) {
var init = function () {
// Setup our connection event handlers
$scope.connected = false;
Connection.init(ConnectionEventHandlers($scope));
// Register our game
GameEvents.init(GameEventHandlers($scope));
// It might not exist in storage, but if it does the last person you played will be already
// entered in the connection id input.
// You can clear out the storage if it's annoying you. See below for more detail.
// Just uncomment the following line.
// Storage.clear();
$scope.opponentId = Storage.retrieveStoredIds().opponentId;
};
$scope.sendCard = function (card) {
Connection.sendData('card', card);
};
// Click connect button and fire this
$scope.connect = function (opponentId) {
$scope.opponentId = Connection.connectToPeer(opponentId);
$scope.status = 'Connecting to ' + opponentId;
$scope.myGo = true;
};
// Setup our game
init();
}
);