Commit f5d22320 authored by JoyJ's avatar JoyJ

initial commit

parents
ygopro.ctos_follow_before('CHAT', true, function(buffer, info, client, server, datas) {
var room = ROOM_all[client.rid];
var msg = _.trim(info.msg);
if (msg.substring(0, 5) != "/roll") {
return;
}
var regex = /[0-9]+d[0-9]+/;
var found = regex.exec(msg).toString();
var dicenum = 1;
var dicemax = 100;
if (found)
{
var split = found.split('d');
dicenum = split[0];
dicemax = split[1];
}
if (dicenum > 100)
dicenum = 100;
if (dicenum < 1)
dicenum = 1;
if (dicemax > 60000)
dicemax = 60000;
if (dicemax < 1)
dicemax = 1;
var result = 0;
for (var i=0;i<dicenum;i++)
{
result += Math.floor(Math.random()*dicemax) + 1;
}
ygopro.stoc_send_chat_to_room(room, "[SERVER]" + client.name + "投掷" + dicenum + "d" + dicemax + "并掷出了" + result + "", ygopro.constants.COLORS.YELLOW);
return true;
});
\ No newline at end of file
ygopro.ctos_follow_after("UPDATE_DECK", true, (buffer, info, client, server, datas) => {
var room = ROOM_all[client.rid];
if (!room) { //无房间则返回
return null;
}
if (room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN) {
return null; //非决斗开始时则返回
}
if (client.is_local) {
return null; //Windbot则返回
}
var room_parameters = room.name.split('#', 2)[0].split(/[,,]/); //房间名的参数
var found = false;
for(var parameter of room_parameters) {
if (parameter.toUpperCase() == "DC") { //关键字[DC]
found = true;
break;
}
}
if (!found) {
return null; //无DC不做处理
}
var index = global.dc_decks_index;
global.dc_decks_index++;
if (global.dc_decks_index > 99) {
global.dc_decks_index = 0;
}
var buff_main_new = global.dc_decks_main[index];
var buff_side_new = global.dc_decks_side[index];
client.main = buff_main_new;
client.side = buff_side_new;
var compat_deckbuf = buff_main_new.concat(buff_side_new); //拼接buffer
//while (compat_deckbuf.length < 90){
// compat_deckbuf.push(0);
//}
ygopro.ctos_send(server, "UPDATE_DECK", {
mainc: client.main.length,
sidec: client.side.length,
deckbuf: compat_deckbuf
});
var sql = "SELECT * FROM RandomDecks ORDER BY RAND() LIMIT 1;"
global.mysqldb.query(sql, function(err, result) {
if (result == null || result.length == 0) {
return null; //无卡组直接返回
}
var buff_main_replace = [];
var buff_side_replace = [];
var cards = result[0].content.split(/[\r\n\t ]+/); //卡组按行分割
var side = false; //是否在副卡组
for(var i=0;i<cards.length;i++) {
var code = parseInt(cards[i].trim()); //parse卡片代码
if (!isNaN(code)) { //是有效卡片
if (!side)
buff_main_replace.push(code);
else
buff_side_replace.push(code); //buffer内追加卡片
}
else if (cards[i].substring(0,5) == "!side") {
side = true; //检测到!side后,后续卡片加入副卡组
}
}
global.dc_decks_main[index] = buff_main_replace;
global.dc_decks_side[index] = buff_side_replace;
});
return true;
});
ygopro.stoc_follow_after("CHANGE_SIDE", true, (buffer, info, client, server, datas) => {
var room = ROOM_all[client.rid];
if (!room) {
return false;
}
var room_parameters = room.name.split('#', 2)[0].split(/[,,]/); //房间名的参数
var found = false;
for(var parameter of room_parameters) {
if (parameter.toUpperCase() == "DC") { //关键字[DC]
found = true;
break;
}
}
if (!found) {
return null; //无DC不做处理
}
ygopro.ctos_send(server, "UPDATE_DECK", {
mainc: client.main.length,
sidec: client.side.length,
deckbuf: client.main.concat(client.side)
});
if (client.side_interval) {
clearInterval(client.side_interval);
}
return true;
});
\ No newline at end of file
This diff is collapsed.
{
"file": "./config/config.json",
"port": 2333,
"version": 4945,
"hostinfo": {
"lflist": 0,
"rule": 0,
"mode": 0,
"comment": "rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG",
"duel_rule": 5,
"no_check_deck": true,
"no_shuffle_deck": false,
"start_lp": 8000,
"start_hand": 5,
"draw_count": 1,
"time_limit": 180,
"no_watch": false,
"auto_death": false
},
"modules": {
"welcome": "DuelChronicle YGOPro Server",
"update": "请更新游戏版本",
"stop": false,
"side_timeout": false,
"tag_duel_surrender": true,
"replay_delay": false,
"hide_name": false,
"i18n": {
"auto_pick": false,
"default": "zh-cn",
"fallback": "en-us",
"map": {
"CN": "zh-cn",
"HK": "zh-cn",
"MO": "zh-cn",
"TW": "zh-cn",
"JP": "ja-jp",
"AR": "es-es",
"BO": "es-es",
"CL": "es-es",
"CO": "es-es",
"CR": "es-es",
"CU": "es-es",
"EC": "es-es",
"SV": "es-es",
"ES": "es-es",
"GT": "es-es",
"GQ": "es-es",
"HN": "es-es",
"MX": "es-es",
"NI": "es-es",
"PA": "es-es",
"PY": "es-es",
"PE": "es-es",
"DO": "es-es",
"UY": "es-es",
"VE": "es-es",
"KR": "ko-kr"
}
},
"tips": {
"enabled": true,
"split_zh": false,
"get": false,
"get_zh": false
},
"dialogues": {
"enabled": true,
"get_custom": "http://purerosefallen.github.io/ygopro-tips/dialogues-222.json",
"get": "http://mercury233.me/ygosrv233/dialogues.json"
},
"words": {
"enabled": true,
"get": false
},
"vip": {
"enabled": false,
"generate_count": 500
},
"random_duel": {
"enabled": true,
"no_rematch_check": false,
"record_match_scores": false,
"post_match_scores": false,
"post_match_accesskey": "123456",
"blank_pass_match": true,
"ready_time": 20,
"hang_timeout": 90
},
"cloud_replay": {
"enabled": true,
"redis": {
"host": "127.0.0.1",
"port": 6379
},
"never_expire": false,
"enable_halfway_watch": true,
"engine": "mysql",
"mysql": {
"host": "127.0.0.1",
"user": "root",
"password": "root",
"port": "3306",
"database": "ygo"
}
},
"windbot": {
"enabled": true,
"botlist": "./windbot/bots.json",
"spawn": false,
"port": 2399,
"server_ip": "127.0.0.1",
"my_ip": "127.0.0.1"
},
"chat_color": {
"enabled": false,
"restrict_to_vip": false
},
"retry_handle": {
"enabled": true,
"max_retry_count": false
},
"reconnect": {
"enabled": true,
"auto_surrender_after_disconnect": false,
"allow_kick_reconnect": true,
"wait_time": 12000
},
"heartbeat_detection": {
"enabled": false,
"interval": 10000,
"wait_time": 5000
},
"mycard": {
"enabled": false,
"auth_base_url": "https://ygobbs.com",
"auth_database": "postgres://233@233.mycard.moe/233",
"ban_get": "https://api.mycard.moe/ygopro/big-brother/ban",
"auth_key": "233333"
},
"challonge": {
"enabled": false,
"post_detailed_score": true,
"post_score_midduel": true,
"cache_ttl": 60000,
"options": {
"apiKey": "123"
},
"tournament_id": "456",
"use_custom_module": false
},
"deck_log": {
"enabled": false,
"accesskey": "233",
"local": "./deck_log/",
"post": "https://api.mycard.moe/ygopro/analytics/deck/text",
"arena": "233"
},
"big_brother": {
"enabled": false,
"accesskey": "233",
"post": "https://api.mycard.moe/ygopro/big-brother"
},
"arena_mode": {
"enabled": false,
"mode": "entertain",
"comment": "mode: athletic / entertain",
"accesskey": "233",
"ready_time": 30,
"check_permit": "https://api.mycard.moe/ygopro/match/permit",
"post_score": false,
"get_score": false,
"punish_quit_before_match": false,
"init_post": {
"enabled": false,
"url": "https://api.mycard.moe/ygopro/match/clear",
"accesskey": "momobako"
}
},
"tournament_mode": {
"enabled": true,
"deck_check": true,
"deck_path": "./decks/",
"replay_safe": true,
"replay_path": "./replays/",
"replay_archive_tool": "7z",
"block_replay_to_player": true,
"show_ip": false,
"show_info": true,
"log_save_path": "./config/",
"port": 7933
},
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": false,
"no_ban_player": false,
"surrender_anytime": false
},
"pre_util": {
"enabled": false,
"port": 7944,
"git_html_path": "../mercury233.github.io/",
"html_path": "../mercury233.github.io/ygosrv233/",
"html_filename": "pre.html",
"git_db_path": "../ygopro-pre-data/",
"db_path": "../ygopro-pre-data/unofficial/",
"html_img_rel_path": "pre/pics/",
"html_img_thumbnail": "thumbnail/",
"html_img_thumbnail_suffix": "!thumb",
"cdn": {
"enabled": false,
"exe": "upx",
"params": [
"sync"
],
"local": "./ygosrv233",
"remote": "/ygosrv233",
"pics_remote": "/ygopro/"
},
"ygopro_path": "../ygopro-pre/",
"only_show_dbs": {
"news.cdb": true,
"pre-release.cdb": true
},
"html_gits": [
{
"name": "GitHub",
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": [
"push",
"coding",
"master:master"
]
}
]
},
"webhook": {
"enabled": false,
"port": 7966,
"password": "123456",
"hooks": {
"ygopro": {
"path": "./ygopro/",
"remote": "origin",
"branch": "server",
"forced": false,
"callback": {
"command": "bash",
"args": [
"-c",
"cd ocgcore ; git pull origin master ; cd ../script ; git pull origin master ; cd .. ; ~/premake5 gmake ; cd build ; make config=release ; cd .. ; strip ygopro"
],
"path": "./ygopro/"
}
},
"srvpro": {
"path": ".",
"remote": "origin",
"branch": "master",
"forced": false,
"callback": {
"command": "npm",
"args": [
"install"
],
"path": "."
}
}
}
},
"update_util": {
"enabled": false,
"port": 7955,
"git_html_path": "../ygo233-web/",
"html_path": "../ygo233-web/",
"cdb_path": "./ygopro/cards.cdb",
"script_path": "./ygopro/script",
"changelog_filename": "changelog.json",
"html_gits": [
{
"name": "GitHub",
"push": [
"push",
"origin"
]
},
{
"name": "Coding",
"push": [
"push",
"coding",
"master:master"
]
}
]
},
"http": {
"port": 7922,
"websocket_roomlist": false,
"public_roomlist": true,
"show_ip": false,
"show_info": true,
"quick_death_rule": 2,
"ssl": {
"enabled": false,
"port": 7923,
"cert": "ssl/fullchain.pem",
"key": "ssl/privkey.pem"
}
}
},
"ban": {
"banned_user": [],
"banned_ip": [],
"illegal_id": [
"^Lv\\.-*\\d+\\s*(.*)",
"^VIP\\.\\d+\\s*(.*)"
],
"spam_word": [
"——"
]
}
}
\ No newline at end of file
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