Commit 70ef0ba3 authored by nanahira's avatar nanahira

Merge branch 'master' into databasen

parents 693361fd d6690872
......@@ -8,12 +8,17 @@ password.json
config.*.json
config.user.bak
ygopro-7210srv
ygopro-222DIY
ygopro-2pick
/bak
/config
/ygopro
/windbot
/decks
/decks_save*
/deck_log*
/replays
/node_modules
/ssl
......@@ -35,3 +40,8 @@ ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
*.csv
/lflist.conf
config.user.bak
......@@ -27,20 +27,20 @@ build_lite:
- docker build --pull --no-cache -f ./Dockerfile.lite -t $CONTAINER_TEST_IMAGE_LITE .
- docker push $CONTAINER_TEST_IMAGE_LITE
upload_stuff_to_minio:
stage: deploy
tags:
- linux
image: $CONTAINER_TEST_IMAGE
script:
- apt update ; apt -y install python3-pip
- pip3 install -U -i https://mirrors.aliyun.com/pypi/simple/ awscli
- cd /ygopro-server
- mkdir /dist
- tar zcfv /dist/ygopro-server.tar.gz ./*
- aws s3 --endpoint=https://minio.mycard.moe:9000 cp /dist/ygopro-server.tar.gz s3://mycard/srvpro/ygopro-server.tar.gz
only:
- master
#upload_stuff_to_minio:
# stage: deploy
# tags:
# - linux
# image: $CONTAINER_TEST_IMAGE
# script:
# - apt update ; apt -y install python3-pip
# - pip3 install -U -i https://mirrors.aliyun.com/pypi/simple/ awscli
# - cd /ygopro-server
# - mkdir /dist
# - tar zcfv /dist/ygopro-server.tar.gz ./*
# - aws s3 --endpoint=https://minio.mycard.moe:9000 cp /dist/ygopro-server.tar.gz s3://mycard/srvpro/ygopro-server.tar.gz
# only:
# - master
deploy_latest:
stage: deploy
......
......@@ -15,7 +15,7 @@ RUN npm ci && \
mkdir config decks replays logs /redis
# ygopro
RUN git clone --branch=server --recursive --depth=1 https://github.com/moecube/ygopro && \
RUN git clone --branch=server --recursive --depth=1 https://github.com/purerosefallen/ygopro && \
cd ygopro && \
git submodule foreach git checkout master && \
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz | tar zfx - && \
......@@ -30,7 +30,7 @@ RUN git clone --branch=server --recursive --depth=1 https://github.com/moecube/y
ls gframe | sed '/game.cpp/d' | xargs -I {} rm -rf gframe/{}
# windbot
RUN git clone --depth=1 https://github.com/moecube/windbot /tmp/windbot && \
RUN git clone --depth=1 https://github.com/purerosefallen/windbot /tmp/windbot && \
cd /tmp/windbot && \
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5" && \
mv /tmp/windbot/bin/Release /ygopro-server/windbot && \
......
......@@ -12,7 +12,7 @@ WORKDIR /ygopro-server
RUN npm ci && \
mkdir config decks replays logs
RUN git clone --branch=server --recursive --depth=1 https://github.com/moecube/ygopro && \
RUN git clone --branch=server --recursive --depth=1 https://github.com/purerosefallen/ygopro && \
cd ygopro && \
git submodule foreach git checkout master && \
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx - && \
......
......@@ -35,11 +35,11 @@
* 安装修改后的YGOPro服务端:https://github.com/moecube/ygopro/tree/server
* `node ygopro-server.js`即可运行
* 简易的控制台在 http://srvpro.ygo233.com/dashboard.html 或 http://srvpro-cn.ygo233.com/dashboard.html
* 使用本项目的Docker镜像: https://hub.docker.com/r/mycard/ygopro-server/
* 使用本项目的Docker镜像: https://hub.docker.com/r/nanahira/ygopro-server/
* 镜像标签
* `mycard/ygopro-server:latest`: 完整镜像
* `mycard/ygopro-server:lite`: 基本镜像,云录像和人机对战功能需要配合`redis``nanahira/windbot`这两个镜像使用。
* `nanahira/ygopro-server:latest`: 完整镜像
* `nanahira/ygopro-server:lite`: 基本镜像,云录像和人机对战功能需要配合`redis``nanahira/windbot`这两个镜像使用。
* 端口
* `7911`: YGOPro端口
......
......@@ -23,6 +23,7 @@
"update": "请更新游戏版本",
"stop": false,
"side_timeout": false,
"tag_duel_surrender": true,
"replay_delay": true,
"hide_name": false,
"display_watchers": false,
......@@ -61,12 +62,23 @@
},
"tips": {
"enabled": true,
"get": false
"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,
"default_type": "S",
......@@ -105,7 +117,8 @@
"my_ip": "127.0.0.1"
},
"chat_color": {
"enabled": false
"enabled": false,
"restrict_to_vip": false
},
"retry_handle": {
"enabled": true,
......
......@@ -11,7 +11,19 @@
"tips": [
"欢迎来到本服务器",
"本服务器使用萌卡代码搭建"
],
"tips_zh": []
},
"words": {
"file": "./config/words.json",
"words": {
"test1": [
"test_word_1"
],
"test2": [
"test_word_2"
]
}
},
"dialogues": {
"file": "./config/dialogues.json",
......@@ -22,6 +34,14 @@
"58481572": [
"我们来做朋友吧!"
]
},
"dialogues_custom": {
"37564303": [
"泡沫君のようだ\n触れて壊さぬように\n刹那哀のまほろば\n見守るよ"
],
"37564765": [
"キラキラひかる空\n二つ並ぶ白い雲\nスカートなびかせて\n裾を掴む影ぼうし"
]
}
},
"duel_log": {
......@@ -32,6 +52,20 @@
"file": "./config/chat_color.json",
"save_list": {}
},
"vip_info": {
"file": "./config/vip_info.json",
"cdkeys": {
"365": [],
"180": [],
"90": [],
"30": [],
"15": [],
"7": [],
"3": [],
"1": []
},
"players": {}
},
"users": {
"file": "./config/admin_user.json",
"permission_examples": {
......@@ -49,7 +83,8 @@
"kick_user": true,
"start_death": true,
"pre_dashboard": true,
"update_dashboard": true
"update_dashboard": true,
"vip": true
},
"judge": {
"get_rooms": true,
......
......@@ -89,6 +89,14 @@
"chat_order_tip": "/tip show a tip",
"chat_order_chatcolor_1": "/color show the current chat color, /color colorname set the chat color",
"chat_order_chatcolor_2": "/color default restore the default chat color, /color help list all available color",
"chat_order_vip": "/vip to view your supporter info, /vip help to view the help of supporter",
"chat_order_vip_help": "/vip help to show this list",
"chat_order_vip_status": "/vip status to view your supporter info",
"chat_order_vip_buy": "/vip buy YOUR_KEY to become a supporter",
"chat_order_vip_password": "/vip password NEW_PASSWORD to change password",
"chat_order_vip_dialogues": "/vip dialogues CARD_CODE DIALOGUE to set a dialogue for a specific card",
"chat_order_vip_words": "/vip words WORD to set your word when joining in the server",
"chat_order_vip_victory": "/vip victory WORD to set your word when you win a duel",
"room_name": "Room name is",
"banned_chat_tip": "You are banned from chatting.",
"banned_duel_tip": "You are banned from the random duel system for sending inappropriate messages.",
......@@ -106,6 +114,8 @@
"afk_warn_part1": "no opreation too long, will be disconnected after ",
"afk_warn_part2": " seconds",
"surrender_confirm": "Are you sure? Enter /surrender again to confirm.",
"surrender_confirm_tag": "Your partner started a surrender request, click Surrender Button or type /surrender to confirm.",
"surrender_confirm_sent": "Surrender request sent, waiting for partner to confirm.",
"surrender_canceled": "Surrender canceled.",
"surrender_denied": "Please don't surrender in the first 2 turns.",
"unwelcome_warn_part1": "If you keep doing ",
......@@ -161,6 +171,28 @@
"challonge_match_already_finished": "Your current match was already finished. Please call the judge for any help.",
"challonge_match_created": "A room for match only is created. Your opponent will join in automatically.",
"challonge_player_already_in": "Please do not enter the room you are already in.",
"vip_remain_part1": "Your supporter identity will be expired at ",
"vip_remain_part2": ". Thanks for your support.",
"vip_remain": "You have already been a supporter. Welcome back!",
"vip_not_bought": "You are not a supporter yet. enter /vip buy KEY to become one.",
"vip_expired_part1": "Your supporter identity have been expired at ",
"vip_expired_part2": ". Welcome to support again.",
"vip_account_existed": "Your username has already taken by other players. Please use another username to support.",
"vip_key_not_found": "Key not found.",
"vip_success_new_part1": "Support success. Use ",
"vip_success_new_part2": " as your name to get the supporter goodies. Thanks for your support.",
"vip_success_renew": "Support success. Thanks again for your support.",
"vip_invalid_card_code": "Invalid card code.",
"vip_cleared_dialogues_part1": "Deleted the dialogue for ",
"vip_cleared_dialogues_part2": ".",
"vip_set_dialogues_part1": "Dialogue for ",
"vip_set_dialogues_part2": " have been set.",
"vip_cleared_words": "Your join word have been deleted.",
"vip_set_words": "Your join word have been set.",
"vip_cleared_victory": "Your victory word have been deleted.",
"vip_set_victory": "Your victory word have been set.",
"vip_password_changed": "Password changed.",
"vip_player_name_too_long": "Your username or password is too long to log in. Please change your username and try again.",
"replay_hint_part1": "Sending the replay of the duel number ",
"replay_hint_part2": ".",
"arena_wait_hint": "If you opponent does not appear within 25 seconds, you may quit without any penalty.",
......@@ -407,6 +439,14 @@
"chat_order_tip": "/tip 显示一条提示",
"chat_order_chatcolor_1": "/color 查看自己的聊天文字颜色,/color 颜色名 设定自己的聊天文字颜色",
"chat_order_chatcolor_2": "/color default 恢复默认聊天字体颜色,/color help 查看所有可用的颜色",
"chat_order_vip": "/vip 查看捐助信息,/vip help 显示捐助指令帮助",
"chat_order_vip_help": "/vip help 显示此帮助",
"chat_order_vip_status": "/vip status 查看自己的捐助信息",
"chat_order_vip_buy": "/vip buy 卡密 获取捐助特权",
"chat_order_vip_password": "/vip password 新密码 修改自己的密码",
"chat_order_vip_dialogues": "/vip dialogues 卡号 台词 设置特定卡的召唤台词",
"chat_order_vip_words": "/vip words 台词 设置自己的进场台词",
"chat_order_vip_victory": "/vip victory 台词 设置自己的胜利台词",
"room_name": "您当前的房间名是",
"banned_chat_tip": "您已被禁言!",
"banned_duel_tip": "您的发言存在严重不适当的内容,禁止您使用随机对战功能!",
......@@ -424,6 +464,8 @@
"afk_warn_part1": "已经很久没有操作了,若继续挂机,将于",
"afk_warn_part2": "秒后被请出房间",
"surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。",
"surrender_confirm_tag": "您的队友发起了投降请求,点击投降按钮或输入 /投降 以确认。",
"surrender_confirm_sent": "已发起投降请求,请等待队友确认。",
"surrender_canceled": "已取消投降,加油!",
"surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。",
"unwelcome_warn_part1": "如果您经常",
......@@ -479,6 +521,28 @@
"challonge_match_already_finished": "你在当前轮次的比赛已经结束,如需重赛,请联系裁判。",
"challonge_match_created": "已建立比赛专用房间,将会自动匹配你的对手。",
"challonge_player_already_in": "请不要重复加入比赛房间。",
"vip_remain_part1": "你的捐助者特权将在 ",
"vip_remain_part2": " 时到期。感谢您的支持。",
"vip_remain": "尊敬的捐助者,欢迎回来。",
"vip_not_bought": "你还未成为捐助者。输入 /vip buy 卡密 进行捐助。",
"vip_expired_part1": "你的捐助者特权已在 ",
"vip_expired_part2": " 时到期。欢迎再次捐助。",
"vip_account_existed": "你的用户名已被其他人使用,请更换用户名进行捐助。",
"vip_key_not_found": "卡密不存在。",
"vip_success_new_part1": "捐助成功。进房时输入 ",
"vip_success_new_part2": " 即可享受捐助特权。感谢您对服务器的支持。",
"vip_success_renew": "续费成功。感谢您对服务器的再次支持。",
"vip_invalid_card_code": "非法卡号。",
"vip_cleared_dialogues_part1": "已删除 ",
"vip_cleared_dialogues_part2": " 的召唤台词。",
"vip_set_dialogues_part1": "已为 ",
"vip_set_dialogues_part2": " 设置召唤台词。",
"vip_cleared_words": "已删除进场台词。",
"vip_set_words": "已设置进场台词。",
"vip_cleared_victory": "已删除胜利台词。",
"vip_set_victory": "已设置胜利台词。",
"vip_password_changed": "密码修改成功。",
"vip_player_name_too_long": "你的用户名或设置的密码太长,使用此用户名可能会无法登陆。请更换用户名重试。",
"replay_hint_part1": "正在发送第",
"replay_hint_part2": "局决斗的录像。",
"arena_wait_hint": "若对手在25秒内不进入游戏,您退房时不会进行扣分。",
......
/*
ygopro-draw.js
get card usage from decks
Author: Nanahira
License: MIT
generate a lflist.conf for drafts.
the config file is at ./config/draw.json, which should be:
{
"dbfile": "ygopro/cards.cdb",
"lflist": "ygopro/lflist.conf",
"list": "2018.7",
"main": 600,
"extra": 300,
"output": "./lflist.conf"
"output_plain": "./pool_plain.txt"
}
*/
var sqlite3 = require('sqlite3').verbose();
var fs = require('fs');
var loadJSON = require('load-json-file').sync;
var config = loadJSON('./config/draw.json');
var constants = loadJSON('./data/constants.json');
var ALL_MAIN_CARDS={};
var ALL_EXTRA_CARDS={};
var CARD_RESULT={};
var CARD_RESULT_PLAIN=[[], [], [], []];
var LFLIST={"unknown": []};
var MAIN_POOL=[];
var EXTRA_POOL=[];
function load_database(callback) {
var db=new sqlite3.Database(config.dbfile);
db.each("select * from datas,texts where datas.id=texts.id", function (err,result) {
if (err) {
console.log(config.dbfile + ":" + err);
return;
}
else {
if ((result.type & constants.TYPES.TYPE_TOKEN) || result.alias) {
return;
}
CARD_RESULT[result.id] = 0;
if((result.type & constants.TYPES.TYPE_FUSION) || (result.type & constants.TYPES.TYPE_SYNCHRO) || (result.type & constants.TYPES.TYPE_XYZ) || (result.type & constants.TYPES.TYPE_LINK)) {
ALL_EXTRA_CARDS[result.id] = 3;
} else {
ALL_MAIN_CARDS[result.id] = 3;
}
}
}, callback);
}
function load_lflist() {
var raw = fs.readFileSync(config.lflist, 'utf8').split(/\n/g);
var current_list = "unknown";
for(var i in raw) {
var line = raw[i];
if(line.match(/!(.+)/)) {
current_list = line.match(/!(.+)/)[1];
if (!LFLIST[current_list]) {
LFLIST[current_list] = {};
}
} else if (line.match(/(\d+) 0/)) {
LFLIST[current_list][parseInt(line.match(/(\d+) 0/)[1])] = 0;
} else if (line.match(/(\d+) 1/)) {
LFLIST[current_list][parseInt(line.match(/(\d+) 1/)[1])] = 1;
} else if (line.match(/(\d+) 2/)) {
LFLIST[current_list][parseInt(line.match(/(\d+) 2/)[1])] = 2;
}
}
if (LFLIST[config.list]) {
for(var code in LFLIST[config.list]) {
count = LFLIST[config.list][code];
if(ALL_MAIN_CARDS[code] === 3) {
ALL_MAIN_CARDS[code] = count;
} else if (ALL_EXTRA_CARDS[code] === 3) {
ALL_EXTRA_CARDS[code] = count;
}
}
}
generate_pool();
}
function generate_pool() {
for (var code in ALL_MAIN_CARDS) {
var count = ALL_MAIN_CARDS[code];
for (var i = 0; i < count; ++i) {
MAIN_POOL.push(code);
}
}
for (var code in ALL_EXTRA_CARDS) {
var count = ALL_EXTRA_CARDS[code];
for (var i = 0; i < count; ++i) {
EXTRA_POOL.push(code);
}
}
pick_cards();
}
function pick_cards() {
for (var i = 0; i < config.main; ++i) {
var l = MAIN_POOL.length;
if (!l) {break;}
var index = Math.floor(Math.random() * l);
var code = MAIN_POOL[index];
if(CARD_RESULT[code] < 3) {
CARD_RESULT[code]++;
}
MAIN_POOL.splice(index, 1);
}
for (var i = 0; i < config.extra; ++i) {
var l = EXTRA_POOL.length;
if (!l) {break;}
var index = Math.floor(Math.random() * l);
var code = EXTRA_POOL[index];
if(CARD_RESULT[code] < 3) {
CARD_RESULT[code]++;
}
EXTRA_POOL.splice(index, 1);
}
output();
}
function output() {
var op = "#[Random]\n\n!Random\n";
var op_plain = "";
for (var code in CARD_RESULT) {
op = op + code + " " + CARD_RESULT[code] + "\n";
if(CARD_RESULT[code] > 0) {
CARD_RESULT_PLAIN[CARD_RESULT[code]].push(code);
}
}
for (var i = 1; i < 4; ++i) {
for (var j in CARD_RESULT_PLAIN[i]) {
const code = CARD_RESULT_PLAIN[i][j];
op_plain = op_plain + code + " " + i + "\n";
}
}
fs.writeFile(config.output, op, 'utf-8', function(err) {
if (err) {
console.log(err);
}
});
console.log(op_plain);
}
load_database(load_lflist);
\ No newline at end of file
/*
ygopro-generate-result.js
ygopro tournament result generator
Author: Yuzurisa
License: MIT
Will generate the tournament result in a specific format.
*/
var output_path = "./config"
if (process.argv[2])
output_path = process.argv[2];
const loadJSON = require('load-json-file').sync;
const fs = require('fs');
const settings = loadJSON('./config/config.json');
const challonge_config = settings.modules.challonge;
if (challonge_config.enabled) {
challonge = require('challonge').createClient({
apiKey: challonge_config.api_key
});
} else {
console.error("Challonge is not enabled.");
return 1;
}
var name_list = {};
var results = {};
console.log("Requesting player datas from Challonge.");
challonge.participants.index({
id: challonge_config.tournament_id,
callback: (error, data) => {
if (error || !data) {
console.error(error);
return;
}
for (var k in data) {
const player = data[k];
if (!player || !player.participant) {
continue;
}
const player_info = player.participant;
const name = player_info.name;
const id = player_info.id;
name_list[id] = name;
}
console.log("Requesting match datas from Challonge.");
//for (var i = 1; i <=)
challonge.matches.index({
id: challonge_config.tournament_id,
callback: (error, data) => {
if (error || !data) {
console.error(error);
return;
}
for (var k in data) {
const match = data[k];
if (!match || !match.match) {
continue;
}
const match_info = match.match;
if (match_info.state != "complete") {
continue;
}
const sign = match_info.identifier;
const round = match_info.round;
const scores = match_info.scoresCsv;
const scores_data = scores.split("-")
if (!scores_data || scores_data.length != 2)
continue;
const player1 = match_info.player1Id;
const player2 = match_info.player2Id;
const match_txt = "[" + sign + "]组:\n [1号]" + name_list[player1] + " " + scores_data[0] + "\n [2号]" + name_list[player2] + " " + scores_data[1] + "\n";
if (!results[round])
results[round] = [];
results[round].push(match_txt);
}
console.log("Request completed. Outputing data.")
var player_text = "";
for (var k in name_list) {
player_text = player_text + name_list[k] + "\n";
}
fs.writeFileSync(output_path + "/player_list.txt", player_text);
for (var k in results) {
const round_data = results[k];
var text = "";
for (var k1 in round_data) {
text = text + round_data[k1];
}
fs.writeFileSync(output_path + "/match_" + k + ".txt", text);
}
console.log("Finished.")
}
})
}
})
......@@ -217,14 +217,14 @@ var writeToFile = function(message, callback) {
_async.auto({
write: (done) => {
fs.writeFile(config.html_path + config.html_filename, fileContent, done)
},
}/*,
copy: ["write", (results, done) => {
if (!config.cdn.enabled) {
copyImages(done);
} else {
done();
}
}]
}]*/
}, (err) => {
if (!err) {
sendResponse("列表更新完成。");
......@@ -300,7 +300,10 @@ var pushDatas = function(callback) {
pushHTMLs(done);
}]
}, callback);
} else {
pushHTMLs(callback);
}
}
var pushHTMLs = function(callback) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -81,6 +81,7 @@ var makeChangelogs = function(dir, since) {
if (prc_git_log.stdout) {
var logs = prc_git_log.stdout.toString().split(/\n/g);
for (var i in logs) {
console.log(logs[i])
var log = logs[i].split(",");
var date = log[1];
if (date) {
......@@ -88,7 +89,8 @@ var makeChangelogs = function(dir, since) {
if (prc_git_diff.stdout) {
var lines = prc_git_diff.stdout.toString().split(/\n/g);
for (var j in lines) {
var line = lines[j].match(/c(\d+)\.lua/);
console.log(lines[j])
var line = lines[j].match(/.*c(\d+)\.lua.*/);
if (line) {
var name = cardNames[line[1]] || line[1];
addedCards.push(name);
......@@ -99,6 +101,7 @@ var makeChangelogs = function(dir, since) {
}
}
for (var i in logs) {
console.log(logs[i])
var log = logs[i].split(",");
var date = log[1];
if (date) {
......@@ -106,7 +109,8 @@ var makeChangelogs = function(dir, since) {
if (prc_git_diff.stdout) {
var lines = prc_git_diff.stdout.toString().split(/\n/g);
for (var j in lines) {
var line = lines[j].match(/c(\d+)\.lua/);
console.log(lines[j])
var line = lines[j].match(/.*c(\d+)\.lua.*/);
if (line) {
var name = cardNames[line[1]] || line[1];
sendResponse("<span class='change'>" + date + " * " + name + "</span>");
......
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