mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
gameCommand implementation
This commit is contained in:
parent
6219a82fbd
commit
c4c48ab821
10 changed files with 62 additions and 39 deletions
|
|
@ -10,6 +10,7 @@ function(Parent, NotificationCenter, ProtocolHelper) {
|
|||
Parent.call(this, id);
|
||||
|
||||
this.channel = channel;
|
||||
this.player = null;
|
||||
var self = this;
|
||||
|
||||
NotificationCenter.on('user/joined', function(user) {
|
||||
|
|
@ -21,6 +22,12 @@ function(Parent, NotificationCenter, ProtocolHelper) {
|
|||
NotificationCenter.on('user/' + this.id + "/joinSuccess", function(options) {
|
||||
self.sendControlCommand("joinSuccess", options);
|
||||
});
|
||||
|
||||
NotificationCenter.on('user/' + this.id + "/message", function(message) { // FIXME: right now only game commands?
|
||||
ProtocolHelper.runCommands(message.data, function (command, options) {
|
||||
self.gameCommand(command, options);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
User.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -37,6 +44,14 @@ function(Parent, NotificationCenter, ProtocolHelper) {
|
|||
this.sendControlCommand("gameCommand", data);
|
||||
};
|
||||
|
||||
User.prototype.gameCommand = function(command, options) {
|
||||
this.player.inputController[command].call(this.player.inputController);
|
||||
};
|
||||
|
||||
User.prototype.setPlayer = function(player) {
|
||||
this.player = player;
|
||||
};
|
||||
|
||||
return User;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue