Commit f7408480 authored by nanahira's avatar nanahira

use latest coffeescript

parent 09cdcc3f
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 2.5.1
(function() {
var WebSocketServer, _delete, broadcast, create, init, room_data, server, settings, start, update, url;
......@@ -31,7 +31,7 @@
}
return results;
})(),
options: room.get_old_hostinfo(),
options: room.get_old_hostinfo(), // Should be updated when MyCard client updates
arena: settings.modules.arena_mode.enabled && room.arena && settings.modules.arena_mode.mode
};
};
......@@ -50,7 +50,7 @@
results = [];
for (i = 0, len = ROOM_all.length; i < len; i++) {
room = ROOM_all[i];
if (room && room.established && (connection.filter === 'started' || !room["private"]) && ((room.duel_stage !== 0) === (connection.filter === 'started'))) {
if (room && room.established && (connection.filter === 'started' || !room.private) && ((room.duel_stage !== 0) === (connection.filter === 'started'))) {
results.push(room_data(room));
}
}
......@@ -61,19 +61,19 @@
};
create = function(room) {
if (!room["private"]) {
if (!room.private) {
return broadcast('create', room_data(room), 'waiting');
}
};
update = function(room) {
if (!room["private"]) {
if (!room.private) {
return broadcast('update', room_data(room), 'waiting');
}
};
start = function(room) {
if (!room["private"]) {
if (!room.private) {
broadcast('delete', room.name, 'waiting');
}
return broadcast('create', room_data(room), 'started');
......@@ -83,7 +83,7 @@
if (room.duel_stage !== 0) {
return broadcast('delete', room.name, 'started');
} else {
if (!room["private"]) {
if (!room.private) {
return broadcast('delete', room.name, 'waiting');
}
}
......@@ -116,7 +116,7 @@
create: create,
update: update,
start: start,
"delete": _delete
delete: _delete
};
}).call(this);
// Generated by CoffeeScript 1.12.7
/*
Main script of new dashboard account system.
The account list file is stored at `./config/admin_user.json`. The users are stored at `users`.
The key is the username. The `permissions` field could be a string, using a permission set from the example, or an object, to define a specific set of permissions.
eg. An account for a judge could be as follows, to use the default permission of judges,
"username": {
"password": "123456",
"enabled": true,
"permissions": "judge"
},
or as follows, to use a specific set of permissions.
"username": {
"password": "123456",
"enabled": true,
"permissions": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
}
},
*/
// Generated by CoffeeScript 2.5.1
(function() {
/*
Main script of new dashboard account system.
The account list file is stored at `./config/admin_user.json`. The users are stored at `users`.
The key is the username. The `permissions` field could be a string, using a permission set from the example, or an object, to define a specific set of permissions.
eg. An account for a judge could be as follows, to use the default permission of judges,
"username": {
"password": "123456",
"enabled": true,
"permissions": "judge"
},
or as follows, to use a specific set of permissions.
"username": {
"password": "123456",
"enabled": true,
"permissions": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
}
},
*/
var add_log, bunyan, check_permission, default_data, fs, loadJSON, log, moment, reload, save, setting_save, users;
fs = require('fs');
......@@ -122,11 +120,8 @@ or as follows, to use a specific set of permissions.
return permission[permission_required];
};
this.auth = function(name, pass, permission_required, action, no_log) {
this.auth = function(name, pass, permission_required, action = 'unknown', no_log) {
var user;
if (action == null) {
action = 'unknown';
}
reload();
user = users.users[name];
if (!user) {
......
This diff is collapsed.
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 2.5.1
(function() {
var Struct, _, declaration, field, i, len, loadJSON, name, result, structs_declaration, type, typedefs;
......@@ -14,14 +14,17 @@
this.i18ns = loadJSON('./data/i18n.json');
structs_declaration = loadJSON('./data/structs.json');
//常量/类型声明
structs_declaration = loadJSON('./data/structs.json'); //结构体声明
typedefs = loadJSON('./data/typedefs.json');
typedefs = loadJSON('./data/typedefs.json'); //类型声明
this.proto_structs = loadJSON('./data/proto_structs.json');
this.proto_structs = loadJSON('./data/proto_structs.json'); //消息与结构体的对应,未完成,对着duelclient.cpp加
this.constants = loadJSON('./data/constants.json');
this.constants = loadJSON('./data/constants.json'); //network.h里定义的常量
//结构体定义
this.structs = {};
for (name in structs_declaration) {
......@@ -35,7 +38,7 @@
result.chars(field.name, field.length * 2, field.encoding);
break;
default:
throw "unsupported encoding: " + field.encoding;
throw `unsupported encoding: ${field.encoding}`;
}
} else {
type = field.type;
......@@ -43,7 +46,7 @@
type = typedefs[type];
}
if (field.length) {
result.array(field.name, field.length, type);
result.array(field.name, field.length, type); //不支持结构体
} else {
if (this.structs[type]) {
result.struct(field.name, this.structs[type]);
......@@ -56,6 +59,7 @@
this.structs[name] = result;
}
//消息跟踪函数 需要重构, 另暂时只支持异步, 同步没做.
this.stoc_follows = {};
this.stoc_follows_before = {};
......@@ -154,11 +158,13 @@
});
};
//消息发送函数,至少要把俩合起来....
this.stoc_send = function(socket, proto, info) {
var buffer, header, key, ref, struct, value;
if (socket.closed) {
return;
}
//console.log proto, proto_structs.STOC[proto], structs[proto_structs.STOC[proto]]
if (typeof info === 'undefined') {
buffer = "";
} else if (Buffer.isBuffer(info)) {
......@@ -169,7 +175,7 @@
struct.set(info);
buffer = struct.buffer();
}
if (typeof proto === 'string') {
if (typeof proto === 'string') { //需要重构
ref = this.constants.STOC;
for (key in ref) {
value = ref[key];
......@@ -196,6 +202,7 @@
if (socket.closed) {
return;
}
//console.log proto, proto_structs.CTOS[proto], structs[proto_structs.CTOS[proto]]
if (typeof info === 'undefined') {
buffer = "";
} else if (Buffer.isBuffer(info)) {
......@@ -206,7 +213,7 @@
struct.set(info);
buffer = struct.buffer();
}
if (typeof proto === 'string') {
if (typeof proto === 'string') { //需要重构
ref = this.constants.CTOS;
for (key in ref) {
value = ref[key];
......@@ -228,11 +235,9 @@
}
};
this.stoc_send_chat = function(client, msg, player) {
//util
this.stoc_send_chat = function(client, msg, player = 8) {
var j, len1, line, o, r, re, ref, ref1;
if (player == null) {
player = 8;
}
if (!client) {
console.log("err stoc_send_chat");
return;
......@@ -256,11 +261,8 @@
}
};
this.stoc_send_chat_to_room = function(room, msg, player) {
this.stoc_send_chat_to_room = function(room, msg, player = 8) {
var client, j, k, len1, len2, ref, ref1;
if (player == null) {
player = 8;
}
if (!room) {
console.log("err stoc_send_chat_to_room");
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment