Commit 26fa5ac7 authored by nanahira's avatar nanahira

exp

parent e4ff0361
......@@ -85,6 +85,10 @@
"surrender_confirm": "Are you sure? Enter /surrender again to confirm.",
"surrender_canceled": "Surrender canceled.",
"surrender_denied": "Please use the Surrender button instead.",
"play_music": "Playing music: ",
"play_music_user": "The current music is played by: ",
"stop_music_user": "The current music is stopped by: ",
"music_not_found": "Cannot find music: ",
"unwelcome_warn_part1": "If you keep doing ",
"unwelcome_warn_part2": ", your opponent may leave you.",
"unwelcome_tip_part1": "Your oppenent did ",
......@@ -178,6 +182,10 @@
"surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。",
"surrender_canceled": "已取消投降,加油!",
"surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。",
"play_music": "正在播放:",
"play_music_user": "当前音乐由以下玩家点选:",
"stop_music_user": "当前音乐被以下玩家终止:",
"music_not_found": "找不到音乐:",
"unwelcome_warn_part1": "如果您经常",
"unwelcome_warn_part2": ",您的对手可能会离你而去。",
"unwelcome_tip_part1": "因为您的对手有",
......
......@@ -1571,6 +1571,16 @@
ygopro.stoc_send_chat_to_room(room, "${lp_low_self}", ygopro.constants.COLORS.PINK);
}
}
if (settings.modules.music.enabled) {
if (ygopro.constants.MSG[msg] === 'HINT') {
var hint_type = buffer.readUInt8(1);
pos = buffer.readUInt8(2);
var music_id = buffer.readUInt32LE(3);
if (hint_type === 11 && music_list_rev[music_id])
ygopro.stoc_send_chat(client, "${play_music}"+music_list_rev[music_id], ygopro.constants.COLORS.BABYBLUE);
}
}
}
if (settings.modules.dialogues.enabled) {
if (ygopro.constants.MSG[msg] === 'SUMMONING' || ygopro.constants.MSG[msg] === 'SPSUMMONING') {
card = buffer.readUInt32LE(1);
......@@ -1777,10 +1787,11 @@
}, 30000);
}
var music_list = {};
var music_list_rev = {};
var music_count = 0;
if (settings.modules.music.enabled) {
var sqlite3 = require('sqlite3').verbose();
var db=new sqlite3.Database("./ygopro/" + settings.modules.music.dbpath);
var count = 0;
db.each("select * from datas,texts where datas.id=texts.id", function (err,result) {
if (err) {
log.info("music load errored", err);
......@@ -1788,14 +1799,18 @@
} 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;
count++;
if (song_name) {
var music_id = result.id * 16 + i - 1;
music_list_rev[music_id] = song_name;
if (!music_list[song_name]) {
music_list[song_name] = music_id;
music_count++;
}
}
}
}
}, function() {
log.info("music loaded", count);
log.info("music loaded", music_count);
});
}
......@@ -1992,13 +2007,15 @@
if (settings.modules.music.enabled && music) {
if (music === "stop") {
ygopro.stoc_send_hint_music_to_room(room, 0);
ygopro.stoc_send_chat_to_room(room, "Music stopped by "+client.name+".", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat_to_room(room, "${play_music}"+music, ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat_to_room(room, "${stop_music_user}"+client.name, ygopro.constants.COLORS.BABYBLUE);
break;
}
var music_id = music_list[music];
if (music_id) {
ygopro.stoc_send_hint_music_to_room(room, music_id);
ygopro.stoc_send_chat_to_room(room, "Playing "+music+" sent by "+client.name+".", ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat_to_room(room, "${play_music}"+music, ygopro.constants.COLORS.BABYBLUE);
ygopro.stoc_send_chat_to_room(room, "${play_music_user}"+client.name, ygopro.constants.COLORS.BABYBLUE);
} else {
ygopro.stoc_send_chat(client, "Music "+music+" not found.", ygopro.constants.COLORS.RED);
}
......
......@@ -220,40 +220,43 @@
}
}
};
this.stoc_send_hint_music = function(client, music, music_type) {
if (!client) {
console.log("err stoc_send_hint_music");
return;
}
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
type: music_type,
player: 0,
data: music
});
};
this.stoc_send_hint_music_to_room = function(room, music) {
this.stoc_send_hint_music_to_room = function(room, music, music_type) {
var client, j, k, len1, len2, ref, ref1;
if (!room) {
console.log("err stoc_send_hint_card_to_room");
console.log("err stoc_send_hint_music_to_room");
return;
}
ref = room.players;
for (j = 0, len1 = ref.length; j < len1; j++) {
client = ref[j];
if (client) {
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
type: 11,
player: 0,
data: music
});
this.stoc_send_hint_music(client, music, music_type);
}
}
ref1 = room.watchers;
for (k = 0, len2 = ref1.length; k < len2; k++) {
client = ref1[k];
if (client) {
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
type: 11,
player: 0,
data: music
});
this.stoc_send_hint_music(client, music, music_type);
}
}
};
this.stoc_send_hint_card_to_room = function(room, card) {
this.stoc_send_hint_music_to_room = function(room, music) {
var client, j, k, len1, len2, ref, ref1;
if (!room) {
console.log("err stoc_send_hint_card_to_room");
......@@ -265,9 +268,9 @@
if (client) {
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
type: 10,
type: 11,
player: 0,
data: card
data: music
});
}
}
......@@ -277,13 +280,13 @@
if (client) {
this.stoc_send(client, 'GAME_MSG', {
curmsg: 2,
type: 10,
type: 11,
player: 0,
data: card
data: music
});
}
}
};
};
this.stoc_send_hint_card_to_room = function(room, card) {
var client, j, k, len1, len2, ref, ref1;
......
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