Commit a125fbe9 authored by nanahira's avatar nanahira

cleanup

parent 028bee34
...@@ -66,10 +66,6 @@ ...@@ -66,10 +66,6 @@
"enabled": false, "enabled": false,
"get": false "get": false
}, },
"music": {
"enabled": false,
"dbpath": "expansions/222DIY.cdb"
},
"random_duel": { "random_duel": {
"enabled": true, "enabled": true,
"no_rematch_check": false, "no_rematch_check": false,
...@@ -256,81 +252,6 @@ ...@@ -256,81 +252,6 @@
} }
] ]
}, },
"command": {
"enabled": false,
"identity": {
"username1": "password1",
"username1": "password2"
},
"command_list": {
"ygopro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/"
},
"make": {
"command": "make",
"args": [
"config=release"
],
"path": "./ygopro/build/"
},
"srvpro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "."
},
"windbot": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./windbot/"
},
"buildbot": {
"command": "xbuild",
"args": [
"/property:Configuration=Release"
],
"path": "./windbot/"
},
"restartbot": {
"command": "pm2",
"args": [
"restart",
"windbot-server"
],
"path": "."
},
"restart": {
"command": "pm2",
"args": [
"restart",
"ygopro-server"
],
"path": "."
},
"script": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/script/"
}
}
},
"http": { "http": {
"port": 7211, "port": 7211,
"password": "Nanahira", "password": "Nanahira",
......
...@@ -66,10 +66,6 @@ ...@@ -66,10 +66,6 @@
"enabled": false, "enabled": false,
"get": false "get": false
}, },
"music": {
"enabled": false,
"dbpath": "expansions/222DIY.cdb"
},
"random_duel": { "random_duel": {
"enabled": false, "enabled": false,
"no_rematch_check": false, "no_rematch_check": false,
...@@ -256,81 +252,6 @@ ...@@ -256,81 +252,6 @@
} }
] ]
}, },
"command": {
"enabled": false,
"identity": {
"username1": "password1",
"username1": "password2"
},
"command_list": {
"ygopro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/"
},
"make": {
"command": "make",
"args": [
"config=release"
],
"path": "./ygopro/build/"
},
"srvpro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "."
},
"windbot": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./windbot/"
},
"buildbot": {
"command": "xbuild",
"args": [
"/property:Configuration=Release"
],
"path": "./windbot/"
},
"restartbot": {
"command": "pm2",
"args": [
"restart",
"windbot-server"
],
"path": "."
},
"restart": {
"command": "pm2",
"args": [
"restart",
"ygopro-server"
],
"path": "."
},
"script": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/script/"
}
}
},
"http": { "http": {
"port": 1263, "port": 1263,
"password": "Nanahira", "password": "Nanahira",
......
...@@ -66,10 +66,6 @@ ...@@ -66,10 +66,6 @@
"enabled": true, "enabled": true,
"get": false "get": false
}, },
"music": {
"enabled": false,
"dbpath": "expansions/222DIY.cdb"
},
"random_duel": { "random_duel": {
"enabled": false, "enabled": false,
"no_rematch_check": false, "no_rematch_check": false,
...@@ -244,81 +240,6 @@ ...@@ -244,81 +240,6 @@
} }
] ]
}, },
"command": {
"enabled": false,
"identity": {
"username1": "password1",
"username1": "password2"
},
"command_list": {
"ygopro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/"
},
"make": {
"command": "make",
"args": [
"config=release"
],
"path": "./ygopro/build/"
},
"srvpro": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "."
},
"windbot": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./windbot/"
},
"buildbot": {
"command": "xbuild",
"args": [
"/property:Configuration=Release"
],
"path": "./windbot/"
},
"restartbot": {
"command": "pm2",
"args": [
"restart",
"windbot-server"
],
"path": "."
},
"restart": {
"command": "pm2",
"args": [
"restart",
"ygopro-server"
],
"path": "."
},
"script": {
"command": "git",
"args": [
"pull",
"origin",
"master"
],
"path": "./ygopro/script/"
}
}
},
"http": { "http": {
"port": 7922, "port": 7922,
"password": "123456", "password": "123456",
......
...@@ -89,10 +89,6 @@ ...@@ -89,10 +89,6 @@
"surrender_confirm": "Are you sure? Enter /surrender again to confirm.", "surrender_confirm": "Are you sure? Enter /surrender again to confirm.",
"surrender_canceled": "Surrender canceled.", "surrender_canceled": "Surrender canceled.",
"surrender_denied": "Please don't surrender in the first 2 turns.", "surrender_denied": "Please don't surrender in the first 2 turns.",
"play_music": "Playing music: ",
"stop_music": "Music set back to default.",
"music_not_found_1": "Music ",
"music_not_found_2": " not found.",
"unwelcome_warn_part1": "If you keep doing ", "unwelcome_warn_part1": "If you keep doing ",
"unwelcome_warn_part2": ", your opponent may leave you.", "unwelcome_warn_part2": ", your opponent may leave you.",
"unwelcome_tip_part1": "Your oppenent did ", "unwelcome_tip_part1": "Your oppenent did ",
...@@ -360,10 +356,6 @@ ...@@ -360,10 +356,6 @@
"surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。", "surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。",
"surrender_canceled": "已取消投降,加油!", "surrender_canceled": "已取消投降,加油!",
"surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。", "surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。",
"play_music": "正在播放:",
"stop_music": "已切换为默认音乐。",
"music_not_found_1": "无法找到音乐:",
"music_not_found_2": "。",
"unwelcome_warn_part1": "如果您经常", "unwelcome_warn_part1": "如果您经常",
"unwelcome_warn_part2": ",您的对手可能会离你而去。", "unwelcome_warn_part2": ",您的对手可能会离你而去。",
"unwelcome_tip_part1": "因为您的对手有", "unwelcome_tip_part1": "因为您的对手有",
......
...@@ -58,10 +58,17 @@ try ...@@ -58,10 +58,17 @@ try
oldtips.tips = oldconfig.tips oldtips.tips = oldconfig.tips
fs.writeFileSync(oldtips.file, JSON.stringify(oldtips, null, 2)) fs.writeFileSync(oldtips.file, JSON.stringify(oldtips, null, 2))
delete oldconfig.tips delete oldconfig.tips
if oldconfig.words
oldtips = {}
oldtips.file = './config/words.json'
oldtips.words = oldconfig.words
fs.writeFileSync(oldtips.file, JSON.stringify(oldtips, null, 2))
delete oldconfig.words
if oldconfig.dialogues if oldconfig.dialogues
olddialogues = {} olddialogues = {}
olddialogues.file = './config/dialogues.json' olddialogues.file = './config/dialogues.json'
olddialogues.dialogues = oldconfig.dialogues olddialogues.dialogues = oldconfig.dialogues
olddialogues.dialogues_custom = {}
fs.writeFileSync(olddialogues.file, JSON.stringify(olddialogues, null, 2)) fs.writeFileSync(olddialogues.file, JSON.stringify(olddialogues, null, 2))
delete oldconfig.dialogues delete oldconfig.dialogues
if oldconfig.modules if oldconfig.modules
...@@ -136,8 +143,16 @@ try ...@@ -136,8 +143,16 @@ try
catch catch
tips = default_data.tips tips = default_data.tips
setting_save(tips) setting_save(tips)
try
words = loadJSON('./config/words.json')
catch
words = default_data.words
setting_save(words)
try try
dialogues = loadJSON('./config/dialogues.json') dialogues = loadJSON('./config/dialogues.json')
if !dialogues.dialogues_custom
dialogues.dialogues_custom = {}
setting_save(dialogues);
catch catch
dialogues = default_data.dialogues dialogues = default_data.dialogues
setting_save(dialogues) setting_save(dialogues)
...@@ -442,6 +457,8 @@ class Room ...@@ -442,6 +457,8 @@ class Room
else if name[0...3] == 'AI#' else if name[0...3] == 'AI#'
@hostinfo.rule = 2 @hostinfo.rule = 2
@hostinfo.lflist = -1 @hostinfo.lflist = -1
@hostinfo.time_limit = 0
@hostinfo.no_check_deck = true
else if (param = name.match /^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i) else if (param = name.match /^(\d)(\d)(T|F)(T|F)(T|F)(\d+),(\d+),(\d+)/i)
@hostinfo.rule = parseInt(param[1]) @hostinfo.rule = parseInt(param[1])
...@@ -1266,6 +1283,9 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -1266,6 +1283,9 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
#欢迎信息 #欢迎信息
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
if settings.modules.words.enabled and words.words[client.name]
for line in _.lines words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]
ygopro.stoc_send_chat(client, 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)
if room.welcome if room.welcome
...@@ -1333,6 +1353,24 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -1333,6 +1353,24 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
return return
# 登场台词 # 登场台词
load_words = () ->
request
url: settings.modules.words.get
json: true
, (error, response, body)->
if _.isString body
log.warn "words bad json", body
else if error or !body
log.warn 'words error', error, response
else
setting_change(words, "words", body)
log.info "words loaded", _.size words.words
return
return
if settings.modules.words.get
load_words()
load_dialogues = () -> load_dialogues = () ->
request request
url: settings.modules.dialogues.get url: settings.modules.dialogues.get
...@@ -1348,9 +1386,27 @@ load_dialogues = () -> ...@@ -1348,9 +1386,27 @@ load_dialogues = () ->
return return
return return
load_dialogues_custom = () ->
request
url: settings.modules.dialogues.get_custom
json: true
, (error, response, body)->
if _.isString body
log.warn "custom dialogues bad json", body
else if error or !body
log.warn 'custom dialogues error', error, response
else
setting_change(dialogues, "dialogues_custom", body)
log.info "custom dialogues loaded", _.size dialogues.dialogues_custom
return
return
if settings.modules.dialogues.get if settings.modules.dialogues.get
load_dialogues() load_dialogues()
if settings.modules.dialogues.get_custom
load_dialogues_custom()
ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)-> ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
...@@ -1525,9 +1581,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)-> ...@@ -1525,9 +1581,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
if ygopro.constants.MSG[msg] == 'SUMMONING' or ygopro.constants.MSG[msg] == 'SPSUMMONING' or ygopro.constants.MSG[msg] == 'CHAINING' if ygopro.constants.MSG[msg] == 'SUMMONING' or ygopro.constants.MSG[msg] == 'SPSUMMONING' or ygopro.constants.MSG[msg] == 'CHAINING'
card = buffer.readUInt32LE(1) card = buffer.readUInt32LE(1)
trigger_location = buffer.readUInt8(6) trigger_location = buffer.readUInt8(6)
if dialogues.dialogues[card] and (ygopro.constants.MSG[msg] != 'CHAINING' or (trigger_location & 0x8) and !(trigger_location & 0x200)) if ygopro.constants.MSG[msg] != 'CHAINING' or (trigger_location & 0x8) and !(trigger_location & 0x200)
for line in _.lines dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)] if dialogues.dialogues[card]
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK) for line in _.lines dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK)
else if dialogues.dialogues_custom[card]
for line in _.lines dialogues.dialogues_custom[card][Math.floor(Math.random() * dialogues.dialogues_custom[card].length)]
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK)
return false return false
#房间管理 #房间管理
...@@ -1670,6 +1730,7 @@ load_tips = ()-> ...@@ -1670,6 +1730,7 @@ load_tips = ()->
if settings.modules.tips.get if settings.modules.tips.get
load_tips() load_tips()
if settings.modules.tips.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.established for room in ROOM_all when room and room.established
ygopro.stoc_send_random_tip_to_room(room) if !room.started or room.changing_side ygopro.stoc_send_random_tip_to_room(room) if !room.started or room.changing_side
...@@ -1941,7 +2002,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)-> ...@@ -1941,7 +2002,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server)->
if client.pos == 0 if client.pos == 0
room.waiting_for_player = room.waiting_for_player2 room.waiting_for_player = room.waiting_for_player2
room.last_active_time = moment() room.last_active_time = moment()
else if !room.started and room.hostinfo.mode == 1 and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and fs.readdirSync(settings.modules.tournament_mode.deck_path).length else if !room.started and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and fs.readdirSync(settings.modules.tournament_mode.deck_path).length
struct = ygopro.structs["deck"] struct = ygopro.structs["deck"]
struct._setBuff(buffer) struct._setBuff(buffer)
struct.set("mainc", 1) struct.set("mainc", 1)
...@@ -2329,8 +2390,15 @@ if settings.modules.http ...@@ -2329,8 +2390,15 @@ if settings.modules.http
else if u.query.loaddialogues else if u.query.loaddialogues
load_dialogues() load_dialogues()
if settings.modules.dialogues.get_custom
load_dialogues_custom()
response.writeHead(200)
response.end(addCallback(u.query.callback, "['loading dialogues', '" + settings.modules.dialogues.get + (if settings.modules.dialogues.get_custom then " and " + settings.modules.dialogues.get_custom else "") + "']"))
else if u.query.loadwords
load_words()
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 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)
......
// Generated by CoffeeScript 1.12.7 // Generated by CoffeeScript 1.12.7
(function() { (function() {
var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, badwords, ban_user, bunyan, chat_color, config, cppversion, crypto, date, default_config, default_data, dialogues, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, j, k, len, len1, lflists, list, loadJSON, load_dialogues, load_tips, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, ygopro, zlib; var Cloud_replay_ids, ROOM_all, ROOM_bad_ip, ROOM_ban_player, ROOM_connected_ip, ROOM_find_by_name, ROOM_find_by_port, ROOM_find_by_title, ROOM_find_or_create_ai, ROOM_find_or_create_by_name, ROOM_find_or_create_random, ROOM_players_banned, ROOM_players_oppentlist, ROOM_unwelcome, ROOM_validate, Room, _, addCallback, badwords, ban_user, bunyan, chat_color, config, cppversion, crypto, date, default_config, default_data, dialogues, duel_log, e, exec, execFile, fs, geoip, get_memory_usage, http, http_server, https, https_server, j, k, len, len1, lflists, list, loadJSON, load_dialogues, load_dialogues_custom, load_tips, load_words, log, memory_usage, merge, moment, net, oldbadwords, oldconfig, olddialogues, oldduellog, oldtips, options, os, path, pgClient, pg_client, pg_query, redis, redisdb, ref, ref1, report_to_big_brother, request, requestListener, roomlist, setting_change, setting_save, settings, spawn, spawnSync, tips, url, users_cache, wait_room_start, wait_room_start_arena, windbot_bin, windbot_parameters, windbot_process, windbots, words, ygopro, zlib;
var words, oldwords, load_dialogues_custom;
net = require('net'); net = require('net');
http = require('http'); http = require('http');
...@@ -78,10 +76,10 @@ ...@@ -78,10 +76,10 @@
delete oldconfig.tips; delete oldconfig.tips;
} }
if (oldconfig.words) { if (oldconfig.words) {
oldwords = {}; oldtips = {};
oldwords.file = './config/words.json'; oldtips.file = './config/words.json';
oldwords.words = oldconfig.words; oldtips.words = oldconfig.words;
fs.writeFileSync(oldwords.file, JSON.stringify(oldwords, null, 2)); fs.writeFileSync(oldtips.file, JSON.stringify(oldtips, null, 2));
delete oldconfig.words; delete oldconfig.words;
} }
if (oldconfig.dialogues) { if (oldconfig.dialogues) {
...@@ -200,7 +198,7 @@ ...@@ -200,7 +198,7 @@
if (!dialogues.dialogues_custom) { if (!dialogues.dialogues_custom) {
dialogues.dialogues_custom = {}; dialogues.dialogues_custom = {};
setting_save(dialogues); setting_save(dialogues);
} }
} catch (error1) { } catch (error1) {
dialogues = default_data.dialogues; dialogues = default_data.dialogues;
setting_save(dialogues); setting_save(dialogues);
...@@ -1561,16 +1559,16 @@ ...@@ -1561,16 +1559,16 @@
}); });
ygopro.stoc_follow('JOIN_GAME', false, function(buffer, info, client, server) { ygopro.stoc_follow('JOIN_GAME', false, function(buffer, info, client, server) {
var recorder, room, watcher; var l, len2, line, recorder, ref2, room, watcher;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
} }
if (settings.modules.words.enabled && words.words[client.name]) { if (settings.modules.words.enabled && words.words[client.name]) {
var player_words = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]); ref2 = _.lines(words.words[client.name][Math.floor(Math.random() * words.words[client.name].length)]);
for (j = 0, len = player_words.length; j < len; j++) { for (l = 0, len2 = ref2.length; l < len2; l++) {
line = player_words[j]; line = ref2[l];
ygopro.stoc_send_chat_to_room(room, line, ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
} }
} }
if (settings.modules.welcome) { if (settings.modules.welcome) {
...@@ -1627,15 +1625,15 @@ ...@@ -1627,15 +1625,15 @@
ygopro.ctos_send(watcher, 'HS_TOOBSERVER'); ygopro.ctos_send(watcher, 'HS_TOOBSERVER');
}); });
watcher.on('data', function(data) { watcher.on('data', function(data) {
var l, len2, ref2, w; var len3, m, ref3, w;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
} }
room.watcher_buffers.push(data); room.watcher_buffers.push(data);
ref2 = room.watchers; ref3 = room.watchers;
for (l = 0, len2 = ref2.length; l < len2; l++) { for (m = 0, len3 = ref3.length; m < len3; m++) {
w = ref2[l]; w = ref3[m];
if (w) { if (w) {
w.write(data); w.write(data);
} }
...@@ -1645,7 +1643,7 @@ ...@@ -1645,7 +1643,7 @@
} }
}); });
var load_words = function() { load_words = function() {
request({ request({
url: settings.modules.words.get, url: settings.modules.words.get,
json: true json: true
...@@ -1699,14 +1697,14 @@ ...@@ -1699,14 +1697,14 @@
if (settings.modules.dialogues.get) { if (settings.modules.dialogues.get) {
load_dialogues(); load_dialogues();
} }
if (settings.modules.dialogues.get_custom) { if (settings.modules.dialogues.get_custom) {
load_dialogues_custom(); load_dialogues_custom();
} }
ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server) { ygopro.stoc_follow('GAME_MSG', true, function(buffer, info, client, server) {
var card, count, l, len2, line, loc, msg, oppo_pos, phase, playertype, pos, reason, ref2, ref3, ref4, room, trigger_location, val, win_pos; var card, count, l, len2, len3, line, loc, m, msg, oppo_pos, phase, playertype, pos, reason, ref2, ref3, ref4, ref5, room, trigger_location, val, win_pos;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!room) { if (!room) {
return; return;
...@@ -1926,31 +1924,23 @@ ...@@ -1926,31 +1924,23 @@
client.card_count += count; client.card_count += count;
} }
} }
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.PINK);
}
}
}
if (settings.modules.dialogues.enabled) { if (settings.modules.dialogues.enabled) {
if (ygopro.constants.MSG[msg] === 'SUMMONING' || ygopro.constants.MSG[msg] === 'SPSUMMONING' || ygopro.constants.MSG[msg] === 'CHAINING') { if (ygopro.constants.MSG[msg] === 'SUMMONING' || ygopro.constants.MSG[msg] === 'SPSUMMONING' || ygopro.constants.MSG[msg] === 'CHAINING') {
card = buffer.readUInt32LE(1); card = buffer.readUInt32LE(1);
trigger_location = buffer.readUInt8(6); trigger_location = buffer.readUInt8(6);
if (dialogues.dialogues[card] && (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && !(trigger_location & 0x200))) { if (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && !(trigger_location & 0x200)) {
ref4 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]); if (dialogues.dialogues[card]) {
for (l = 0, len2 = ref4.length; l < len2; l++) { ref4 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]);
line = ref4[l]; for (l = 0, len2 = ref4.length; l < len2; l++) {
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK); line = ref4[l];
} ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
} else if (dialogues.dialogues_custom[card] && (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && !(trigger_location & 0x200))) { }
ref2 = _.lines(dialogues.dialogues_custom[card][Math.floor(Math.random() * dialogues.dialogues_custom[card].length)]); } else if (dialogues.dialogues_custom[card]) {
for (j = 0, len = ref2.length; j < len; j++) { ref5 = _.lines(dialogues.dialogues_custom[card][Math.floor(Math.random() * dialogues.dialogues_custom[card].length)]);
line = ref2[j]; for (m = 0, len3 = ref5.length; m < len3; m++) {
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK); line = ref5[m];
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK);
}
} }
} }
} }
...@@ -2158,6 +2148,7 @@ ...@@ -2158,6 +2148,7 @@
if (settings.modules.tips.get) { if (settings.modules.tips.get) {
load_tips(); load_tips();
} }
if (settings.modules.tips.enabled) { if (settings.modules.tips.enabled) {
setInterval(function() { setInterval(function() {
var l, len2, room; var l, len2, room;
...@@ -2172,34 +2163,6 @@ ...@@ -2172,34 +2163,6 @@
}, 30000); }, 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);
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) {
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", music_count);
});
}
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, l, len2, player, ref2, room; var deck_arena, deck_name, deck_text, l, len2, player, ref2, room;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
...@@ -2394,54 +2357,6 @@ ...@@ -2394,54 +2357,6 @@
ygopro.stoc_send_chat(client, "${room_name} " + room.name, ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${room_name} " + room.name, ygopro.constants.COLORS.BABYBLUE);
} }
break; break;
case '/command':
if (settings.modules.command.enabled && (!settings.modules.command.identity || (settings.modules.command.identity[client.name] && settings.modules.command.identity[client.name] === room.name))) {
var cname = cmd[1];
if (!cname) {
ygopro.stoc_send_chat(client, "Please enter the command.", ygopro.constants.COLORS.RED);
break;
}
var command_info = settings.modules.command.command_list[cname];
if (!command_info) {
ygopro.stoc_send_chat(client, "Command '"+cname+"' not found.", ygopro.constants.COLORS.RED);
break;
}
ygopro.stoc_send_chat(client, "Started running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE);
try {
var proc = spawn(command_info.command, command_info.args, { cwd: command_info.path, env: process.env });
proc.stdout.setEncoding('utf8');
proc.stdout.on('data', function(data) {
ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.LIGHTBLUE);
});
proc.stderr.setEncoding('utf8');
proc.stderr.on('data', function(data) {
ygopro.stoc_send_chat(client, data, ygopro.constants.COLORS.RED);
});
proc.on('close', function (code) {
ygopro.stoc_send_chat(client, "Finished running command '"+cname+"' .", ygopro.constants.COLORS.BABYBLUE);
});
} catch (e) {}
}
break;
/*
case '/music':
var music = msg.slice(7);
if (settings.modules.music.enabled) {
if (!music || music.length <= 0) {
ygopro.stoc_send_hint_music(client, 0, 11);
ygopro.stoc_send_chat(client, "${stop_music}", ygopro.constants.COLORS.BABYBLUE);
break;
}
var music_id = music_list[music];
if (music_id) {
ygopro.stoc_send_hint_music(client, music_id, 11);
ygopro.stoc_send_chat(client, "${play_music}"+music, ygopro.constants.COLORS.BABYBLUE);
} else {
ygopro.stoc_send_chat(client, "${music_not_found_1}"+music+"${music_not_found_2}", ygopro.constants.COLORS.RED);
}
}
break;
*/
case '/color': case '/color':
if (settings.modules.chat_color.enabled) { if (settings.modules.chat_color.enabled) {
cip = settings.modules.mycard.enabled ? client.name : client.ip; cip = settings.modules.mycard.enabled ? client.name : client.ip;
...@@ -3117,26 +3032,6 @@ ...@@ -3117,26 +3032,6 @@
return; return;
} }
if (u.query.shout) { if (u.query.shout) {
/*
if (u.query.shout.slice(0, 7) === "/music " && settings.modules.music.enabled) {
var music = u.query.shout.slice(7);
var music_id = music_list[music];
if (music_id) {
for (j = 0, len = ROOM_all.length; j < len; j++) {
room = ROOM_all[j];
if (room && room.established) {
ygopro.stoc_send_hint_music_to_room(room, music_id, 11);
ygopro.stoc_send_chat_to_room(room, "${play_music}"+music, ygopro.constants.COLORS.YELLOW);
}
}
response.writeHead(200);
response.end(addCallback(u.query.callback, "['music ok', '" + u.query.shout + "']"));
} else {
response.writeHead(200);
response.end(addCallback(u.query.callback, "['music not found', '" + u.query.shout + "']"));
}
} else {
*/
for (m = 0, len3 = ROOM_all.length; m < len3; m++) { for (m = 0, len3 = ROOM_all.length; m < len3; m++) {
room = ROOM_all[m]; room = ROOM_all[m];
if (room && room.established) { if (room && room.established) {
...@@ -3145,8 +3040,6 @@ ...@@ -3145,8 +3040,6 @@
} }
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['shout ok', '" + u.query.shout + "']")); response.end(addCallback(u.query.callback, "['shout ok', '" + u.query.shout + "']"));
// }
} else if (u.query.stop) { } else if (u.query.stop) {
if (u.query.stop === 'false') { if (u.query.stop === 'false') {
u.query.stop = false; u.query.stop = false;
...@@ -3171,7 +3064,7 @@ ...@@ -3171,7 +3064,7 @@
load_dialogues_custom(); load_dialogues_custom();
} }
response.writeHead(200); response.writeHead(200);
response.end(addCallback(u.query.callback, "['loading dialogues', '" + settings.modules.dialogues.get + (settings.modules.dialogues.get_custom ? (" and " + settings.modules.dialogues.get_custom) : "") + "']")); response.end(addCallback(u.query.callback, "['loading dialogues', '" + settings.modules.dialogues.get + (settings.modules.dialogues.get_custom ? " and " + settings.modules.dialogues.get_custom : "") + "']"));
} else if (u.query.loadwords) { } else if (u.query.loadwords) {
load_words(); load_words();
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