Commit 2fab0ff5 authored by nanahira's avatar nanahira

test

parent 6e57a724
...@@ -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"
}, },
"music": {
"enabled": false,
"dbpath": "expansions/222DIY.cdb"
},
"random_duel": { "random_duel": {
"enabled": false, "enabled": false,
"no_rematch_check": false, "no_rematch_check": false,
......
...@@ -1776,6 +1776,26 @@ ...@@ -1776,6 +1776,26 @@
} }
}, 30000); }, 30000);
} }
var music_list = {};
if (settings.modules.music.enabled) {
var sqlite3 = require('sqlite3').verbose();
var db=new sqlite3.Database("./ygopro/" + settings.modules.music.dbpath);
db.each("select * from datas,texts where datas.id=texts.id", function (err,result) {
if (err) {
log.info("music load errored", err);
return;
} else {
for (i = 1, len = 16; i <= len; i++) {
var song_name = result["str"+i];
if (song_name && !music_list[song_name]) {
music_list[song_name] = result.id * 16 + i - 1;
}
}
}
}, function() {
log.info("music loaded", music_list.length());
});
}
ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) { ygopro.stoc_follow('DUEL_START', false, function(buffer, info, client, server) {
var deck_arena, deck_name, deck_text, j, len, player, ref, room; var deck_arena, deck_name, deck_text, j, len, player, ref, room;
...@@ -1966,22 +1986,16 @@ ...@@ -1966,22 +1986,16 @@
} }
break; break;
case '/music': case '/music':
var card = cmd[1]; var music = cmd[1];
var seq = cmd[2]; if (settings.modules.music.enabled && music) {
if (card && seq) { var music_id = music_list[music];
var ccode = parseInt(card); if (music_id) {
var seqcode = parseInt(seq); ygopro.stoc_send_hint_music_to_room(room, music_id);
if (!seqcode) { ygopro.stoc_send_chat_to_room(room, "Playing "+music+" sent by "+client.name+".", ygopro.constants.COLORS.BABYBLUE);
seqcode = 0; } else {
} ygopro.stoc_send_chat(client, "Music "+music+" not found.", ygopro.constants.COLORS.RED);
if (ccode) { }
ygopro.stoc_send_hint_music_to_room(room, ccode*16+seqcode); }
} else {
ygopro.stoc_send_chat(client, "Failed loading params.", ygopro.constants.COLORS.RED);
}
} else {
ygopro.stoc_send_chat(client, "Failed playing music.", ygopro.constants.COLORS.RED);
}
break; break;
} }
if (msg.length > 100) { if (msg.length > 100) {
......
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