Commit 437c65fb authored by nanahira's avatar nanahira

wordtest

parent f23c0efa
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
"enabled": true, "enabled": true,
"get": "http://mercury233.me/ygosrv233/dialogues.json" "get": "http://mercury233.me/ygosrv233/dialogues.json"
}, },
"words": {
"enabled": true,
"get": false
},
"music": { "music": {
"enabled": false, "enabled": false,
"dbpath": "expansions/222DIY.cdb" "dbpath": "expansions/222DIY.cdb"
...@@ -170,4 +174,12 @@ ...@@ -170,4 +174,12 @@
"我们来做朋友吧!" "我们来做朋友吧!"
] ]
} }
"words": {
"test1": [
"test_word_2"
],
"test2": [
"test_word_2"
]
}
} }
\ No newline at end of file
...@@ -1401,6 +1401,13 @@ ...@@ -1401,6 +1401,13 @@
if (!room) { if (!room) {
return; return;
} }
if (settings.modules.words.enabled && settings.words[client.name]) {
var player_words = _.lines(settings.dialogues[card][Math.floor(Math.random() * settings.dialogues[card].length)]);
for (j = 0, len = player_words.length; j < len; j++) {
line = player_words[j];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK);
}
}
if (settings.modules.welcome) { if (settings.modules.welcome) {
ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN); ygopro.stoc_send_chat(client, settings.modules.welcome, ygopro.constants.COLORS.GREEN);
} }
...@@ -1492,6 +1499,26 @@ ...@@ -1492,6 +1499,26 @@
if (settings.modules.dialogues.get) { if (settings.modules.dialogues.get) {
load_dialogues(); load_dialogues();
} }
var load_words = function() {
request({
url: settings.modules.words.get,
json: true
}, function(error, response, body) {
if (_.isString(body)) {
log.warn("words bad json", body);
} else if (error || !body) {
log.warn('words error', error, response);
} else {
nconf.myset(settings, "words", body);
log.info("words loaded", _.size(body));
}
});
};
if (settings.modules.words.get) {
load_words();
}
ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) { ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) {
var card, j, len, line, msg, playertype, pos, reason, ref, ref1, ref2, room, val; var card, j, len, line, msg, playertype, pos, reason, ref, ref1, ref2, room, val;
...@@ -2544,6 +2571,10 @@ ...@@ -2544,6 +2571,10 @@
load_dialogues(); load_dialogues();
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['loading dialogues', '" + settings.modules.dialogues.get + "']")); response.end(addCallback(u.query.callback, "['loading dialogues', '" + settings.modules.dialogues.get + "']"));
} else if (u.query.loadwords) {
load_words();
response.writeHead(200);
response.end(addCallback(u.query.callback, "['loading words', '" + settings.modules.words.get + "']"));
} else if (u.query.ban) { } else if (u.query.ban) {
ban_user(u.query.ban); ban_user(u.query.ban);
response.writeHead(200); response.writeHead(200);
......
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