mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
removed game.html, fixes #85
This commit is contained in:
parent
b86052e93b
commit
9e6c42f221
8 changed files with 444 additions and 357 deletions
|
|
@ -9,7 +9,9 @@ define([
|
|||
|
||||
function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
||||
|
||||
function Networker (socketLink) {
|
||||
function Networker (socketLink, channelName, nickname) {
|
||||
this.channelName = channelName;
|
||||
this.nickname = nickname;
|
||||
this.socketLink = socketLink;
|
||||
this.gameController = null;
|
||||
this.users = {};
|
||||
|
|
@ -38,14 +40,13 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
|
||||
Networker.prototype.onConnect = function () {
|
||||
console.log('connected.')
|
||||
var channel = JSON.parse(localStorage["channel"]);
|
||||
var player = JSON.parse(localStorage["player"]);
|
||||
if(channel.name) {
|
||||
if(this.channelName) {
|
||||
var options = {
|
||||
channelName: channel.name,
|
||||
nickname: player.nickname
|
||||
channelName: this.channelName,
|
||||
nickname: this.nickname
|
||||
}
|
||||
this.sendCommand('join', options);
|
||||
DomController.setConnected(true);
|
||||
} else {
|
||||
window.location.href = "/";
|
||||
}
|
||||
|
|
@ -55,7 +56,7 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
//if(this.gameController) this.gameController.destruct();
|
||||
//this.gameController = null;
|
||||
console.log('disconnected. game destroyed. no auto-reconnect');
|
||||
document.body.style.backgroundColor = '#aaaaaa';
|
||||
DomController.setConnected(false);
|
||||
}
|
||||
|
||||
Networker.prototype.onJoinSuccess = function (options) {
|
||||
|
|
|
|||
|
|
@ -123,6 +123,14 @@ function (Settings, Nc, Stats, Screenfull) {
|
|||
this.health.innerHTML = "Health: " + parseInt(health, 10);
|
||||
};
|
||||
|
||||
DomController.prototype.setConnected = function(connected) {
|
||||
if(connected) {
|
||||
document.body.style.backgroundColor = '';
|
||||
} else {
|
||||
document.body.style.backgroundColor = '#aaaaaa';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return new DomController();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue