Commit 7c31bd73 authored by nanahira's avatar nanahira

Merge branch 'master' into tcg_random

parents 456fb764 44af210f
...@@ -3,22 +3,10 @@ FROM node:12-stretch-slim ...@@ -3,22 +3,10 @@ FROM node:12-stretch-slim
# apt # apt
RUN apt update && \ RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libssl1.0-dev libsqlite3-dev mono-complete p7zip-full redis-server env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libevent-dev libsqlite3-dev mono-complete p7zip-full redis-server
RUN npm install -g pm2 RUN npm install -g pm2
# libevent
WORKDIR /
RUN wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate && \
tar xf libevent-2.0.22-stable.tar.gz && \
cd libevent-2.0.22-stable/ && \
./configure && \
make && \
make install && \
cd .. && \
bash -c 'ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5;ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5;exit 0' && \
rm -rf /libevent-2.0.22-stable.tar.gz /libevent-2.0.22-stable
# srvpro # srvpro
COPY . /ygopro-server COPY . /ygopro-server
WORKDIR /ygopro-server WORKDIR /ygopro-server
......
...@@ -3,19 +3,7 @@ FROM node:12-stretch-slim ...@@ -3,19 +3,7 @@ FROM node:12-stretch-slim
# apt # apt
RUN apt update && \ RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libssl1.0-dev libsqlite3-dev p7zip-full env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libsqlite3-dev libevent-dev p7zip-full
# libevent
WORKDIR /
RUN wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate && \
tar xf libevent-2.0.22-stable.tar.gz && \
cd libevent-2.0.22-stable/ && \
./configure && \
make && \
make install && \
cd .. && \
bash -c 'ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5;ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5;ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5;exit 0' && \
rm -rf /libevent-2.0.22-stable.tar.gz /libevent-2.0.22-stable
# srvpro # srvpro
COPY . /ygopro-server COPY . /ygopro-server
......
{
"file": "./config/admin_user.json",
"permission_examples": {
"sudo": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"clear_duel_log": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"stop": true,
"change_settings": true,
"ban_user": true,
"kick_user": true,
"start_death": true,
"pre_dashboard": true,
"update_dashboard": true,
"vip": true
},
"judge": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
},
"streamer": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true
}
},
"users": {
"root": {
"password": "Nanahira",
"enabled": true,
"permissions": "sudo"
}
}
}
{
"file": "./config/config.json",
"port": 7210,
"version": 4930,
"hostinfo": {
"lflist": 0,
"rule": 0,
"mode": 0,
"comment": "rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG",
"enable_priority": false,
"no_check_deck": false,
"no_shuffle_deck": false,
"start_lp": 8000,
"start_hand": 5,
"draw_count": 1,
"time_limit": 180
},
"modules": {
"welcome": "YGOPro Koishi Server",
"update": "请更新游戏版本",
"stop": false,
"side_timeout": 3,
"tag_duel_surrender": true,
"replay_delay": true,
"i18n": {
"auto_pick": true,
"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,
"get": "https://purerosefallen.github.io/ygopro-tips/tips.json"
},
"dialogues": {
"enabled": true,
"get_custom": "http://purerosefallen.github.io/ygopro-tips/dialogues-222.json",
"get": "http://mercury233.me/ygosrv233/dialogues.json"
},
"words": {
"enabled": false,
"get": false
},
"vip": {
"enabled": false,
"generate_count": 500
},
"pre_release_compat": {
"enabled": false,
"official_database": "./ygopro/cards.cdb",
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
},
"random_duel": {
"enabled": true,
"no_rematch_check": false,
"hang_timeout": 90
},
"cloud_replay": {
"enabled": true,
"redis": {
"host": "127.0.0.1",
"port": 6379
},
"enable_halfway_watch": true
},
"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": true
},
"retry_handle": {
"enabled": true,
"max_retry_count": false
},
"reconnect": {
"enabled": true,
"auto_surrender_after_disconnect": false,
"allow_kick_reconnect": true,
"wait_time": 180000
},
"heartbeat_detection": {
"enabled": false,
"interval": 20000,
"wait_time": 10000
},
"mycard": {
"enabled": false,
"auth_base_url": "https://ygobbs.com",
"auth_database": "postgres://233@233.mycard.moe/233",
"auth_key": "233333"
},
"challonge": {
"enabled": false,
"post_detailed_score": true,
"api_key": "123",
"tournament_id": "456"
},
"deck_log": {
"enabled": true,
"accesskey": "233",
"local": "./decks_save/",
"post": false,
"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",
"post_score": false,
"get_score": false
},
"tournament_mode": {
"enabled": false,
"deck_check": true,
"deck_path": "./decks/",
"replay_safe": true,
"replay_path": "./replays/",
"replay_archive_tool": "7z",
"block_replay_to_player": true,
"show_ip": true,
"show_info": true,
"log_save_path": "./config/",
"port": 7212
},
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": false,
"no_ban_player": 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": true,
"port": 7213,
"password": "Nanahira",
"hooks": {
"windbot": {
"path": "./windbot/",
"remote": "origin",
"branch": "master",
"forced": true,
"callback": {
"command": "xbuild",
"args": [
"/property:Configuration=Release",
"/property:TargetFrameworkVersion=v4.5"
],
"path": "./windbot/"
}
},
"ygopro": {
"path": "./ygopro/",
"remote": "origin",
"branch": "server",
"forced": true,
"callback": {
"command": "bash",
"args": [
"-c",
"cd ocgcore ; git pull origin master ; git reset --hard FETCH_HEAD ; cd ../script ; git pull origin master ; git reset --hard FETCH_HEAD ; cd .. ; ~/premake5 gmake ; cd build ; make config=release ; cd .. ; strip ygopro"
],
"path": "./ygopro/"
}
},
"srvpro": {
"path": ".",
"remote": "origin",
"branch": "master",
"forced": true,
"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": 7211,
"websocket_roomlist": false,
"public_roomlist": false,
"show_ip": true,
"show_info": true,
"quick_death_rule": 1,
"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": [
"——"
]
}
}
{
"dbfile": "ygopro/cards.cdb",
"deckpath": "decks_save"
}
{
"file": "./config/admin_user.json",
"permission_examples": {
"sudo": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"clear_duel_log": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"stop": true,
"change_settings": true,
"ban_user": true,
"kick_user": true,
"start_death": true,
"pre_dashboard": true,
"update_dashboard": true,
"vip": true
},
"judge": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true,
"deck_dashboard_write": true,
"shout": true,
"kick_user": true,
"start_death": true
},
"streamer": {
"get_rooms": true,
"duel_log": true,
"download_replay": true,
"deck_dashboard_read": true
}
},
"users": {
"root": {
"password": "Nanahira",
"enabled": true,
"permissions": "sudo"
},
"judge": {
"password": "Clala",
"enabled": true,
"permissions": "judge"
},
"streamer": {
"password": "Aris",
"enabled": true,
"permissions": "streamer"
}
}
}
{
"file": "./config/config.json",
"port": 514,
"version": 4930,
"hostinfo": {
"lflist": 0,
"rule": 0,
"mode": 0,
"comment": "rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG",
"enable_priority": false,
"no_check_deck": false,
"no_shuffle_deck": false,
"start_lp": 8000,
"start_hand": 5,
"draw_count": 1,
"time_limit": 180
},
"modules": {
"welcome": "YGOPro Tourney",
"update": "请更新游戏版本",
"stop": false,
"side_timeout": 3,
"tag_duel_surrender": true,
"replay_delay": true,
"i18n": {
"auto_pick": true,
"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,
"get": "https://purerosefallen.github.io/ygopro-tips/tips.json"
},
"dialogues": {
"enabled": true,
"get_custom": "http://purerosefallen.github.io/ygopro-tips/dialogues-222.json",
"get": "http://mercury233.me/ygosrv233/dialogues.json"
},
"words": {
"enabled": false,
"get": false
},
"koishi_roomlist": {
"enabled": false
},
"vip": {
"enabled": false,
"generate_count": 500
},
"pre_release_compat": {
"enabled": false,
"official_database": "./ygopro/cards.cdb",
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
},
"random_duel": {
"enabled": false,
"no_rematch_check": false,
"hang_timeout": 90
},
"cloud_replay": {
"enabled": true,
"redis": {
"host": "127.0.0.1",
"port": 6379
},
"enable_halfway_watch": true
},
"windbot": {
"enabled": false,
"botlist": "./windbot/bots.json",
"spawn": false,
"port": 2399,
"server_ip": "127.0.0.1",
"my_ip": "127.0.0.1"
},
"chat_color": {
"enabled": false
},
"retry_handle": {
"enabled": true,
"max_retry_count": false
},
"reconnect": {
"enabled": true,
"auto_surrender_after_disconnect": false,
"allow_kick_reconnect": true,
"wait_time": 300000
},
"heartbeat_detection": {
"enabled": false,
"interval": 30000,
"wait_time": 15000
},
"mycard": {
"enabled": false,
"auth_base_url": "https://ygobbs.com",
"auth_database": "postgres://233@233.mycard.moe/233",
"auth_key": "233333"
},
"challonge": {
"enabled": false,
"post_detailed_score": true,
"post_score_midduel": true,
"cache_ttl": 60000,
"api_key": "11",
"tournament_id": "22",
"use_custom_module": false
},
"deck_log": {
"enabled": false,
"accesskey": "233",
"local": "./decks_save/",
"post": false,
"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",
"post_score": false,
"get_score": false
},
"tournament_mode": {
"enabled": true,
"deck_check": true,
"deck_path": "./decks/",
"replay_safe": true,
"replay_path": "./replays/",
"replay_archive_tool": "7z",
"block_replay_to_player": false,
"show_ip": true,
"show_info": true,
"log_save_path": "./config/",
"port": 5142
},
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": true,
"no_ban_player": true
},
"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": true,
"port": 7213,
"password": "Nanahira",
"hooks": {
"windbot": {
"path": "./windbot/",
"remote": "origin",
"branch": "master",
"callback": {
"command": "xbuild",
"args": [
"/property:Configuration=Release",
"/property:TargetFrameworkVersion=v4.5"
],
"path": "./windbot/"
}
},
"ygopro": {
"path": "./ygopro/",
"remote": "origin",
"branch": "server",
"callback": {
"command": "bash",
"args": [
"-c",
"git reset --hard FETCH_HEAD ; cd ocgcore ; git pull origin master ; git reset --hard FETCH_HEAD ; cd ../script ; git pull origin master ; git reset --hard FETCH_HEAD ; cd .. ; premake5 gmake ; cd build ; make config=release ; cd .. ; strip ygopro"
],
"path": "./ygopro/"
}
},
"srvpro": {
"path": ".",
"remote": "origin",
"branch": "master",
"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": 5141,
"websocket_roomlist": false,
"public_roomlist": false,
"show_ip": true,
"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": [
"——"
]
}
}
{
"dbfile": "ygopro/cards.cdb",
"deckpath": "decks_save"
}
...@@ -269,6 +269,14 @@ ...@@ -269,6 +269,14 @@
"LINK_MARKER_TOP": 128, "LINK_MARKER_TOP": 128,
"LINK_MARKER_TOP_RIGHT": 256 "LINK_MARKER_TOP_RIGHT": 256
}, },
"DUEL_STAGE": {
"BEGIN": 0,
"FINGER": 1,
"FIRSTGO": 2,
"DUELING": 3,
"SIDING": 4,
"END": 5
},
"COLORS": { "COLORS": {
"LIGHTBLUE": 8, "LIGHTBLUE": 8,
"RED": 11, "RED": 11,
...@@ -282,6 +290,3 @@ ...@@ -282,6 +290,3 @@
"DARKGRAY": 19 "DARKGRAY": 19
} }
} }
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
"pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb" "pre_release_database": "./../ygopro-pre-data/expansions/pre-release.cdb"
}, },
"random_duel": { "random_duel": {
"enabled": false, "enabled": true,
"no_rematch_check": false, "no_rematch_check": false,
"record_match_scores": false, "record_match_scores": false,
"post_match_scores": false, "post_match_scores": false,
......
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
sudo yum install epel-release yum-utils curl wget -y
sudo rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
curl https://download.mono-project.com/repo/centos6-stable.repo | sudo tee /etc/yum.repos.d/mono-centos6-stable.repo
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install nodejs git gcc gcc-c++ sqlite-devel readline-devel openssl-devel mono-complete -y
sudo npm install pm2 -g
mkdir lib
cd lib
wget http://download.redis.io/releases/redis-stable.tar.gz --no-check-certificate
tar xzfv redis-stable.tar.gz
cd redis-stable
make -j$PROCESS_COUNT
sudo make install
sudo cp -rf src/redis-server /usr/bin/
cd ..
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
cp -rf premake5 ~
wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate
tar xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable/
./configure
make -j$PROCESS_COUNT
sudo make install
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5
cd ..
cd ..
git clone https://github.com/purerosefallen/ygopro --branch=server --recursive
cd ygopro/
git submodule foreach git checkout master
~/premake5 gmake
cd build/
make config=release -j$PROCESS_COUNT
cd ..
ln -s bin/release/ygopro ./
strip ygopro
cd ..
git clone https://github.com/purerosefallen/windbot
cd windbot
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
ln -s bin/Release/WindBot.exe .
ln -s ../ygopro/cards.cdb .
cd ..
git clone https://github.com/purerosefallen/ygopro-server
cd ygopro-server
npm install
ln -s ../ygopro .
ln -s ../windbot .
mkdir config
cp data/default_config.json config/config.json
cd ..
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
sudo yum install epel-release yum-utils curl wget -y
sudo rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
curl https://download.mono-project.com/repo/centos7-stable.repo | sudo tee /etc/yum.repos.d/mono-centos7-stable.repo
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install nodejs git gcc gcc-c++ sqlite-devel readline-devel openssl-devel mono-complete -y
sudo npm install pm2 -g
mkdir lib
cd lib
wget http://download.redis.io/releases/redis-stable.tar.gz --no-check-certificate
tar xzfv redis-stable.tar.gz
cd redis-stable
make -j$PROCESS_COUNT
sudo make install
sudo cp -rf src/redis-server /usr/bin/
cd ..
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
cp -rf premake5 ~
wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate
tar xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable/
./configure
make -j$PROCESS_COUNT
sudo make install
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5
cd ..
cd ..
git clone https://github.com/purerosefallen/ygopro --branch=server --recursive
cd ygopro/
git submodule foreach git checkout master
~/premake5 gmake
cd build/
make config=release -j$PROCESS_COUNT
cd ..
ln -s bin/release/ygopro ./
strip ygopro
cd ..
git clone https://github.com/purerosefallen/windbot
cd windbot
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
ln -s bin/Release/WindBot.exe .
ln -s ../ygopro/cards.cdb .
cd ..
git clone https://github.com/purerosefallen/ygopro-server
cd ygopro-server
npm install
ln -s ../ygopro .
ln -s ../windbot .
mkdir config
cp data/default_config.json config/config.json
cd ..
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt-get install -y apt-transport-https curl wget
echo "deb http://download.mono-project.com/repo/ubuntu stable-trusty main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install -y git build-essential libreadline-dev libsqlite3-dev libevent-dev mono-complete nodejs
sudo npm install pm2 -g
mkdir lib
cd lib
wget http://download.redis.io/releases/redis-stable.tar.gz --no-check-certificate
tar xzfv redis-stable.tar.gz
cd redis-stable
make -j$PROCESS_COUNT
sudo make install
sudo cp -rf src/redis-server /usr/bin/
cd ..
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
cp -rf premake5 ~
cd ..
git clone https://github.com/purerosefallen/ygopro --branch=server --recursive
cd ygopro/
git submodule foreach git checkout master
~/premake5 gmake
git checkout -f
git submodule foreach git checkout -f
cd build/
make config=release -j$PROCESS_COUNT
cd ..
ln -s bin/release/ygopro ./
strip ygopro
cd ..
git clone https://github.com/purerosefallen/windbot
cd windbot
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
ln -s bin/Release/WindBot.exe .
ln -s ../ygopro/cards.cdb .
cd ..
git clone https://github.com/purerosefallen/ygopro-server
cd ygopro-server
npm install
ln -s ../ygopro .
ln -s ../windbot .
mkdir config
cp data/default_config.json config/config.json
cd ..
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt-get install -y apt-transport-https curl wget
echo "deb http://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install -y git build-essential libreadline-dev libsqlite3-dev libevent-dev mono-complete nodejs
sudo npm install pm2 -g
mkdir lib
cd lib
wget http://download.redis.io/releases/redis-stable.tar.gz --no-check-certificate
tar xzfv redis-stable.tar.gz
cd redis-stable
make -j$PROCESS_COUNT
sudo make install
sudo cp -rf src/redis-server /usr/bin/
cd ..
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
cp -rf premake5 ~
cd ..
git clone https://github.com/purerosefallen/ygopro --branch=server --recursive
cd ygopro/
git submodule foreach git checkout master
~/premake5 gmake
cd build/
make config=release -j$PROCESS_COUNT
cd ..
ln -s bin/release/ygopro ./
strip ygopro
cd ..
git clone https://github.com/purerosefallen/windbot
cd windbot
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
ln -s bin/Release/WindBot.exe .
ln -s ../ygopro/cards.cdb .
cd ..
git clone https://github.com/purerosefallen/ygopro-server
cd ygopro-server
npm install
ln -s ../ygopro .
ln -s ../windbot .
mkdir config
cp data/default_config.json config/config.json
cd ..
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt-get install -y curl wget
echo "deb http://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install -y git build-essential libreadline-dev libsqlite3-dev libssl1.0-dev mono-complete nodejs
sudo npm install pm2 -g
mkdir lib
cd lib
wget http://download.redis.io/releases/redis-stable.tar.gz --no-check-certificate
tar xzfv redis-stable.tar.gz
cd redis-stable
make -j$PROCESS_COUNT
sudo make install
sudo cp -rf src/redis-server /usr/bin/
cd ..
wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha13/premake-5.0.0-alpha13-linux.tar.gz | tar zfx -
cp -rf premake5 ~
wget 'https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz' -O libevent-2.0.22-stable.tar.gz --no-check-certificate
tar xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable/
./configure
make -j$PROCESS_COUNT
sudo make install
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib/libevent_pthreads-2.0.so.5
sudo ln -s /usr/local/lib/libevent_pthreads-2.0.so.5 /usr/lib64/libevent_pthreads-2.0.so.5
cd ..
cd ..
git clone https://github.com/purerosefallen/ygopro --branch=server --recursive
cd ygopro/
git submodule foreach git checkout master
~/premake5 gmake
cd build/
make config=release -j$PROCESS_COUNT
cd ..
ln -s bin/release/ygopro ./
strip ygopro
cd ..
git clone https://github.com/purerosefallen/windbot
cd windbot
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
ln -s bin/Release/WindBot.exe .
ln -s ../ygopro/cards.cdb .
cd ..
git clone https://github.com/purerosefallen/ygopro-server
cd ygopro-server
npm install
ln -s ../ygopro .
ln -s ../windbot .
mkdir config
cp data/default_config.json config/config.json
cd ..
#!/bin/bash
export PROCESS_COUNT=$(grep -c "processor" /proc/cpuinfo)
git fetch origin master
git reset --hard FETCH_HEAD
cd windbot
git fetch origin master
git reset --hard FETCH_HEAD
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5"
cd ../ygopro
git fetch origin server
git reset --hard FETCH_HEAD
git submodule foreach git fetch origin master
git submodule foreach git reset --hard FETCH_HEAD
~/premake5 gmake
cd build
make config=release -j$PROCESS_COUNT
cd ../
strip ygopro
cd ../
...@@ -672,7 +672,7 @@ ROOM_find_or_create_random = (type, player_ip)-> ...@@ -672,7 +672,7 @@ ROOM_find_or_create_random = (type, player_ip)->
max_player = if type == 'T' then 4 else 2 max_player = if type == 'T' then 4 else 2
playerbanned = (bannedplayer and bannedplayer.count > 3 and moment() < bannedplayer.time) playerbanned = (bannedplayer and bannedplayer.count > 3 and moment() < bannedplayer.time)
result = _.find ROOM_all, (room)-> result = _.find ROOM_all, (room)->
return room and room.random_type != '' and !room.started and !room.windbot and return room and room.random_type != '' and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and !room.windbot and
((type == '' and room.random_type != 'T' and ((!_.endsWith(room.random_type, "MR") and room.random_type != 'M') or (settings.modules.random_duel.blank_pass_match and room.random_type != 'T'))) or room.random_type == type) and ((type == '' and room.random_type != 'T' and ((!_.endsWith(room.random_type, "MR") and room.random_type != 'M') or (settings.modules.random_duel.blank_pass_match and room.random_type != 'T'))) or room.random_type == type) and
room.get_playing_player().length < max_player and room.get_playing_player().length < max_player and
(settings.modules.random_duel.no_rematch_check or room.get_host() == null or (settings.modules.random_duel.no_rematch_check or room.get_host() == null or
...@@ -801,7 +801,7 @@ CLIENT_reconnect_register = (client, room_id, error) -> ...@@ -801,7 +801,7 @@ CLIENT_reconnect_register = (client, room_id, error) ->
room = ROOM_all[room_id] room = ROOM_all[room_id]
if client.had_new_reconnection if client.had_new_reconnection
return false return false
if !settings.modules.reconnect.enabled or !room or client.system_kicked or client.flee_free or disconnect_list[CLIENT_get_authorize_key(client)] or client.is_post_watcher or !CLIENT_is_player(client, room) or !room.started or room.windbot or (settings.modules.reconnect.auto_surrender_after_disconnect and room.hostinfo.mode != 1) or (room.random_type and room.get_disconnected_count() > 1) if !settings.modules.reconnect.enabled or !room or client.system_kicked or client.flee_free or disconnect_list[CLIENT_get_authorize_key(client)] or client.is_post_watcher or !CLIENT_is_player(client, room) or room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or room.windbot or (settings.modules.reconnect.auto_surrender_after_disconnect and room.hostinfo.mode != 1) or (room.random_type and room.get_disconnected_count() > 1)
return false return false
# for player in room.players # for player in room.players
# if player != client and CLIENT_get_authorize_key(player) == CLIENT_get_authorize_key(client) # if player != client and CLIENT_get_authorize_key(player) == CLIENT_get_authorize_key(client)
...@@ -824,7 +824,7 @@ CLIENT_reconnect_register = (client, room_id, error) -> ...@@ -824,7 +824,7 @@ CLIENT_reconnect_register = (client, room_id, error) ->
if client.time_confirm_required if client.time_confirm_required
client.time_confirm_required = false client.time_confirm_required = false
ygopro.ctos_send(client.server, 'TIME_CONFIRM') ygopro.ctos_send(client.server, 'TIME_CONFIRM')
if settings.modules.reconnect.auto_surrender_after_disconnect and room.turn and room.turn > 0 if settings.modules.reconnect.auto_surrender_after_disconnect and room.duel_stage == ygopro.constants.DUEL_STAGE.DUELING
ygopro.ctos_send(client.server, 'SURRENDER') ygopro.ctos_send(client.server, 'SURRENDER')
return true return true
...@@ -888,7 +888,7 @@ CLIENT_is_able_to_reconnect = (client, deckbuf) -> ...@@ -888,7 +888,7 @@ CLIENT_is_able_to_reconnect = (client, deckbuf) ->
return true return true
CLIENT_get_kick_reconnect_target = (client, deckbuf) -> CLIENT_get_kick_reconnect_target = (client, deckbuf) ->
for room in ROOM_all when room and room.started and !room.windbot for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and !room.windbot
for player in room.get_playing_player() when !player.closed and player.name == client.name and (settings.modules.challonge.enabled or player.pass == client.pass) and (settings.modules.mycard.enabled or settings.modules.tournament_mode.enabled or player.ip == client.ip or (client.vpass and client.vpass == player.vpass)) and (!deckbuf or _.isEqual(player.start_deckbuf, deckbuf)) for player in room.get_playing_player() when !player.closed and player.name == client.name and (settings.modules.challonge.enabled or player.pass == client.pass) and (settings.modules.mycard.enabled or settings.modules.tournament_mode.enabled or player.ip == client.ip or (client.vpass and client.vpass == player.vpass)) and (!deckbuf or _.isEqual(player.start_deckbuf, deckbuf))
return player return player
return null return null
...@@ -919,25 +919,28 @@ CLIENT_send_pre_reconnect_info = (client, room, old_client) -> ...@@ -919,25 +919,28 @@ CLIENT_send_pre_reconnect_info = (client, room, old_client) ->
CLIENT_send_reconnect_info = (client, server, room) -> CLIENT_send_reconnect_info = (client, server, room) ->
client.reconnecting = true client.reconnecting = true
ygopro.stoc_send_chat(client, "${reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE)
if room.turn and room.turn > 0 switch room.duel_stage
ygopro.ctos_send(server, 'REQUEST_FIELD') when ygopro.constants.DUEL_STAGE.FINGER
else if room.changing_side ygopro.stoc_send(client, 'DUEL_START')
ygopro.stoc_send(client, 'DUEL_START') if (room.hostinfo.mode != 2 or client.pos == 0 or client.pos == 2) and !client.selected_preduel
if !client.selected_preduel ygopro.stoc_send(client, 'SELECT_HAND')
ygopro.stoc_send(client, 'CHANGE_SIDE') client.reconnecting = false
client.reconnecting = false break
else if room.selecting_hand when ygopro.constants.DUEL_STAGE.FIRSTGO
ygopro.stoc_send(client, 'DUEL_START') ygopro.stoc_send(client, 'DUEL_START')
if (room.hostinfo.mode != 2 or client.pos == 0 or client.pos == 2) and !client.selected_preduel if client == room.selecting_tp # and !client.selected_preduel
ygopro.stoc_send(client, 'SELECT_HAND') ygopro.stoc_send(client, 'SELECT_TP')
client.reconnecting = false client.reconnecting = false
else if room.selecting_tp break
ygopro.stoc_send(client, 'DUEL_START') when ygopro.constants.DUEL_STAGE.SIDING
if client == room.selecting_tp # and !client.selected_preduel ygopro.stoc_send(client, 'DUEL_START')
ygopro.stoc_send(client, 'SELECT_TP') if !client.selected_preduel
client.reconnecting = false ygopro.stoc_send(client, 'CHANGE_SIDE')
else client.reconnecting = false
ygopro.ctos_send(server, 'REQUEST_FIELD') break
else
ygopro.ctos_send(server, 'REQUEST_FIELD')
break
return return
CLIENT_pre_reconnect = (client) -> CLIENT_pre_reconnect = (client) ->
...@@ -1103,11 +1106,11 @@ replace_buffer = (buffer, list, start_pos) -> ...@@ -1103,11 +1106,11 @@ replace_buffer = (buffer, list, start_pos) ->
class Room class Room
constructor: (name, @hostinfo) -> constructor: (name, @hostinfo) ->
@name = name @name = name
@alive = true #@alive = true
@players = [] @players = []
@player_datas = [] @player_datas = []
@status = 'starting' @status = 'starting'
@started = false #@started = false
@established = false @established = false
@watcher_buffers = [] @watcher_buffers = []
@recorder_buffers = [] @recorder_buffers = []
...@@ -1120,6 +1123,7 @@ class Room ...@@ -1120,6 +1123,7 @@ class Room
@duel_count = 0 @duel_count = 0
@death = 0 @death = 0
@turn = 0 @turn = 0
@duel_stage = ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.replay_delay if settings.modules.replay_delay
@replays = [] @replays = []
ROOM_all.push this ROOM_all.push this
...@@ -1409,7 +1413,7 @@ class Room ...@@ -1409,7 +1413,7 @@ class Room
# log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body # log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
return return
if settings.modules.challonge.enabled and @started and @hostinfo.mode != 2 and !@kicked if settings.modules.challonge.enabled and @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and @hostinfo.mode != 2 and !@kicked
room_name = @name room_name = @name
challonge.matches._update({ challonge.matches._update({
id: settings.modules.challonge.tournament_id, id: settings.modules.challonge.tournament_id,
...@@ -1493,7 +1497,7 @@ class Room ...@@ -1493,7 +1497,7 @@ class Room
return found return found
get_challonge_score: -> get_challonge_score: ->
if !settings.modules.challonge.enabled or !@started or @hostinfo.mode == 2 if !settings.modules.challonge.enabled or @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or @hostinfo.mode == 2
return null return null
challonge_duel_log = {} challonge_duel_log = {}
if @scores[@dueling_players[0].name_vpass] > @scores[@dueling_players[1].name_vpass] if @scores[@dueling_players[0].name_vpass] > @scores[@dueling_players[1].name_vpass]
...@@ -1555,7 +1559,7 @@ class Room ...@@ -1555,7 +1559,7 @@ class Room
ROOM_players_oppentlist[client.ip] = null ROOM_players_oppentlist[client.ip] = null
if @established if @established
roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist roomlist.update(this) if !@windbot and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.http.websocket_roomlist
client.server.connect @port, '127.0.0.1', -> client.server.connect @port, '127.0.0.1', ->
client.server.write buffer for buffer in client.pre_establish_buffers client.server.write buffer for buffer in client.pre_establish_buffers
client.established = true client.established = true
...@@ -1573,8 +1577,8 @@ class Room ...@@ -1573,8 +1577,8 @@ class Room
#client.room = null #client.room = null
client.server.destroy() client.server.destroy()
else else
#log.info(client.name, @started, @disconnector, @random_type, @players.length) #log.info(client.name, @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN, @disconnector, @random_type, @players.length)
if @arena and !@started and @disconnector != 'server' and !@arena_score_handled if @arena and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and @disconnector != 'server' and !@arena_score_handled
if settings.modules.arena_mode.punish_quit_before_match and @players.length == 2 and !client.arena_quit_free if settings.modules.arena_mode.punish_quit_before_match and @players.length == 2 and !client.arena_quit_free
for player in @players when player.pos != 7 for player in @players when player.pos != 7
@scores[player.name_vpass] = 0 @scores[player.name_vpass] = 0
...@@ -1585,7 +1589,7 @@ class Room ...@@ -1585,7 +1589,7 @@ class Room
@arena_score_handled = true @arena_score_handled = true
index = _.indexOf(@players, client) index = _.indexOf(@players, client)
@players.splice(index, 1) unless index == -1 @players.splice(index, 1) unless index == -1
if @started and @disconnector != 'server' and client.pos < 4 if @duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and @disconnector != 'server' and client.pos < 4
@finished = true @finished = true
if !@finished_by_death if !@finished_by_death
@scores[client.name_vpass] = -9 @scores[client.name_vpass] = -9
...@@ -1593,10 +1597,10 @@ class Room ...@@ -1593,10 +1597,10 @@ class Room
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}") ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}")
if settings.modules.random_duel.record_match_scores and @random_type == 'M' if settings.modules.random_duel.record_match_scores and @random_type == 'M'
ROOM_player_flee(client.name_vpass) ROOM_player_flee(client.name_vpass)
if @players.length and !(@windbot and client.is_host) and !(@arena and !@started and client.pos <= 3) if @players.length and !(@windbot and client.is_host) and !(@arena and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and client.pos <= 3)
left_name = (if settings.modules.hide_name and !@started then "********" else client.name) left_name = (if settings.modules.hide_name and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN then "********" else client.name)
ygopro.stoc_send_chat_to_room this, "#{left_name} ${left_game}" + if error then ": #{error}" else '' ygopro.stoc_send_chat_to_room this, "#{left_name} ${left_game}" + if error then ": #{error}" else ''
roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist roomlist.update(this) if !@windbot and @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.http.websocket_roomlist
#client.room = null #client.room = null
else else
@send_replays() @send_replays()
...@@ -1608,10 +1612,10 @@ class Room ...@@ -1608,10 +1612,10 @@ class Room
return return
start_death: () -> start_death: () ->
unless @established and @started and !@death if @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or @death
return false return false
oppo_pos = if @hostinfo.mode == 2 then 2 else 1 oppo_pos = if @hostinfo.mode == 2 then 2 else 1
if !@changing_side and (!@duel_count or @turn) # Extra duel started in duel if @duel_stage == ygopro.constants.DUEL_STAGE.DUELING
switch settings.modules.http.quick_death_rule switch settings.modules.http.quick_death_rule
when 3 when 3
@death = -2 @death = -2
...@@ -1648,7 +1652,7 @@ class Room ...@@ -1648,7 +1652,7 @@ class Room
return true return true
cancel_death: () -> cancel_death: () ->
unless @established and @started and @death if @duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or !@death
return false return false
@death = 0 @death = 0
ygopro.stoc_send_chat_to_room(this, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(this, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE)
...@@ -2024,7 +2028,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2024,7 +2028,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
room_buffer.write(room.name, buffer_pos, 64, "utf8") room_buffer.write(room.name, buffer_pos, 64, "utf8")
buffer_pos += 64 buffer_pos += 64
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1 oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
room_buffer.writeUInt8((if !room.started then 0 else if room.changing_side then 2 else 1), buffer_pos) room_buffer.writeUInt8((if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN then 0 else if room.duel_stage == ygopro.constants.DUEL_STAGE.SIDING then 2 else 1), buffer_pos)
buffer_pos++ buffer_pos++
room_buffer.writeInt8(room.duel_count, buffer_pos) room_buffer.writeInt8(room.duel_count, buffer_pos)
buffer_pos++ buffer_pos++
...@@ -2040,7 +2044,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2040,7 +2044,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
player_string = player_string + "+" + (if room_players[1] then room_players[1].name else "???") player_string = player_string + "+" + (if room_players[1] then room_players[1].name else "???")
room_buffer.write(player_string, buffer_pos, 128, "utf8") room_buffer.write(player_string, buffer_pos, 128, "utf8")
buffer_pos += 128 buffer_pos += 128
if room.started if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
room_buffer.writeInt8((if room_players[0] and room.scores[room_players[0].name_vpass]? then room.scores[room_players[0].name_vpass] else 0), buffer_pos) room_buffer.writeInt8((if room_players[0] and room.scores[room_players[0].name_vpass]? then room.scores[room_players[0].name_vpass] else 0), buffer_pos)
buffer_pos++ buffer_pos++
room_buffer.writeInt32LE((if room_players[0] and room_players[0].lp? then room_players[0].lp else room.hostinfo.start_lp), buffer_pos) room_buffer.writeInt32LE((if room_players[0] and room_players[0].lp? then room_players[0].lp else room.hostinfo.start_lp), buffer_pos)
...@@ -2057,7 +2061,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2057,7 +2061,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
player_string = player_string + "+" + (if room_players[oppo_pos + 1] then room_players[oppo_pos + 1].name else "???") player_string = player_string + "+" + (if room_players[oppo_pos + 1] then room_players[oppo_pos + 1].name else "???")
room_buffer.write(player_string, buffer_pos, 128, "utf8") room_buffer.write(player_string, buffer_pos, 128, "utf8")
buffer_pos += 128 buffer_pos += 128
if room.started if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
room_buffer.writeInt8((if room_players[oppo_pos] and room.scores[room_players[oppo_pos].name_vpass]? then room.scores[room_players[oppo_pos].name_vpass] else 0), buffer_pos) room_buffer.writeInt8((if room_players[oppo_pos] and room.scores[room_players[oppo_pos].name_vpass]? then room.scores[room_players[oppo_pos].name_vpass] else 0), buffer_pos)
buffer_pos++ buffer_pos++
room_buffer.writeInt32LE((if room_players[oppo_pos] and room_players[oppo_pos].lp? then room_players[oppo_pos].lp else room.hostinfo.start_lp), buffer_pos) room_buffer.writeInt32LE((if room_players[oppo_pos] and room_players[oppo_pos].lp? then room_players[oppo_pos].lp else room.hostinfo.start_lp), buffer_pos)
...@@ -2210,7 +2214,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2210,7 +2214,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error else if room.error
ygopro.stoc_die(client, room.error) ygopro.stoc_die(client, room.error)
else if room.started else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room) client.rid = _.indexOf(ROOM_all, room)
...@@ -2298,7 +2302,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2298,7 +2302,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
else if settings.modules.challonge.enabled else if settings.modules.challonge.enabled
pre_room = ROOM_find_by_name(info.pass) pre_room = ROOM_find_by_name(info.pass)
if pre_room and pre_room.started and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.hostinfo.no_watch if pre_room and pre_room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.cloud_replay.enable_halfway_watch and !pre_room.hostinfo.no_watch
room = pre_room room = pre_room
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room) client.rid = _.indexOf(ROOM_all, room)
...@@ -2360,7 +2364,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2360,7 +2364,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error else if room.error
ygopro.stoc_die(client, room.error) ygopro.stoc_die(client, room.error)
else if room.started else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
#client.setTimeout(300000) #连接后超时5分钟 #client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room) client.rid = _.indexOf(ROOM_all, room)
...@@ -2449,7 +2453,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)-> ...@@ -2449,7 +2453,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
ygopro.stoc_die(client, "${server_full}") ygopro.stoc_die(client, "${server_full}")
else if room.error else if room.error
ygopro.stoc_die(client, room.error) ygopro.stoc_die(client, room.error)
else if room.started else if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch if settings.modules.cloud_replay.enable_halfway_watch and !room.hostinfo.no_watch
client.setTimeout(300000) #连接后超时5分钟 client.setTimeout(300000) #连接后超时5分钟
client.rid = _.indexOf(ROOM_all, room) client.rid = _.indexOf(ROOM_all, room)
...@@ -2659,7 +2663,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2659,7 +2663,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
client.is_first = !(playertype & 0xf) client.is_first = !(playertype & 0xf)
client.lp = room.hostinfo.start_lp client.lp = room.hostinfo.start_lp
client.card_count = 0 if room.hostinfo.mode != 2 client.card_count = 0 if room.hostinfo.mode != 2
room.selecting_tp = false room.duel_stage = ygopro.constants.DUEL_STAGE.DUELING
if client.pos == 0 if client.pos == 0
room.turn = 0 room.turn = 0
room.duel_count++ room.duel_count++
...@@ -2682,7 +2686,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2682,7 +2686,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if ygopro.constants.MSG[msg] == 'NEW_TURN' if ygopro.constants.MSG[msg] == 'NEW_TURN'
r_player = buffer.readUInt8(1) r_player = buffer.readUInt8(1)
if client.pos == 0 and (r_player & 0x2) == 0 if client.pos == 0 and (r_player & 0x2) == 0
room.turn = room.turn + 1 room.turn++
if room.death and room.death != -2 if room.death and room.death != -2
if room.turn >= room.death if room.turn >= room.death
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1 oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
...@@ -2713,13 +2717,14 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2713,13 +2717,14 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if ygopro.constants.MSG[msg] == 'WIN' and client.pos == 0 if ygopro.constants.MSG[msg] == 'WIN' and client.pos == 0
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first or pos == 2 or room.turn <= 0 or !room.turn pos = 1 - pos unless client.is_first or pos == 2 or room.duel_stage != ygopro.constants.DUEL_STAGE.DUELING
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2 pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
reason = buffer.readUInt8(2) reason = buffer.readUInt8(2)
#log.info {winner: pos, reason: reason} #log.info {winner: pos, reason: reason}
#room.duels.push {winner: pos, reason: reason} #room.duels.push {winner: pos, reason: reason}
room.winner = pos room.winner = pos
room.turn = 0 room.turn = 0
room.duel_stage = ygopro.constants.DUEL_STAGE.END
if settings.modules.heartbeat_detection.enabled if settings.modules.heartbeat_detection.enabled
for player in room.players for player in room.players
player.heartbeat_protected = false player.heartbeat_protected = false
...@@ -2934,7 +2939,7 @@ ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)-> ...@@ -2934,7 +2939,7 @@ ygopro.stoc_follow 'TYPE_CHANGE', true, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'HS_PLAYER_ENTER', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'HS_PLAYER_ENTER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return false unless room and settings.modules.hide_name and !room.started return false unless room and settings.modules.hide_name and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
pos = info.pos pos = info.pos
if pos < 4 and pos != client.pos if pos < 4 and pos != client.pos
struct = ygopro.structs["STOC_HS_PlayerEnter"] struct = ygopro.structs["STOC_HS_PlayerEnter"]
...@@ -3017,7 +3022,7 @@ ygopro.stoc_follow 'DUEL_END', false, (buffer, info, client, server, datas)-> ...@@ -3017,7 +3022,7 @@ ygopro.stoc_follow 'DUEL_END', false, (buffer, info, client, server, datas)->
CLIENT_send_replays(player, room) CLIENT_send_replays(player, room)
wait_room_start = (room, time)-> wait_room_start = (room, time)->
unless !room or room.started or room.ready_player_count_without_host < room.max_player - 1 if room and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and room.ready_player_count_without_host >= room.max_player - 1
time -= 1 time -= 1
if time if time
unless time % 5 unless time % 5
...@@ -3032,7 +3037,7 @@ wait_room_start = (room, time)-> ...@@ -3032,7 +3037,7 @@ wait_room_start = (room, time)->
return return
wait_room_start_arena = (room)-> wait_room_start_arena = (room)->
unless !room or room.started or !room.waiting_for_player if room and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and room.waiting_for_player
room.waiting_for_player_time = room.waiting_for_player_time - 1 room.waiting_for_player_time = room.waiting_for_player_time - 1
if room.waiting_for_player_time > 0 if room.waiting_for_player_time > 0
unless room.waiting_for_player_time % 5 unless room.waiting_for_player_time % 5
...@@ -3100,15 +3105,15 @@ if settings.modules.tips.get_zh ...@@ -3100,15 +3105,15 @@ if settings.modules.tips.get_zh
if settings.modules.tips.enabled 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.duel_stage == ygopro.constants.DUEL_STAGE.SIDING or room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
return return
, 30000 , 30000
ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room and !client.reconnecting return unless room and !client.reconnecting
unless room.started #first start if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN #first start
room.started = true room.duel_stage = ygopro.constants.DUEL_STAGE.FINGER
room.start_time = moment().format() room.start_time = moment().format()
room.turn = 0 room.turn = 0
roomlist.start room if !room.windbot and settings.modules.http.websocket_roomlist roomlist.start room if !room.windbot and settings.modules.http.websocket_roomlist
...@@ -3179,7 +3184,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)-> ...@@ -3179,7 +3184,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server, datas)-> ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
if !room.started if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
return true return true
if room.random_type and room.turn < 3 and not client.flee_free and not settings.modules.test_mode.surrender_anytime and not (room.random_type=='M' and settings.modules.random_duel.record_match_scores) if room.random_type and room.turn < 3 and not client.flee_free and not settings.modules.test_mode.surrender_anytime and not (room.random_type=='M' and settings.modules.random_duel.record_match_scores)
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE)
...@@ -3225,7 +3230,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)-> ...@@ -3225,7 +3230,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
cmd = msg.split(' ') cmd = msg.split(' ')
switch cmd[0] switch cmd[0]
when '/投降', '/surrender' when '/投降', '/surrender'
if !room.started or (room.hostinfo.mode==2 and !settings.modules.tag_duel_surrender) if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or (room.hostinfo.mode==2 and !settings.modules.tag_duel_surrender)
return cancel return cancel
if room.random_type and room.turn < 3 and !client.flee_free if room.random_type and room.turn < 3 and !client.flee_free
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE)
...@@ -3424,7 +3429,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)-> ...@@ -3424,7 +3429,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
else else
client.abuse_count=client.abuse_count+4 client.abuse_count=client.abuse_count+4
ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED)
else if (client.rag and room.started) else if (client.rag and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN)
client.rag = false client.rag = false
#ygopro.stoc_send_chat(client, "${chat_warn_level0}", ygopro.constants.COLORS.RED) #ygopro.stoc_send_chat(client, "${chat_warn_level0}", ygopro.constants.COLORS.RED)
cancel = true cancel = true
...@@ -3503,7 +3508,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3503,7 +3508,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
buff_side = (info.deckbuf[i] for i in [info.mainc...info.mainc + info.sidec]) buff_side = (info.deckbuf[i] for i in [info.mainc...info.mainc + info.sidec])
client.main = buff_main client.main = buff_main
client.side = buff_side client.side = buff_side
if room.started if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
client.selected_preduel = true client.selected_preduel = true
if client.side_tcount if client.side_tcount
clearInterval client.side_interval clearInterval client.side_interval
...@@ -3512,7 +3517,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3512,7 +3517,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
else else
client.start_deckbuf = Buffer.from(buffer) client.start_deckbuf = Buffer.from(buffer)
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1 oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
if settings.modules.http.quick_death_rule >= 2 and room.started and room.death and room.scores[room.dueling_players[0].name_vpass] != room.scores[room.dueling_players[oppo_pos].name_vpass] if settings.modules.http.quick_death_rule >= 2 and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.death and room.scores[room.dueling_players[0].name_vpass] != room.scores[room.dueling_players[oppo_pos].name_vpass]
win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos win_pos = if room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] then 0 else oppo_pos
room.finished_by_death = true room.finished_by_death = true
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
...@@ -3523,7 +3528,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3523,7 +3528,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
CLIENT_kick(room.dueling_players[oppo_pos - win_pos]) CLIENT_kick(room.dueling_players[oppo_pos - win_pos])
CLIENT_kick(room.dueling_players[oppo_pos - win_pos + 1]) if room.hostinfo.mode == 2 CLIENT_kick(room.dueling_players[oppo_pos - win_pos + 1]) if room.hostinfo.mode == 2
return true return true
if settings.modules.side_restrict.enabled and room.started if settings.modules.side_restrict.enabled and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
for code in settings.modules.side_restrict.restrict_cards for code in settings.modules.side_restrict.restrict_cards
if _.indexOf(buff_side, code) > -1 or (settings.modules.pre_release_compat.enabled and _.indexOf(buff_side, room.list_pre_to_official[code]) > -1) if _.indexOf(buff_side, code) > -1 or (settings.modules.pre_release_compat.enabled and _.indexOf(buff_side, room.list_pre_to_official[code]) > -1)
ygopro.stoc_send_chat_to_room(room, "${invalid_side_rule}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "${invalid_side_rule}", ygopro.constants.COLORS.RED)
...@@ -3538,7 +3543,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3538,7 +3543,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
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 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.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.deck_check and fs.readdirSync(settings.modules.tournament_mode.deck_path).length
struct.set("mainc", 1) struct.set("mainc", 1)
struct.set("sidec", 1) struct.set("sidec", 1)
struct.set("deckbuf", [4392470, 4392470]) struct.set("deckbuf", [4392470, 4392470])
...@@ -3602,7 +3607,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)-> ...@@ -3602,7 +3607,7 @@ ygopro.ctos_follow 'UPDATE_DECK', true, (buffer, info, client, server, datas)->
buffer = struct.buffer buffer = struct.buffer
client.main = buff_main_new client.main = buff_main_new
client.side = buff_side_new client.side = buff_side_new
if !room.started if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
client.is_using_pre_release = found or client.vpass == "COMPAT" client.is_using_pre_release = found or client.vpass == "COMPAT"
if client.is_using_pre_release if client.is_using_pre_release
ygopro.stoc_send_chat(client, "${pre_release_compat_hint}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${pre_release_compat_hint}", ygopro.constants.COLORS.BABYBLUE)
...@@ -3627,7 +3632,7 @@ ygopro.stoc_follow 'TIME_LIMIT', true, (buffer, info, client, server, datas)-> ...@@ -3627,7 +3632,7 @@ ygopro.stoc_follow 'TIME_LIMIT', true, (buffer, info, client, server, datas)->
return true return true
else else
client.time_confirm_required = true client.time_confirm_required = true
return unless settings.modules.heartbeat_detection.enabled and room.turn and room.turn > 0 and !room.windbot return unless settings.modules.heartbeat_detection.enabled and room.duel_stage == ygopro.constants.DUEL_STAGE.DUELING and !room.windbot
check = false check = false
if room.hostinfo.mode != 2 if room.hostinfo.mode != 2
check = (client.is_first and info.player == 0) or (!client.is_first and info.player == 1) check = (client.is_first and info.player == 0) or (!client.is_first and info.player == 1)
...@@ -3693,8 +3698,8 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server, datas)-> ...@@ -3693,8 +3698,8 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'CHAT', true, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'CHAT', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
pid = info.player pid = info.player
return unless room and pid < 4 and settings.modules.chat_color.enabled and (!settings.modules.hide_name or room.started) return unless room and pid < 4 and settings.modules.chat_color.enabled and (!settings.modules.hide_name or room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN)
if room.started and room.turn > 0 and !room.dueling_players[0].is_first if room.duel_stage == ygopro.constants.DUEL_STAGE.DUELING and !room.dueling_players[0].is_first
if room.hostinfo.mode == 2 if room.hostinfo.mode == 2
pid = { pid = {
0: 2, 0: 2,
...@@ -3721,8 +3726,7 @@ ygopro.stoc_follow 'SELECT_HAND', false, (buffer, info, client, server, datas)-> ...@@ -3721,8 +3726,7 @@ ygopro.stoc_follow 'SELECT_HAND', false, (buffer, info, client, server, datas)->
return unless room return unless room
client.selected_preduel = false client.selected_preduel = false
if client.pos == 0 if client.pos == 0
room.selecting_hand = true room.duel_stage = ygopro.constants.DUEL_STAGE.FINGER
room.changing_side = false
return unless room.random_type or room.arena return unless room.random_type or room.arena
if client.pos == 0 if client.pos == 0
room.waiting_for_player = client room.waiting_for_player = client
...@@ -3735,8 +3739,7 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server, datas)-> ...@@ -3735,8 +3739,7 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
client.selected_preduel = false client.selected_preduel = false
room.changing_side = false room.duel_stage = ygopro.constants.DUEL_STAGE.FIRSTGO
room.selecting_hand = false
room.selecting_tp = client room.selecting_tp = client
if room.random_type or room.arena if room.random_type or room.arena
room.waiting_for_player = client room.waiting_for_player = client
...@@ -3746,13 +3749,14 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server, datas)-> ...@@ -3746,13 +3749,14 @@ ygopro.stoc_follow 'SELECT_TP', false, (buffer, info, client, server, datas)->
ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)-> ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room return unless room
room.changing_side = true if client.pos == 0
room.duel_stage = ygopro.constants.DUEL_STAGE.SIDING
client.selected_preduel = false client.selected_preduel = false
if settings.modules.side_timeout if settings.modules.side_timeout
client.side_tcount = settings.modules.side_timeout client.side_tcount = settings.modules.side_timeout
ygopro.stoc_send_chat(client, "${side_timeout_part1}#{settings.modules.side_timeout}${side_timeout_part2}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${side_timeout_part1}#{settings.modules.side_timeout}${side_timeout_part2}", ygopro.constants.COLORS.BABYBLUE)
sinterval = setInterval ()-> sinterval = setInterval ()->
if not (room and room.started and client and client.side_tcount and room.changing_side) if not (room and client and client.side_tcount and room.duel_stage == ygopro.constants.DUEL_STAGE.SIDING)
clearInterval sinterval clearInterval sinterval
return return
if client.side_tcount == 1 if client.side_tcount == 1
...@@ -3834,7 +3838,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)-> ...@@ -3834,7 +3838,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server, datas)->
if settings.modules.random_duel.enabled if settings.modules.random_duel.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and room.random_type and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0 for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.random_type and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0
time_passed = Math.floor((moment() - room.last_active_time) / 1000) time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed #log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout if time_passed >= settings.modules.random_duel.hang_timeout
...@@ -3853,7 +3857,7 @@ if settings.modules.random_duel.enabled ...@@ -3853,7 +3857,7 @@ if settings.modules.random_duel.enabled
if settings.modules.mycard.enabled if settings.modules.mycard.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and room.arena and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0 for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.arena and room.last_active_time and room.waiting_for_player and room.get_disconnected_count() == 0
time_passed = Math.floor((moment() - room.last_active_time) / 1000) time_passed = Math.floor((moment() - room.last_active_time) / 1000)
#log.info time_passed #log.info time_passed
if time_passed >= settings.modules.random_duel.hang_timeout if time_passed >= settings.modules.random_duel.hang_timeout
...@@ -3866,7 +3870,7 @@ if settings.modules.mycard.enabled ...@@ -3866,7 +3870,7 @@ if settings.modules.mycard.enabled
else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10) else if time_passed >= (settings.modules.random_duel.hang_timeout - 20) and not (time_passed % 10)
ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{room.waiting_for_player.name} ${afk_warn_part1}#{settings.modules.random_duel.hang_timeout - time_passed}${afk_warn_part2}", ygopro.constants.COLORS.RED)
if settings.modules.arena_mode.punish_quit_before_match if settings.modules.arena_mode.punish_quit_before_match
for room in ROOM_all when room and room.arena and !room.started and room.get_playing_player().length < 2 for room in ROOM_all when room and room.arena and room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN and room.get_playing_player().length < 2
player = room.get_playing_player()[0] player = room.get_playing_player()[0]
if player and player.join_time and !player.arena_quit_free if player and player.join_time and !player.arena_quit_free
waited_time = moment() - player.join_time waited_time = moment() - player.join_time
...@@ -3880,15 +3884,15 @@ if settings.modules.mycard.enabled ...@@ -3880,15 +3884,15 @@ if settings.modules.mycard.enabled
if settings.modules.heartbeat_detection.enabled if settings.modules.heartbeat_detection.enabled
setInterval ()-> setInterval ()->
for room in ROOM_all when room and room.started and (room.hostinfo.time_limit == 0 or !room.turn or room.turn <= 0) and !room.windbot for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and (room.hostinfo.time_limit == 0 or room.duel_stage != ygopro.constants.DUEL_STAGE.DUELING) and !room.windbot
for player in room.get_playing_player() when player and (!room.changing_side or player.selected_preduel) for player in room.get_playing_player() when player and (room.duel_stage != ygopro.constants.DUEL_STAGE.SIDING or player.selected_preduel)
CLIENT_heartbeat_register(player, true) CLIENT_heartbeat_register(player, true)
return return
, settings.modules.heartbeat_detection.interval , settings.modules.heartbeat_detection.interval
setInterval ()-> setInterval ()->
current_time = moment() current_time = moment()
for room in ROOM_all when room and room.started and room.hostinfo.auto_death and !room.auto_death_triggered and current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death for room in ROOM_all when room and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and room.hostinfo.auto_death and !room.auto_death_triggered and current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death
room.auto_death_triggered = true room.auto_death_triggered = true
room.start_death() room.start_death()
...@@ -3963,14 +3967,14 @@ if settings.modules.http ...@@ -3963,14 +3967,14 @@ if settings.modules.http
id: (-1).toString(), id: (-1).toString(),
name: player.name, name: player.name,
ip: if settings.modules.http.show_ip and pass_validated and !player.is_local then player.ip.slice(7) else null, ip: if settings.modules.http.show_ip and pass_validated and !player.is_local then player.ip.slice(7) else null,
status: if settings.modules.http.show_info and room.started and player.pos != 7 then ( status: if settings.modules.http.show_info and room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN and player.pos != 7 then (
score: room.scores[player.name_vpass], score: room.scores[player.name_vpass],
lp: if player.lp? then player.lp else room.hostinfo.start_lp, lp: if player.lp? then player.lp else room.hostinfo.start_lp,
cards: if room.hostinfo.mode != 2 then (if player.card_count? then player.card_count else room.hostinfo.start_hand) else null cards: if room.hostinfo.mode != 2 then (if player.card_count? then player.card_count else room.hostinfo.start_hand) else null
) else null, ) else null,
pos: player.pos pos: player.pos
), "pos"), ), "pos"),
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.changing_side then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait' istart: if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.duel_stage == ygopro.constants.DUEL_STAGE.SIDING then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait'
), null, 2 ), null, 2
response.end(addCallback(u.query.callback, roomsjson)) response.end(addCallback(u.query.callback, roomsjson))
...@@ -4165,7 +4169,7 @@ if settings.modules.http ...@@ -4165,7 +4169,7 @@ if settings.modules.http
kick_room_found = false kick_room_found = false
for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.process_pid.toString() or u.query.kick == room.name) for room in ROOM_all when room and room.established and (u.query.kick == "all" or u.query.kick == room.process_pid.toString() or u.query.kick == room.name)
kick_room_found = true kick_room_found = true
if room.started if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
room.scores[room.dueling_players[0].name_vpass] = 0 room.scores[room.dueling_players[0].name_vpass] = 0
room.scores[room.dueling_players[1].name_vpass] = 0 room.scores[room.dueling_players[1].name_vpass] = 0
room.kicked = true room.kicked = true
...@@ -4199,7 +4203,7 @@ if settings.modules.http ...@@ -4199,7 +4203,7 @@ if settings.modules.http
response.end(addCallback(u.query.callback, "['密码错误', 0]")) response.end(addCallback(u.query.callback, "['密码错误', 0]"))
return return
death_room_found = false death_room_found = false
for room in ROOM_all when room and (u.query.death == "all" or u.query.death == room.process_pid.toString() or u.query.death == room.name) for room in ROOM_all when room and (u.query.deathcancel == "all" or u.query.deathcancel == room.process_pid.toString() or u.query.deathcancel == room.name)
if room.cancel_death() if room.cancel_death()
death_room_found = true death_room_found = true
response.writeHead(200) response.writeHead(200)
...@@ -4214,7 +4218,7 @@ if settings.modules.http ...@@ -4214,7 +4218,7 @@ if settings.modules.http
response.end(addCallback(u.query.callback, "['密码错误', 0]")) response.end(addCallback(u.query.callback, "['密码错误', 0]"))
return return
for room in ROOM_all when room for room in ROOM_all when room
if room.started if room.duel_stage != ygopro.constants.DUEL_STAGE.BEGIN
room.scores[room.dueling_players[0].name_vpass] = 0 room.scores[room.dueling_players[0].name_vpass] = 0
room.scores[room.dueling_players[1].name_vpass] = 0 room.scores[room.dueling_players[1].name_vpass] = 0
room.kicked = true room.kicked = true
......
...@@ -865,7 +865,7 @@ ...@@ -865,7 +865,7 @@
max_player = type === 'T' ? 4 : 2; max_player = type === 'T' ? 4 : 2;
playerbanned = bannedplayer && bannedplayer.count > 3 && moment() < bannedplayer.time; playerbanned = bannedplayer && bannedplayer.count > 3 && moment() < bannedplayer.time;
result = _.find(ROOM_all, function(room) { result = _.find(ROOM_all, function(room) {
return room && room.random_type !== '' && !room.started && !room.windbot && ((type === '' && room.random_type !== 'T' && ((!_.endsWith(room.random_type, "MR") && room.random_type !== 'M') || (settings.modules.random_duel.blank_pass_match && room.random_type !== 'T'))) || room.random_type === type) && room.get_playing_player().length < max_player && (settings.modules.random_duel.no_rematch_check || room.get_host() === null || room.get_host().ip !== ROOM_players_oppentlist[player_ip]) && (playerbanned === room.deprecated || type === 'T'); return room && room.random_type !== '' && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot && ((type === '' && room.random_type !== 'T' && ((!_.endsWith(room.random_type, "MR") && room.random_type !== 'M') || (settings.modules.random_duel.blank_pass_match && room.random_type !== 'T'))) || room.random_type === type) && room.get_playing_player().length < max_player && (settings.modules.random_duel.no_rematch_check || room.get_host() === null || room.get_host().ip !== ROOM_players_oppentlist[player_ip]) && (playerbanned === room.deprecated || type === 'T');
}); });
if (result) { if (result) {
result.welcome = '${random_duel_enter_room_waiting}'; result.welcome = '${random_duel_enter_room_waiting}';
...@@ -1040,7 +1040,7 @@ ...@@ -1040,7 +1040,7 @@
if (client.had_new_reconnection) { if (client.had_new_reconnection) {
return false; return false;
} }
if (!settings.modules.reconnect.enabled || !room || client.system_kicked || client.flee_free || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || !room.started || room.windbot || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1) || (room.random_type && room.get_disconnected_count() > 1)) { if (!settings.modules.reconnect.enabled || !room || client.system_kicked || client.flee_free || disconnect_list[CLIENT_get_authorize_key(client)] || client.is_post_watcher || !CLIENT_is_player(client, room) || room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || room.windbot || (settings.modules.reconnect.auto_surrender_after_disconnect && room.hostinfo.mode !== 1) || (room.random_type && room.get_disconnected_count() > 1)) {
return false; return false;
} }
dinfo = { dinfo = {
...@@ -1060,7 +1060,7 @@ ...@@ -1060,7 +1060,7 @@
client.time_confirm_required = false; client.time_confirm_required = false;
ygopro.ctos_send(client.server, 'TIME_CONFIRM'); ygopro.ctos_send(client.server, 'TIME_CONFIRM');
} }
if (settings.modules.reconnect.auto_surrender_after_disconnect && room.turn && room.turn > 0) { if (settings.modules.reconnect.auto_surrender_after_disconnect && room.duel_stage === ygopro.constants.DUEL_STAGE.DUELING) {
ygopro.ctos_send(client.server, 'SURRENDER'); ygopro.ctos_send(client.server, 'SURRENDER');
} }
return true; return true;
...@@ -1164,7 +1164,7 @@ ...@@ -1164,7 +1164,7 @@
var len3, len4, m, n, player, ref3, room; var len3, len4, m, n, player, ref3, room;
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.started && !room.windbot) { if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && !room.windbot) {
ref3 = room.get_playing_player(); ref3 = room.get_playing_player();
for (n = 0, len4 = ref3.length; n < len4; n++) { for (n = 0, len4 = ref3.length; n < len4; n++) {
player = ref3[n]; player = ref3[n];
...@@ -1211,28 +1211,31 @@ ...@@ -1211,28 +1211,31 @@
CLIENT_send_reconnect_info = function(client, server, room) { CLIENT_send_reconnect_info = function(client, server, room) {
client.reconnecting = true; client.reconnecting = true;
ygopro.stoc_send_chat(client, "${reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${reconnecting_to_room}", ygopro.constants.COLORS.BABYBLUE);
if (room.turn && room.turn > 0) { switch (room.duel_stage) {
ygopro.ctos_send(server, 'REQUEST_FIELD'); case ygopro.constants.DUEL_STAGE.FINGER:
} else if (room.changing_side) { ygopro.stoc_send(client, 'DUEL_START');
ygopro.stoc_send(client, 'DUEL_START'); if ((room.hostinfo.mode !== 2 || client.pos === 0 || client.pos === 2) && !client.selected_preduel) {
if (!client.selected_preduel) { ygopro.stoc_send(client, 'SELECT_HAND');
ygopro.stoc_send(client, 'CHANGE_SIDE'); }
} client.reconnecting = false;
client.reconnecting = false; break;
} else if (room.selecting_hand) { case ygopro.constants.DUEL_STAGE.FIRSTGO:
ygopro.stoc_send(client, 'DUEL_START'); ygopro.stoc_send(client, 'DUEL_START');
if ((room.hostinfo.mode !== 2 || client.pos === 0 || client.pos === 2) && !client.selected_preduel) { if (client === room.selecting_tp) {
ygopro.stoc_send(client, 'SELECT_HAND'); ygopro.stoc_send(client, 'SELECT_TP');
} }
client.reconnecting = false; client.reconnecting = false;
} else if (room.selecting_tp) { break;
ygopro.stoc_send(client, 'DUEL_START'); case ygopro.constants.DUEL_STAGE.SIDING:
if (client === room.selecting_tp) { ygopro.stoc_send(client, 'DUEL_START');
ygopro.stoc_send(client, 'SELECT_TP'); if (!client.selected_preduel) {
} ygopro.stoc_send(client, 'CHANGE_SIDE');
client.reconnecting = false; }
} else { client.reconnecting = false;
ygopro.ctos_send(server, 'REQUEST_FIELD'); break;
default:
ygopro.ctos_send(server, 'REQUEST_FIELD');
break;
} }
}; };
...@@ -1440,11 +1443,9 @@ ...@@ -1440,11 +1443,9 @@
var death_time, draw_count, error, lflist, list_official_to_pre, list_pre_to_official, official_database, param, pre_release_database, rule, start_hand, start_lp, temp_list, time_limit; var death_time, draw_count, error, lflist, list_official_to_pre, list_pre_to_official, official_database, param, pre_release_database, rule, start_hand, start_lp, temp_list, time_limit;
this.hostinfo = hostinfo; this.hostinfo = hostinfo;
this.name = name; this.name = name;
this.alive = true;
this.players = []; this.players = [];
this.player_datas = []; this.player_datas = [];
this.status = 'starting'; this.status = 'starting';
this.started = false;
this.established = false; this.established = false;
this.watcher_buffers = []; this.watcher_buffers = [];
this.recorder_buffers = []; this.recorder_buffers = [];
...@@ -1457,6 +1458,7 @@ ...@@ -1457,6 +1458,7 @@
this.duel_count = 0; this.duel_count = 0;
this.death = 0; this.death = 0;
this.turn = 0; this.turn = 0;
this.duel_stage = ygopro.constants.DUEL_STAGE.BEGIN;
if (settings.modules.replay_delay) { if (settings.modules.replay_delay) {
this.replays = []; this.replays = [];
} }
...@@ -1830,7 +1832,7 @@ ...@@ -1830,7 +1832,7 @@
}; };
})(this)); })(this));
} }
if (settings.modules.challonge.enabled && this.started && this.hostinfo.mode !== 2 && !this.kicked) { if (settings.modules.challonge.enabled && this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.hostinfo.mode !== 2 && !this.kicked) {
room_name = this.name; room_name = this.name;
challonge.matches._update({ challonge.matches._update({
id: settings.modules.challonge.tournament_id, id: settings.modules.challonge.tournament_id,
...@@ -1939,7 +1941,7 @@ ...@@ -1939,7 +1941,7 @@
Room.prototype.get_challonge_score = function() { Room.prototype.get_challonge_score = function() {
var challonge_duel_log; var challonge_duel_log;
if (!settings.modules.challonge.enabled || !this.started || this.hostinfo.mode === 2) { if (!settings.modules.challonge.enabled || this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.hostinfo.mode === 2) {
return null; return null;
} }
challonge_duel_log = {}; challonge_duel_log = {};
...@@ -2018,7 +2020,7 @@ ...@@ -2018,7 +2020,7 @@
} }
} }
if (this.established) { if (this.established) {
if (!this.windbot && !this.started && settings.modules.http.websocket_roomlist) { if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
} }
client.server.connect(this.port, '127.0.0.1', function() { client.server.connect(this.port, '127.0.0.1', function() {
...@@ -2047,7 +2049,7 @@ ...@@ -2047,7 +2049,7 @@
} }
client.server.destroy(); client.server.destroy();
} else { } else {
if (this.arena && !this.started && this.disconnector !== 'server' && !this.arena_score_handled) { if (this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && !this.arena_score_handled) {
if (settings.modules.arena_mode.punish_quit_before_match && this.players.length === 2 && !client.arena_quit_free) { if (settings.modules.arena_mode.punish_quit_before_match && this.players.length === 2 && !client.arena_quit_free) {
ref3 = this.players; ref3 = this.players;
for (m = 0, len3 = ref3.length; m < len3; m++) { for (m = 0, len3 = ref3.length; m < len3; m++) {
...@@ -2072,7 +2074,7 @@ ...@@ -2072,7 +2074,7 @@
if (index !== -1) { if (index !== -1) {
this.players.splice(index, 1); this.players.splice(index, 1);
} }
if (this.started && this.disconnector !== 'server' && client.pos < 4) { if (this.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && this.disconnector !== 'server' && client.pos < 4) {
this.finished = true; this.finished = true;
if (!this.finished_by_death) { if (!this.finished_by_death) {
this.scores[client.name_vpass] = -9; this.scores[client.name_vpass] = -9;
...@@ -2084,10 +2086,10 @@ ...@@ -2084,10 +2086,10 @@
} }
} }
} }
if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && !this.started && client.pos <= 3)) { if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && client.pos <= 3)) {
left_name = (settings.modules.hide_name && !this.started ? "********" : client.name); left_name = (settings.modules.hide_name && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN ? "********" : client.name);
ygopro.stoc_send_chat_to_room(this, (left_name + " ${left_game}") + (error ? ": " + error : '')); ygopro.stoc_send_chat_to_room(this, (left_name + " ${left_game}") + (error ? ": " + error : ''));
if (!this.windbot && !this.started && settings.modules.http.websocket_roomlist) { if (!this.windbot && this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.http.websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
} }
} else { } else {
...@@ -2103,11 +2105,11 @@ ...@@ -2103,11 +2105,11 @@
Room.prototype.start_death = function() { Room.prototype.start_death = function() {
var oppo_pos, win_pos; var oppo_pos, win_pos;
if (!(this.established && this.started && !this.death)) { if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || this.death) {
return false; return false;
} }
oppo_pos = this.hostinfo.mode === 2 ? 2 : 1; oppo_pos = this.hostinfo.mode === 2 ? 2 : 1;
if (!this.changing_side && (!this.duel_count || this.turn)) { if (this.duel_stage === ygopro.constants.DUEL_STAGE.DUELING) {
switch (settings.modules.http.quick_death_rule) { switch (settings.modules.http.quick_death_rule) {
case 3: case 3:
this.death = -2; this.death = -2;
...@@ -2160,7 +2162,7 @@ ...@@ -2160,7 +2162,7 @@
}; };
Room.prototype.cancel_death = function() { Room.prototype.cancel_death = function() {
if (!(this.established && this.started && this.death)) { if (this.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || !this.death) {
return false; return false;
} }
this.death = 0; this.death = 0;
...@@ -2576,7 +2578,7 @@ ...@@ -2576,7 +2578,7 @@
room_buffer.write(room.name, buffer_pos, 64, "utf8"); room_buffer.write(room.name, buffer_pos, 64, "utf8");
buffer_pos += 64; buffer_pos += 64;
oppo_pos = room.hostinfo.mode === 2 ? 2 : 1; oppo_pos = room.hostinfo.mode === 2 ? 2 : 1;
room_buffer.writeUInt8((!room.started ? 0 : room.changing_side ? 2 : 1), buffer_pos); room_buffer.writeUInt8((room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN ? 0 : room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING ? 2 : 1), buffer_pos);
buffer_pos++; buffer_pos++;
room_buffer.writeInt8(room.duel_count, buffer_pos); room_buffer.writeInt8(room.duel_count, buffer_pos);
buffer_pos++; buffer_pos++;
...@@ -2599,7 +2601,7 @@ ...@@ -2599,7 +2601,7 @@
} }
room_buffer.write(player_string, buffer_pos, 128, "utf8"); room_buffer.write(player_string, buffer_pos, 128, "utf8");
buffer_pos += 128; buffer_pos += 128;
if (room.started) { if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
room_buffer.writeInt8((room_players[0] && (room.scores[room_players[0].name_vpass] != null) ? room.scores[room_players[0].name_vpass] : 0), buffer_pos); room_buffer.writeInt8((room_players[0] && (room.scores[room_players[0].name_vpass] != null) ? room.scores[room_players[0].name_vpass] : 0), buffer_pos);
buffer_pos++; buffer_pos++;
room_buffer.writeInt32LE((room_players[0] && (room_players[0].lp != null) ? room_players[0].lp : room.hostinfo.start_lp), buffer_pos); room_buffer.writeInt32LE((room_players[0] && (room_players[0].lp != null) ? room_players[0].lp : room.hostinfo.start_lp), buffer_pos);
...@@ -2619,7 +2621,7 @@ ...@@ -2619,7 +2621,7 @@
} }
room_buffer.write(player_string, buffer_pos, 128, "utf8"); room_buffer.write(player_string, buffer_pos, 128, "utf8");
buffer_pos += 128; buffer_pos += 128;
if (room.started) { if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
room_buffer.writeInt8((room_players[oppo_pos] && (room.scores[room_players[oppo_pos].name_vpass] != null) ? room.scores[room_players[oppo_pos].name_vpass] : 0), buffer_pos); room_buffer.writeInt8((room_players[oppo_pos] && (room.scores[room_players[oppo_pos].name_vpass] != null) ? room.scores[room_players[oppo_pos].name_vpass] : 0), buffer_pos);
buffer_pos++; buffer_pos++;
room_buffer.writeInt32LE((room_players[oppo_pos] && (room_players[oppo_pos].lp != null) ? room_players[oppo_pos].lp : room.hostinfo.start_lp), buffer_pos); room_buffer.writeInt32LE((room_players[oppo_pos] && (room_players[oppo_pos].lp != null) ? room_players[oppo_pos].lp : room.hostinfo.start_lp), buffer_pos);
...@@ -2780,7 +2782,7 @@ ...@@ -2780,7 +2782,7 @@
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) { } else if (room.error) {
ygopro.stoc_die(client, room.error); ygopro.stoc_die(client, room.error);
} else if (room.started) { } else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) { if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000); client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
...@@ -2890,7 +2892,7 @@ ...@@ -2890,7 +2892,7 @@
} }
} else if (settings.modules.challonge.enabled) { } else if (settings.modules.challonge.enabled) {
pre_room = ROOM_find_by_name(info.pass); pre_room = ROOM_find_by_name(info.pass);
if (pre_room && pre_room.started && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.hostinfo.no_watch) { if (pre_room && pre_room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.cloud_replay.enable_halfway_watch && !pre_room.hostinfo.no_watch) {
room = pre_room; room = pre_room;
client.setTimeout(300000); client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
...@@ -2968,7 +2970,7 @@ ...@@ -2968,7 +2970,7 @@
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) { } else if (room.error) {
ygopro.stoc_die(client, room.error); ygopro.stoc_die(client, room.error);
} else if (room.started) { } else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) { if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
client.is_post_watcher = true; client.is_post_watcher = true;
...@@ -3058,7 +3060,7 @@ ...@@ -3058,7 +3060,7 @@
ygopro.stoc_die(client, "${server_full}"); ygopro.stoc_die(client, "${server_full}");
} else if (room.error) { } else if (room.error) {
ygopro.stoc_die(client, room.error); ygopro.stoc_die(client, room.error);
} else if (room.started) { } else if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) { if (settings.modules.cloud_replay.enable_halfway_watch && !room.hostinfo.no_watch) {
client.setTimeout(300000); client.setTimeout(300000);
client.rid = _.indexOf(ROOM_all, room); client.rid = _.indexOf(ROOM_all, room);
...@@ -3319,7 +3321,7 @@ ...@@ -3319,7 +3321,7 @@
if (room.hostinfo.mode !== 2) { if (room.hostinfo.mode !== 2) {
client.card_count = 0; client.card_count = 0;
} }
room.selecting_tp = false; room.duel_stage = ygopro.constants.DUEL_STAGE.DUELING;
if (client.pos === 0) { if (client.pos === 0) {
room.turn = 0; room.turn = 0;
room.duel_count++; room.duel_count++;
...@@ -3345,7 +3347,7 @@ ...@@ -3345,7 +3347,7 @@
if (ygopro.constants.MSG[msg] === 'NEW_TURN') { if (ygopro.constants.MSG[msg] === 'NEW_TURN') {
r_player = buffer.readUInt8(1); r_player = buffer.readUInt8(1);
if (client.pos === 0 && (r_player & 0x2) === 0) { if (client.pos === 0 && (r_player & 0x2) === 0) {
room.turn = room.turn + 1; room.turn++;
if (room.death && room.death !== -2) { if (room.death && room.death !== -2) {
if (room.turn >= room.death) { if (room.turn >= room.death) {
oppo_pos = room.hostinfo.mode === 2 ? 2 : 1; oppo_pos = room.hostinfo.mode === 2 ? 2 : 1;
...@@ -3383,7 +3385,7 @@ ...@@ -3383,7 +3385,7 @@
} }
if (ygopro.constants.MSG[msg] === 'WIN' && client.pos === 0) { if (ygopro.constants.MSG[msg] === 'WIN' && client.pos === 0) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!(client.is_first || pos === 2 || room.turn <= 0 || !room.turn)) { if (!(client.is_first || pos === 2 || room.duel_stage !== ygopro.constants.DUEL_STAGE.DUELING)) {
pos = 1 - pos; pos = 1 - pos;
} }
if (pos >= 0 && room.hostinfo.mode === 2) { if (pos >= 0 && room.hostinfo.mode === 2) {
...@@ -3392,6 +3394,7 @@ ...@@ -3392,6 +3394,7 @@
reason = buffer.readUInt8(2); reason = buffer.readUInt8(2);
room.winner = pos; room.winner = pos;
room.turn = 0; room.turn = 0;
room.duel_stage = ygopro.constants.DUEL_STAGE.END;
if (settings.modules.heartbeat_detection.enabled) { if (settings.modules.heartbeat_detection.enabled) {
ref3 = room.players; ref3 = room.players;
for (m = 0, len3 = ref3.length; m < len3; m++) { for (m = 0, len3 = ref3.length; m < len3; m++) {
...@@ -3695,7 +3698,7 @@ ...@@ -3695,7 +3698,7 @@
ygopro.stoc_follow('HS_PLAYER_ENTER', true, function(buffer, info, client, server, datas) { ygopro.stoc_follow('HS_PLAYER_ENTER', true, function(buffer, info, client, server, datas) {
var pos, room, struct; var pos, room, struct;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && settings.modules.hide_name && !room.started)) { if (!(room && settings.modules.hide_name && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN)) {
return false; return false;
} }
pos = info.pos; pos = info.pos;
...@@ -3831,7 +3834,7 @@ ...@@ -3831,7 +3834,7 @@
wait_room_start = function(room, time) { wait_room_start = function(room, time) {
var len3, m, player, ref3; var len3, m, player, ref3;
if (!(!room || room.started || room.ready_player_count_without_host < room.max_player - 1)) { if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.ready_player_count_without_host >= room.max_player - 1) {
time -= 1; time -= 1;
if (time) { if (time) {
if (!(time % 5)) { if (!(time % 5)) {
...@@ -3856,7 +3859,7 @@ ...@@ -3856,7 +3859,7 @@
wait_room_start_arena = function(room) { wait_room_start_arena = function(room) {
var display_name, len3, m, player, ref3; var display_name, len3, m, player, ref3;
if (!(!room || room.started || !room.waiting_for_player)) { if (room && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.waiting_for_player) {
room.waiting_for_player_time = room.waiting_for_player_time - 1; room.waiting_for_player_time = room.waiting_for_player_time - 1;
if (room.waiting_for_player_time > 0) { if (room.waiting_for_player_time > 0) {
if (!(room.waiting_for_player_time % 5)) { if (!(room.waiting_for_player_time % 5)) {
...@@ -3958,7 +3961,7 @@ ...@@ -3958,7 +3961,7 @@
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) {
if (!room.started || room.changing_side) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING || room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
ygopro.stoc_send_random_tip_to_room(room); ygopro.stoc_send_random_tip_to_room(room);
} }
} }
...@@ -3972,8 +3975,8 @@ ...@@ -3972,8 +3975,8 @@
if (!(room && !client.reconnecting)) { if (!(room && !client.reconnecting)) {
return; return;
} }
if (!room.started) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
room.started = true; room.duel_stage = ygopro.constants.DUEL_STAGE.FINGER;
room.start_time = moment().format(); room.start_time = moment().format();
room.turn = 0; room.turn = 0;
if (!room.windbot && settings.modules.http.websocket_roomlist) { if (!room.windbot && settings.modules.http.websocket_roomlist) {
...@@ -4076,7 +4079,7 @@ ...@@ -4076,7 +4079,7 @@
if (!room) { if (!room) {
return; return;
} }
if (!room.started) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
return true; return true;
} }
if (room.random_type && room.turn < 3 && !client.flee_free && !settings.modules.test_mode.surrender_anytime && !(room.random_type === 'M' && settings.modules.random_duel.record_match_scores)) { if (room.random_type && room.turn < 3 && !client.flee_free && !settings.modules.test_mode.surrender_anytime && !(room.random_type === 'M' && settings.modules.random_duel.record_match_scores)) {
...@@ -4138,7 +4141,7 @@ ...@@ -4138,7 +4141,7 @@
switch (cmd[0]) { switch (cmd[0]) {
case '/投降': case '/投降':
case '/surrender': case '/surrender':
if (!room.started || (room.hostinfo.mode === 2 && !settings.modules.tag_duel_surrender)) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN || (room.hostinfo.mode === 2 && !settings.modules.tag_duel_surrender)) {
return cancel; return cancel;
} }
if (room.random_type && room.turn < 3 && !client.flee_free) { if (room.random_type && room.turn < 3 && !client.flee_free) {
...@@ -4402,7 +4405,7 @@ ...@@ -4402,7 +4405,7 @@
client.abuse_count = client.abuse_count + 4; client.abuse_count = client.abuse_count + 4;
ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat(client, "${chat_warn_level2}", ygopro.constants.COLORS.RED);
} }
} else if (client.rag && room.started) { } else if (client.rag && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
client.rag = false; client.rag = false;
cancel = true; cancel = true;
} else if (_.any(settings.ban.spam_word, function(badword) { } else if (_.any(settings.ban.spam_word, function(badword) {
...@@ -4505,7 +4508,7 @@ ...@@ -4505,7 +4508,7 @@
})(); })();
client.main = buff_main; client.main = buff_main;
client.side = buff_side; client.side = buff_side;
if (room.started) { if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
client.selected_preduel = true; client.selected_preduel = true;
if (client.side_tcount) { if (client.side_tcount) {
clearInterval(client.side_interval); clearInterval(client.side_interval);
...@@ -4516,7 +4519,7 @@ ...@@ -4516,7 +4519,7 @@
client.start_deckbuf = Buffer.from(buffer); client.start_deckbuf = Buffer.from(buffer);
} }
oppo_pos = room.hostinfo.mode === 2 ? 2 : 1; oppo_pos = room.hostinfo.mode === 2 ? 2 : 1;
if (settings.modules.http.quick_death_rule >= 2 && room.started && room.death && room.scores[room.dueling_players[0].name_vpass] !== room.scores[room.dueling_players[oppo_pos].name_vpass]) { if (settings.modules.http.quick_death_rule >= 2 && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.death && room.scores[room.dueling_players[0].name_vpass] !== room.scores[room.dueling_players[oppo_pos].name_vpass]) {
win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos; win_pos = room.scores[room.dueling_players[0].name_vpass] > room.scores[room.dueling_players[oppo_pos].name_vpass] ? 0 : oppo_pos;
room.finished_by_death = true; room.finished_by_death = true;
ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat_to_room(room, "${death2_finish_part1}" + room.dueling_players[win_pos].name + "${death2_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
...@@ -4534,7 +4537,7 @@ ...@@ -4534,7 +4537,7 @@
} }
return true; return true;
} }
if (settings.modules.side_restrict.enabled && room.started) { if (settings.modules.side_restrict.enabled && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
ref3 = settings.modules.side_restrict.restrict_cards; ref3 = settings.modules.side_restrict.restrict_cards;
for (m = 0, len3 = ref3.length; m < len3; m++) { for (m = 0, len3 = ref3.length; m < len3; m++) {
code = ref3[m]; code = ref3[m];
...@@ -4555,7 +4558,7 @@ ...@@ -4555,7 +4558,7 @@
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 && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check && fs.readdirSync(settings.modules.tournament_mode.deck_path).length) { } else if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.deck_check && fs.readdirSync(settings.modules.tournament_mode.deck_path).length) {
struct.set("mainc", 1); struct.set("mainc", 1);
struct.set("sidec", 1); struct.set("sidec", 1);
struct.set("deckbuf", [4392470, 4392470]); struct.set("deckbuf", [4392470, 4392470]);
...@@ -4636,7 +4639,7 @@ ...@@ -4636,7 +4639,7 @@
client.main = buff_main_new; client.main = buff_main_new;
client.side = buff_side_new; client.side = buff_side_new;
} }
if (!room.started) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN) {
client.is_using_pre_release = found || client.vpass === "COMPAT"; client.is_using_pre_release = found || client.vpass === "COMPAT";
if (client.is_using_pre_release) { if (client.is_using_pre_release) {
ygopro.stoc_send_chat(client, "${pre_release_compat_hint}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${pre_release_compat_hint}", ygopro.constants.COLORS.BABYBLUE);
...@@ -4675,7 +4678,7 @@ ...@@ -4675,7 +4678,7 @@
client.time_confirm_required = true; client.time_confirm_required = true;
} }
} }
if (!(settings.modules.heartbeat_detection.enabled && room.turn && room.turn > 0 && !room.windbot)) { if (!(settings.modules.heartbeat_detection.enabled && room.duel_stage === ygopro.constants.DUEL_STAGE.DUELING && !room.windbot)) {
return; return;
} }
check = false; check = false;
...@@ -4770,10 +4773,10 @@ ...@@ -4770,10 +4773,10 @@
var len3, m, pid, player, ref3, room, tcolor, tplayer; var len3, m, pid, player, ref3, room, tcolor, tplayer;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
pid = info.player; pid = info.player;
if (!(room && pid < 4 && settings.modules.chat_color.enabled && (!settings.modules.hide_name || room.started))) { if (!(room && pid < 4 && settings.modules.chat_color.enabled && (!settings.modules.hide_name || room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN))) {
return; return;
} }
if (room.started && room.turn > 0 && !room.dueling_players[0].is_first) { if (room.duel_stage === ygopro.constants.DUEL_STAGE.DUELING && !room.dueling_players[0].is_first) {
if (room.hostinfo.mode === 2) { if (room.hostinfo.mode === 2) {
pid = { pid = {
0: 2, 0: 2,
...@@ -4813,8 +4816,7 @@ ...@@ -4813,8 +4816,7 @@
} }
client.selected_preduel = false; client.selected_preduel = false;
if (client.pos === 0) { if (client.pos === 0) {
room.selecting_hand = true; room.duel_stage = ygopro.constants.DUEL_STAGE.FINGER;
room.changing_side = false;
} }
if (!(room.random_type || room.arena)) { if (!(room.random_type || room.arena)) {
return; return;
...@@ -4834,8 +4836,7 @@ ...@@ -4834,8 +4836,7 @@
return; return;
} }
client.selected_preduel = false; client.selected_preduel = false;
room.changing_side = false; room.duel_stage = ygopro.constants.DUEL_STAGE.FIRSTGO;
room.selecting_hand = false;
room.selecting_tp = client; room.selecting_tp = client;
if (room.random_type || room.arena) { if (room.random_type || room.arena) {
room.waiting_for_player = client; room.waiting_for_player = client;
...@@ -4849,13 +4850,15 @@ ...@@ -4849,13 +4850,15 @@
if (!room) { if (!room) {
return; return;
} }
room.changing_side = true; if (client.pos === 0) {
room.duel_stage = ygopro.constants.DUEL_STAGE.SIDING;
}
client.selected_preduel = false; client.selected_preduel = false;
if (settings.modules.side_timeout) { if (settings.modules.side_timeout) {
client.side_tcount = settings.modules.side_timeout; client.side_tcount = settings.modules.side_timeout;
ygopro.stoc_send_chat(client, "${side_timeout_part1}" + settings.modules.side_timeout + "${side_timeout_part2}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${side_timeout_part1}" + settings.modules.side_timeout + "${side_timeout_part2}", ygopro.constants.COLORS.BABYBLUE);
sinterval = setInterval(function() { sinterval = setInterval(function() {
if (!(room && room.started && client && client.side_tcount && room.changing_side)) { if (!(room && client && client.side_tcount && room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING)) {
clearInterval(sinterval); clearInterval(sinterval);
return; return;
} }
...@@ -4972,7 +4975,7 @@ ...@@ -4972,7 +4975,7 @@
var len3, m, room, time_passed; var len3, m, room, time_passed;
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.started && room.random_type && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) { if (!(room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.random_type && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) {
continue; continue;
} }
time_passed = Math.floor((moment() - room.last_active_time) / 1000); time_passed = Math.floor((moment() - room.last_active_time) / 1000);
...@@ -4996,7 +4999,7 @@ ...@@ -4996,7 +4999,7 @@
var len3, len4, m, n, player, room, time_passed, waited_time; var len3, len4, m, n, player, room, time_passed, waited_time;
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.started && room.arena && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) { if (!(room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.arena && room.last_active_time && room.waiting_for_player && room.get_disconnected_count() === 0)) {
continue; continue;
} }
time_passed = Math.floor((moment() - room.last_active_time) / 1000); time_passed = Math.floor((moment() - room.last_active_time) / 1000);
...@@ -5013,7 +5016,7 @@ ...@@ -5013,7 +5016,7 @@
if (settings.modules.arena_mode.punish_quit_before_match) { if (settings.modules.arena_mode.punish_quit_before_match) {
for (n = 0, len4 = ROOM_all.length; n < len4; n++) { for (n = 0, len4 = ROOM_all.length; n < len4; n++) {
room = ROOM_all[n]; room = ROOM_all[n];
if (!(room && room.arena && !room.started && room.get_playing_player().length < 2)) { if (!(room && room.arena && room.duel_stage === ygopro.constants.DUEL_STAGE.BEGIN && room.get_playing_player().length < 2)) {
continue; continue;
} }
player = room.get_playing_player()[0]; player = room.get_playing_player()[0];
...@@ -5036,11 +5039,11 @@ ...@@ -5036,11 +5039,11 @@
var len3, len4, m, n, player, ref3, room; var len3, len4, m, n, player, ref3, room;
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.started && (room.hostinfo.time_limit === 0 || !room.turn || room.turn <= 0) && !room.windbot) { if (room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && (room.hostinfo.time_limit === 0 || room.duel_stage !== ygopro.constants.DUEL_STAGE.DUELING) && !room.windbot) {
ref3 = room.get_playing_player(); ref3 = room.get_playing_player();
for (n = 0, len4 = ref3.length; n < len4; n++) { for (n = 0, len4 = ref3.length; n < len4; n++) {
player = ref3[n]; player = ref3[n];
if (player && (!room.changing_side || player.selected_preduel)) { if (player && (room.duel_stage !== ygopro.constants.DUEL_STAGE.SIDING || player.selected_preduel)) {
CLIENT_heartbeat_register(player, true); CLIENT_heartbeat_register(player, true);
} }
} }
...@@ -5055,7 +5058,7 @@ ...@@ -5055,7 +5058,7 @@
results = []; results = [];
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.started && room.hostinfo.auto_death && !room.auto_death_triggered && current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death)) { if (!(room && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && room.hostinfo.auto_death && !room.auto_death_triggered && current_time - moment(room.start_time) > 60000 * room.hostinfo.auto_death)) {
continue; continue;
} }
room.auto_death_triggered = true; room.auto_death_triggered = true;
...@@ -5153,7 +5156,7 @@ ...@@ -5153,7 +5156,7 @@
id: (-1).toString(), id: (-1).toString(),
name: player.name, name: player.name,
ip: settings.modules.http.show_ip && pass_validated && !player.is_local ? player.ip.slice(7) : null, ip: settings.modules.http.show_ip && pass_validated && !player.is_local ? player.ip.slice(7) : null,
status: settings.modules.http.show_info && room.started && player.pos !== 7 ? { status: settings.modules.http.show_info && room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN && player.pos !== 7 ? {
score: room.scores[player.name_vpass], score: room.scores[player.name_vpass],
lp: player.lp != null ? player.lp : room.hostinfo.start_lp, lp: player.lp != null ? player.lp : room.hostinfo.start_lp,
cards: room.hostinfo.mode !== 2 ? (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : null cards: room.hostinfo.mode !== 2 ? (player.card_count != null ? player.card_count : room.hostinfo.start_hand) : null
...@@ -5164,7 +5167,7 @@ ...@@ -5164,7 +5167,7 @@
} }
return results1; return results1;
})(), "pos"), })(), "pos"),
istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " " + (room.changing_side ? "Siding" : "Turn:" + (room.turn != null ? room.turn : 0) + (room.death ? "/" + (room.death > 0 ? room.death - 1 : "Death") : "")) : 'start') : 'wait' istart: room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " " + (room.duel_stage === ygopro.constants.DUEL_STAGE.SIDING ? "Siding" : "Turn:" + (room.turn != null ? room.turn : 0) + (room.death ? "/" + (room.death > 0 ? room.death - 1 : "Death") : "")) : 'start') : 'wait'
}); });
} }
} }
...@@ -5399,7 +5402,7 @@ ...@@ -5399,7 +5402,7 @@
continue; continue;
} }
kick_room_found = true; kick_room_found = true;
if (room.started) { if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
room.scores[room.dueling_players[0].name_vpass] = 0; room.scores[room.dueling_players[0].name_vpass] = 0;
room.scores[room.dueling_players[1].name_vpass] = 0; room.scores[room.dueling_players[1].name_vpass] = 0;
} }
...@@ -5444,7 +5447,7 @@ ...@@ -5444,7 +5447,7 @@
death_room_found = false; death_room_found = false;
for (r = 0, len8 = ROOM_all.length; r < len8; r++) { for (r = 0, len8 = ROOM_all.length; r < len8; r++) {
room = ROOM_all[r]; room = ROOM_all[r];
if (room && (u.query.death === "all" || u.query.death === room.process_pid.toString() || u.query.death === room.name)) { if (room && (u.query.deathcancel === "all" || u.query.deathcancel === room.process_pid.toString() || u.query.deathcancel === room.name)) {
if (room.cancel_death()) { if (room.cancel_death()) {
death_room_found = true; death_room_found = true;
} }
...@@ -5467,7 +5470,7 @@ ...@@ -5467,7 +5470,7 @@
if (!(room)) { if (!(room)) {
continue; continue;
} }
if (room.started) { if (room.duel_stage !== ygopro.constants.DUEL_STAGE.BEGIN) {
room.scores[room.dueling_players[0].name_vpass] = 0; room.scores[room.dueling_players[0].name_vpass] = 0;
room.scores[room.dueling_players[1].name_vpass] = 0; room.scores[room.dueling_players[1].name_vpass] = 0;
} }
......
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