fixed js syntax errors and changed to ggs_gamevm
This commit is contained in:
parent
6986bc269f
commit
e53c2a82c4
2 changed files with 51 additions and 52 deletions
|
@ -1,7 +1,3 @@
|
||||||
function _GGS(tableToken) {
|
|
||||||
|
|
||||||
this.tableToken = tableToken;
|
|
||||||
|
|
||||||
function Storage(type) {
|
function Storage(type) {
|
||||||
if (type == "world" || type == "localStorage" || type == "players") {
|
if (type == "world" || type == "localStorage" || type == "players") {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -42,6 +38,10 @@ function _GGS(tableToken) {
|
||||||
} else throw "GGS: No such storage available " + type;
|
} else throw "GGS: No such storage available " + type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _GGS(tableToken) {
|
||||||
|
|
||||||
|
this.tableToken = tableToken;
|
||||||
|
|
||||||
var world = new Storage("world");
|
var world = new Storage("world");
|
||||||
this.__defineGetter__("world", function() {
|
this.__defineGetter__("world", function() {
|
||||||
return world;
|
return world;
|
||||||
|
@ -64,24 +64,22 @@ function _GGS(tableToken) {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
function _GGS.prototype.sendCommandToAll(command, args) {
|
_GGS.prototype.sendCommandToAll = function(command, args) {
|
||||||
var message = "{" + command + "," + args + "}";
|
var message = "{" + command + "," + args + "}";
|
||||||
callErlang("ggs_table send_command_to_all " + escapeErlang([this.tableToken, message]));
|
callErlang("ggs_table send_command_to_all " + escapeErlang([this.tableToken, message]));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
function _GGS.prototype.serverLog(message) {
|
_GGS.prototype.serverLog = function(message) {
|
||||||
callErlang("error_logger info_msg " + escapeErlang([message]))
|
callErlang("error_logger info_msg " + escapeErlang([message]))
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeErlang(args) {
|
function escapeErlang(args) {
|
||||||
var str = JSON.stringify(args);
|
var str = JSON.stringify(args);
|
||||||
str = str.replace("'", "\\\'");
|
str = str.replace("'", "\\\'");
|
||||||
return "'" + str "'";
|
return "'" + str + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Player(token) {
|
function Player(token) {
|
||||||
|
|
||||||
var playerToken = token;
|
var playerToken = token;
|
||||||
|
@ -98,7 +96,7 @@ function Player(token) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// ------------ Player stuff -------------
|
// ------------ Player stuff -------------
|
||||||
// TODO: remove this later on
|
// TODO: remove this later on
|
||||||
|
|
||||||
|
@ -175,3 +173,4 @@ function listUsers(player) {
|
||||||
}
|
}
|
||||||
player.sendCommand("nicklist", nicks_a.join(","));
|
player.sendCommand("nicklist", nicks_a.join(","));
|
||||||
}
|
}
|
||||||
|
*/
|
|
@ -83,7 +83,7 @@ send_command_to_all(TableToken, Command, Args) ->
|
||||||
%% @private
|
%% @private
|
||||||
init([TableToken]) ->
|
init([TableToken]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
GameVM = ggs_gamevm_e:start_link(TableToken),
|
GameVM = ggs_gamevm:start_link(TableToken),
|
||||||
{ok, #state {
|
{ok, #state {
|
||||||
game_vm = GameVM,
|
game_vm = GameVM,
|
||||||
players = [] }}.
|
players = [] }}.
|
||||||
|
@ -110,14 +110,14 @@ handle_cast({notify, Player, Message}, #state { game_vm = GameVM } = State) ->
|
||||||
PlayerToken = ggs_coordinator:player_pid_to_token(Player),
|
PlayerToken = ggs_coordinator:player_pid_to_token(Player),
|
||||||
case Message of
|
case Message of
|
||||||
{server, define, Args} ->
|
{server, define, Args} ->
|
||||||
ggs_gamevm_e:define(GameVM, Args);
|
ggs_gamevm:define(GameVM, Args);
|
||||||
{game, Command, Args} ->
|
{game, Command, Args} ->
|
||||||
ggs_gamevm_e:player_command(GameVM, PlayerToken, Command, Args)
|
ggs_gamevm:player_command(GameVM, PlayerToken, Command, Args)
|
||||||
end,
|
end,
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast({notify_game, Message, From}, #state { game_vm = GameVM } = State) ->
|
handle_cast({notify_game, Message, From}, #state { game_vm = GameVM } = State) ->
|
||||||
ggs_gamevm_e:player_command(GameVM, From, Message, ""),
|
ggs_gamevm:player_command(GameVM, From, Message, ""),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast({notify_all_players, Message}, #state{players = Players} = State) ->
|
handle_cast({notify_all_players, Message}, #state{players = Players} = State) ->
|
||||||
|
|
Reference in a new issue