Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro
Commits
1e59412f
Commit
1e59412f
authored
Jun 23, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
1003f3df
8ef3f868
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
380 additions
and
38 deletions
+380
-38
data/default_config.json
data/default_config.json
+6
-0
data/i18n.json
data/i18n.json
+12
-0
package.json
package.json
+1
-0
ygopro-server.coffee
ygopro-server.coffee
+155
-14
ygopro-server.js
ygopro-server.js
+206
-24
No files found.
data/default_config.json
View file @
1e59412f
...
...
@@ -102,6 +102,12 @@
"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"
:
false
,
"accesskey"
:
"233"
,
...
...
data/i18n.json
View file @
1e59412f
...
...
@@ -137,6 +137,12 @@
"deck_incorrect_reconnect"
:
"Please pick your previous deck."
,
"reconnect_failed"
:
"Reconnect failed."
,
"reconnecting_to_room"
:
"Reconnecting to server..."
,
"challonge_user_not_found"
:
"You are not a participant of the tournament."
,
"challonge_match_load_failed"
:
"Failed loading tournament info."
,
"challonge_match_not_found"
:
"Your current match was not found."
,
"challonge_match_already_finished"
:
"Your current match was already finished. Please call the judge for any help."
,
"challonge_match_created"
:
"A room for match only is created. Your opponent will join in automatically."
,
"challonge_player_already_in"
:
"Please do not enter the room you are already in."
,
"athletic_arena_tip"
:
"During an athletic match, a game quit behavior is regarded as a surrender."
},
"es-es"
:
{
...
...
@@ -414,6 +420,12 @@
"deck_incorrect_reconnect"
:
"请选择你在本局决斗中使用的卡组。"
,
"reconnect_failed"
:
"重新连接失败。"
,
"reconnecting_to_room"
:
"正在重新连接到服务器……"
,
"challonge_user_not_found"
:
"未找到你的参赛信息。"
,
"challonge_match_load_failed"
:
"读取比赛信息失败。"
,
"challonge_match_not_found"
:
"你没有当前轮次的比赛。"
,
"challonge_match_already_finished"
:
"你在当前轮次的比赛已经结束,如需重赛,请联系裁判。"
,
"challonge_match_created"
:
"已建立比赛专用房间,将会自动匹配你的对手。"
,
"challonge_player_already_in"
:
"请不要重复加入比赛房间。"
,
"athletic_arena_tip"
:
"在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr"
:
{
...
...
package.json
View file @
1e59412f
...
...
@@ -12,6 +12,7 @@
"author"
:
"zh99998 <zh99998@gmail.com>, mercury233 <me@mercury233.me>"
,
"dependencies"
:
{
"
bunyan
"
:
"
latest
"
,
"
challonge
"
:
"
^2.1.1
"
,
"
deepmerge
"
:
"
latest
"
,
"
load-json-file
"
:
"
latest
"
,
"
moment
"
:
"
latest
"
,
...
...
ygopro-server.coffee
View file @
1e59412f
...
...
@@ -64,6 +64,7 @@ import_datas = [
"last_game_msg_title"
,
"last_hint_msg"
,
"start_deckbuf"
,
"challonge_info"
,
"ready_trap"
]
...
...
@@ -265,6 +266,11 @@ if settings.modules.mycard.enabled
log
.
info
"loading mycard user..."
pg_client
.
connect
()
if
settings
.
modules
.
challonge
.
enabled
challonge
=
require
(
'challonge'
).
createClient
({
apiKey
:
settings
.
modules
.
challonge
.
api_key
})
# 获取可用内存
memory_usage
=
0
get_memory_usage
=
()
->
...
...
@@ -462,7 +468,7 @@ release_disconnect = (dinfo, reconnected) ->
return
CLIENT_get_authorize_key
=
(
client
)
->
if
settings
.
modules
.
mycard
.
enabled
or
settings
.
modules
.
tournament_mode
.
enabled
or
client
.
is_local
if
settings
.
modules
.
mycard
.
enabled
or
settings
.
modules
.
tournament_mode
.
enabled
or
settings
.
modules
.
challonge
.
enabled
or
client
.
is_local
return
client
.
name
else
return
client
.
ip
+
":"
+
client
.
name
...
...
@@ -665,6 +671,8 @@ class Room
@
duel_count
=
0
@
death
=
0
@
turn
=
0
if
settings
.
modules
.
challonge
.
enabled
@
challonge_duel_log
=
{}
ROOM_all
.
push
this
@
hostinfo
||=
JSON
.
parse
(
JSON
.
stringify
(
settings
.
hostinfo
))
...
...
@@ -834,6 +842,16 @@ class Room
#else
# log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
return
if
settings
.
modules
.
challonge
.
enabled
and
@
started
challonge
.
matches
.
update
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
matchId
:
@
challonge_info
.
id
,
match
:
@
challonge_duel_log
,
callback
:
(
err
,
data
)
->
if
err
log
.
warn
(
"Errored pushing scores to Challonge."
,
err
)
return
})
if
@
player_datas
.
length
and
settings
.
modules
.
cloud_replay
.
enabled
replay_id
=
@
cloud_replay_id
if
@
has_ygopro_error
...
...
@@ -1314,7 +1332,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
}
CLIENT_kick
(
client
)
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
random_duel
.
enabled
and
!
settings
.
modules
.
windbot
.
enabled
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
random_duel
.
enabled
and
!
settings
.
modules
.
windbot
.
enabled
and
!
settings
.
modules
.
challonge
.
enabled
ygopro
.
stoc_die
(
client
,
"${blank_room_name}"
)
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard
.
enabled
and
info
.
pass
[
0
...
3
]
!=
'AI#'
...
...
@@ -1377,6 +1395,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
}
options
.
lflist
=
_
.
findIndex
lflists
,
(
list
)
->
((
options
.
rule
==
1
)
==
list
.
tcg
)
and
list
.
date
.
isBefore
()
room
=
new
Room
(
name
,
options
)
if
room
room
.
title
=
info
.
pass
.
slice
(
8
).
replace
(
String
.
fromCharCode
(
0xFEFF
),
' '
)
room
.
private
=
action
==
2
when
3
...
...
@@ -1387,6 +1406,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
return
when
4
room
=
ROOM_find_or_create_by_name
(
'M#'
+
info
.
pass
.
slice
(
8
))
if
room
room
.
private
=
true
room
.
arena
=
settings
.
modules
.
arena_mode
.
mode
if
room
.
arena
==
"athletic"
...
...
@@ -1460,6 +1480,90 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
finish
(
buffer
)
else
if
settings
.
modules
.
challonge
.
enabled
pre_room
=
ROOM_find_by_name
(
info
.
pass
)
if
pre_room
and
pre_room
.
started
and
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
room
=
pre_room
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${watch_join}"
)
room
.
watchers
.
push
client
ygopro
.
stoc_send_chat
(
client
,
"${watch_watching}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
for
buffer
in
room
.
watcher_buffers
client
.
write
buffer
else
ygopro
.
stoc_send_chat
(
client
,
'${loading_user_info}'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
challonge
.
participants
.
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
(
err
,
data
)
->
if
err
or
!
data
if
err
log
.
warn
(
"Failed loading Challonge user info"
,
err
)
ygopro
.
stoc_die
(
client
,
'${challonge_match_load_failed}'
)
return
found
=
false
for
k
,
user
of
data
if
user
.
participant
and
user
.
participant
.
name
==
client
.
name
found
=
user
.
participant
break
if
!
found
ygopro
.
stoc_die
(
client
,
'${challonge_user_not_found}'
)
return
client
.
challonge_info
=
found
challonge
.
matches
.
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
(
err
,
data
)
->
if
err
or
!
data
if
err
log
.
warn
(
"Failed loading Challonge match info"
,
err
)
ygopro
.
stoc_die
(
client
,
'${challonge_match_load_failed}'
)
return
found
=
false
for
k
,
match
of
data
if
match
and
match
.
match
and
!
match
.
match
.
winnerId
and
match
.
match
.
player1Id
and
match
.
match
.
player2Id
and
(
match
.
match
.
player1Id
==
client
.
challonge_info
.
id
or
match
.
match
.
player2Id
==
client
.
challonge_info
.
id
)
found
=
match
.
match
break
if
!
found
ygopro
.
stoc_die
(
client
,
'${challonge_match_not_found}'
)
return
#if found.winnerId
# ygopro.stoc_die(client, '${challonge_match_already_finished}')
# return
room
=
ROOM_find_or_create_by_name
(
'M#'
+
found
.
id
)
if
room
room
.
challonge_info
=
found
room
.
max_player
=
2
room
.
welcome
=
"${challonge_match_created}"
if
!
room
ygopro
.
stoc_die
(
client
,
"${server_full}"
)
else
if
room
.
error
ygopro
.
stoc_die
(
client
,
room
.
error
)
else
if
room
.
started
if
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${watch_join}"
)
room
.
watchers
.
push
client
ygopro
.
stoc_send_chat
(
client
,
"${watch_watching}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
for
buffer
in
room
.
watcher_buffers
client
.
write
buffer
else
ygopro
.
stoc_die
(
client
,
"${watch_denied}"
)
else
for
player
in
room
.
players
when
player
and
player
!=
client
and
player
.
name
==
client
.
name
ygopro
.
stoc_die
(
client
,
"${challonge_player_already_in}"
)
return
#client.room = room
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
room
.
connect
(
client
)
return
})
return
})
else
if
!
client
.
name
or
client
.
name
==
""
ygopro
.
stoc_die
(
client
,
"${bad_user_name}"
)
...
...
@@ -1786,6 +1890,28 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
room
.
winner_name
=
room
.
dueling_players
[
pos
].
name
#log.info room.dueling_players, pos
room
.
scores
[
room
.
winner_name
]
=
room
.
scores
[
room
.
winner_name
]
+
1
if
settings
.
modules
.
challonge
.
enabled
if
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
>
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
room
.
challonge_duel_log
.
winnerId
=
room
.
dueling_players
[
0
].
challonge_info
.
id
else
if
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
<
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
room
.
challonge_duel_log
.
winnerId
=
room
.
dueling_players
[
1
].
challonge_info
.
id
else
if
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
!=
0
or
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
!=
0
room
.
challonge_duel_log
.
winnerId
=
"tie"
if
settings
.
modules
.
challonge
.
post_detailed_score
if
room
.
dueling_players
[
0
].
challonge_info
.
id
==
room
.
challonge_info
.
player1Id
and
room
.
dueling_players
[
1
].
challonge_info
.
id
==
room
.
challonge_info
.
player2Id
room
.
challonge_duel_log
.
scoresCsv
=
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
+
"-"
+
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
else
if
room
.
dueling_players
[
1
].
challonge_info
.
id
==
room
.
challonge_info
.
player1Id
and
room
.
dueling_players
[
0
].
challonge_info
.
id
==
room
.
challonge_info
.
player2Id
room
.
challonge_duel_log
.
scoresCsv
=
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
+
"-"
+
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
else
room
.
challonge_duel_log
.
scoresCsv
=
"0-0"
log
.
warn
(
"Score mismatch."
,
room
.
name
)
else
if
room
.
challonge_duel_log
.
winnerId
==
room
.
challonge_info
.
player1Id
room
.
challonge_duel_log
.
scoresCsv
=
"1-0"
else
if
room
.
challonge_duel_log
.
winnerId
==
room
.
challonge_info
.
player2Id
room
.
challonge_duel_log
.
scoresCsv
=
"0-1"
else
room
.
challonge_duel_log
.
scoresCsv
=
"0-0"
if
room
.
death
if
settings
.
modules
.
http
.
quick_death_rule
==
1
or
settings
.
modules
.
http
.
quick_death_rule
==
3
room
.
death
=
-
1
...
...
@@ -1871,7 +1997,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server)->
ygopro
.
ctos_follow
'HS_TOOBSERVER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
if
not
room
.
arena
or
client
.
is_local
if
(
!
room
.
arena
and
!
settings
.
modules
.
challonge
.
enabled
)
or
client
.
is_local
return
false
for
player
in
room
.
players
if
player
==
client
...
...
@@ -1884,7 +2010,7 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)->
return
unless
room
for
player
in
room
.
players
if
player
and
player
.
pos
==
info
.
pos
and
player
!=
client
if
room
.
arena
==
"athletic"
if
room
.
arena
==
"athletic"
or
settings
.
modules
.
challonge
.
enabled
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${kicked_by_system}"
,
ygopro
.
constants
.
COLORS
.
RED
)
CLIENT_kick
(
client
)
return
true
...
...
@@ -2464,7 +2590,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
ygopro
.
stoc_follow
'REPLAY'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
return
settings
.
modules
.
tournament_mode
.
enabled
and
settings
.
modules
.
tournament_mode
.
replay_safe
unless
room
return
settings
.
modules
.
tournament_mode
.
enabled
and
settings
.
modules
.
tournament_mode
.
replay_safe
and
settings
.
modules
.
tournament_mode
.
block_replay_to_player
unless
room
if
settings
.
modules
.
cloud_replay
.
enabled
and
room
.
random_type
Cloud_replay_ids
.
push
room
.
cloud_replay_id
if
settings
.
modules
.
tournament_mode
.
enabled
and
settings
.
modules
.
tournament_mode
.
replay_safe
...
...
@@ -2729,9 +2855,24 @@ if settings.modules.http
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['ban ok', '"
+
u
.
query
.
ban
+
"']"
))
else
if
u
.
query
.
kick
kick_room_found
=
false
for
room
in
ROOM_all
when
room
and
room
.
established
and
(
u
.
query
.
kick
==
"all"
or
u
.
query
.
kick
==
room
.
port
.
toString
()
or
u
.
query
.
kick
==
room
.
name
)
kick_room_found
=
true
if
room
.
started
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
=
0
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
=
0
room
.
process
.
kill
()
room
.
delete
()
response
.
writeHead
(
200
)
if
kick_room_found
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['kick ok', '"
+
u
.
query
.
kick
+
"']"
))
else
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['room not found', '"
+
u
.
query
.
kick
+
"']"
))
else
if
u
.
query
.
death
death_room_found
=
false
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
!
room
.
death
and
(
u
.
query
.
death
==
"all"
or
u
.
query
.
death
==
room
.
port
.
toString
())
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
!
room
.
death
and
(
u
.
query
.
death
==
"all"
or
u
.
query
.
death
==
room
.
port
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
death_room_found
=
true
oppo_pos
=
if
room
.
hostinfo
.
mode
==
2
then
2
else
1
if
!
room
.
changing_side
and
(
!
room
.
duel_count
or
room
.
turn
)
...
...
ygopro-server.js
View file @
1e59412f
// Generated by CoffeeScript 1.12.7
(
function
()
{
var
CLIENT_get_authorize_key
,
CLIENT_import_data
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
Cloud_replay_ids
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
Room
,
SERVER_clear_disconnect
,
_
,
addCallback
,
badwords
,
ban_user
,
bunyan
,
chat_color
,
config
,
cppversion
,
crypto
,
date
,
default_config
,
default_data
,
dialogues
,
disconnect_list
,
duel_log
,
e
,
exec
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
import_datas
,
j
,
l
,
len
,
len1
,
lflists
,
list
,
loadJSON
,
load_dialogues
,
load_dialogues_custom
,
load_tips
,
load_words
,
log
,
memory_usage
,
merge
,
moment
,
net
,
oldbadwords
,
oldconfig
,
olddialogues
,
oldduellog
,
oldtips
,
oldwords
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
ref
,
ref1
,
release_disconnect
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
tips
,
url
,
users_cache
,
wait_room_start
,
wait_room_start_arena
,
windbot_bin
,
windbot_parameters
,
windbot_process
,
windbots
,
words
,
ygopro
,
zlib
;
var
CLIENT_get_authorize_key
,
CLIENT_import_data
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
Cloud_replay_ids
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
Room
,
SERVER_clear_disconnect
,
_
,
addCallback
,
badwords
,
ban_user
,
bunyan
,
cha
llonge
,
cha
t_color
,
config
,
cppversion
,
crypto
,
date
,
default_config
,
default_data
,
dialogues
,
disconnect_list
,
duel_log
,
e
,
exec
,
execFile
,
fs
,
geoip
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
import_datas
,
j
,
l
,
len
,
len1
,
lflists
,
list
,
loadJSON
,
load_dialogues
,
load_dialogues_custom
,
load_tips
,
load_words
,
log
,
memory_usage
,
merge
,
moment
,
net
,
oldbadwords
,
oldconfig
,
olddialogues
,
oldduellog
,
oldtips
,
oldwords
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
ref
,
ref1
,
release_disconnect
,
report_to_big_brother
,
request
,
requestListener
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
tips
,
url
,
users_cache
,
wait_room_start
,
wait_room_start_arena
,
windbot_bin
,
windbot_parameters
,
windbot_process
,
windbots
,
words
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -58,7 +58,7 @@
}
});
import_datas
=
[
"
abuse_count
"
,
"
rag
"
,
"
rid
"
,
"
is_post_watcher
"
,
"
retry_count
"
,
"
name
"
,
"
is_first
"
,
"
lp
"
,
"
card_count
"
,
"
is_host
"
,
"
pos
"
,
"
surrend_confirm
"
,
"
kick_count
"
,
"
deck_saved
"
,
"
main
"
,
"
side
"
,
"
side_interval
"
,
"
side_tcount
"
,
"
selected_preduel
"
,
"
last_game_msg
"
,
"
last_game_msg_title
"
,
"
last_hint_msg
"
,
"
start_deckbuf
"
,
"
ready_trap
"
];
import_datas
=
[
"
abuse_count
"
,
"
rag
"
,
"
rid
"
,
"
is_post_watcher
"
,
"
retry_count
"
,
"
name
"
,
"
is_first
"
,
"
lp
"
,
"
card_count
"
,
"
is_host
"
,
"
pos
"
,
"
surrend_confirm
"
,
"
kick_count
"
,
"
deck_saved
"
,
"
main
"
,
"
side
"
,
"
side_interval
"
,
"
side_tcount
"
,
"
selected_preduel
"
,
"
last_game_msg
"
,
"
last_game_msg_title
"
,
"
last_hint_msg
"
,
"
start_deckbuf
"
,
"
challonge_info
"
,
"
ready_trap
"
];
merge
=
require
(
'
deepmerge
'
);
...
...
@@ -320,6 +320,12 @@
pg_client
.
connect
();
}
if
(
settings
.
modules
.
challonge
.
enabled
)
{
challonge
=
require
(
'
challonge
'
).
createClient
({
apiKey
:
settings
.
modules
.
challonge
.
api_key
});
}
memory_usage
=
0
;
get_memory_usage
=
function
()
{
...
...
@@ -599,7 +605,7 @@
};
CLIENT_get_authorize_key
=
function
(
client
)
{
if
(
settings
.
modules
.
mycard
.
enabled
||
settings
.
modules
.
tournament_mode
.
enabled
||
client
.
is_local
)
{
if
(
settings
.
modules
.
mycard
.
enabled
||
settings
.
modules
.
tournament_mode
.
enabled
||
settings
.
modules
.
challonge
.
enabled
||
client
.
is_local
)
{
return
client
.
name
;
}
else
{
return
client
.
ip
+
"
:
"
+
client
.
name
;
...
...
@@ -854,6 +860,9 @@
this
.
duel_count
=
0
;
this
.
death
=
0
;
this
.
turn
=
0
;
if
(
settings
.
modules
.
challonge
.
enabled
)
{
this
.
challonge_duel_log
=
{};
}
ROOM_all
.
push
(
this
);
this
.
hostinfo
||
(
this
.
hostinfo
=
JSON
.
parse
(
JSON
.
stringify
(
settings
.
hostinfo
)));
delete
this
.
hostinfo
.
comment
;
...
...
@@ -1078,6 +1087,18 @@
})(
this
));
}
}
if
(
settings
.
modules
.
challonge
.
enabled
&&
this
.
started
)
{
challonge
.
matches
.
update
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
matchId
:
this
.
challonge_info
.
id
,
match
:
this
.
challonge_duel_log
,
callback
:
function
(
err
,
data
)
{
if
(
err
)
{
log
.
warn
(
"
Errored pushing scores to Challonge.
"
,
err
);
}
}
});
}
if
(
this
.
player_datas
.
length
&&
settings
.
modules
.
cloud_replay
.
enabled
)
{
replay_id
=
this
.
cloud_replay_id
;
if
(
this
.
has_ygopro_error
)
{
...
...
@@ -1572,7 +1593,7 @@
});
ygopro
.
ctos_follow
(
'
JOIN_GAME
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
var
check
,
decrypted_buffer
,
finish
,
i
,
id
,
len2
,
len3
,
m
,
n
,
name
,
ref2
,
ref3
,
replay_id
,
room
,
secret
;
var
check
,
decrypted_buffer
,
finish
,
i
,
id
,
len2
,
len3
,
len4
,
m
,
n
,
name
,
o
,
pre_room
,
ref2
,
ref3
,
ref4
,
replay_id
,
room
,
secret
;
info
.
pass
=
info
.
pass
.
trim
();
if
(
CLIENT_is_able_to_reconnect
(
client
))
{
CLIENT_pre_reconnect
(
client
);
...
...
@@ -1629,7 +1650,7 @@
code
:
settings
.
version
});
CLIENT_kick
(
client
);
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
random_duel
.
enabled
&&
!
settings
.
modules
.
windbot
.
enabled
)
{
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
random_duel
.
enabled
&&
!
settings
.
modules
.
windbot
.
enabled
&&
!
settings
.
modules
.
challonge
.
enabled
)
{
ygopro
.
stoc_die
(
client
,
"
${blank_room_name}
"
);
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard
.
enabled
&&
info
.
pass
.
slice
(
0
,
3
)
!==
'
AI#
'
)
{
ygopro
.
stoc_send_chat
(
client
,
'
${loading_user_info}
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
...
...
@@ -1684,8 +1705,10 @@
return
((
options
.
rule
===
1
)
===
list
.
tcg
)
&&
list
.
date
.
isBefore
();
});
room
=
new
Room
(
name
,
options
);
if
(
room
)
{
room
.
title
=
info
.
pass
.
slice
(
8
).
replace
(
String
.
fromCharCode
(
0xFEFF
),
'
'
);
room
[
"
private
"
]
=
action
===
2
;
}
break
;
case
3
:
name
=
info
.
pass
.
slice
(
8
);
...
...
@@ -1697,12 +1720,14 @@
break
;
case
4
:
room
=
ROOM_find_or_create_by_name
(
'
M#
'
+
info
.
pass
.
slice
(
8
));
if
(
room
)
{
room
[
"
private
"
]
=
true
;
room
.
arena
=
settings
.
modules
.
arena_mode
.
mode
;
if
(
room
.
arena
===
"
athletic
"
)
{
room
.
max_player
=
2
;
room
.
welcome
=
"
${athletic_arena_tip}
"
;
}
}
break
;
case
5
:
title
=
info
.
pass
.
slice
(
8
).
replace
(
String
.
fromCharCode
(
0xFEFF
),
'
'
);
...
...
@@ -1784,6 +1809,115 @@
}
return
finish
(
buffer
);
});
}
else
if
(
settings
.
modules
.
challonge
.
enabled
)
{
pre_room
=
ROOM_find_by_name
(
info
.
pass
);
if
(
pre_room
&&
pre_room
.
started
&&
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
)
{
room
=
pre_room
;
client
.
setTimeout
(
300000
);
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${watch_join}
"
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref3
=
room
.
watcher_buffers
;
for
(
n
=
0
,
len3
=
ref3
.
length
;
n
<
len3
;
n
++
)
{
buffer
=
ref3
[
n
];
client
.
write
(
buffer
);
}
}
else
{
ygopro
.
stoc_send_chat
(
client
,
'
${loading_user_info}
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
challonge
.
participants
.
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
function
(
err
,
data
)
{
var
found
,
k
,
user
;
if
(
err
||
!
data
)
{
if
(
err
)
{
log
.
warn
(
"
Failed loading Challonge user info
"
,
err
);
}
ygopro
.
stoc_die
(
client
,
'
${challonge_match_load_failed}
'
);
return
;
}
found
=
false
;
for
(
k
in
data
)
{
user
=
data
[
k
];
if
(
user
.
participant
&&
user
.
participant
.
name
===
client
.
name
)
{
found
=
user
.
participant
;
break
;
}
}
if
(
!
found
)
{
ygopro
.
stoc_die
(
client
,
'
${challonge_user_not_found}
'
);
return
;
}
client
.
challonge_info
=
found
;
challonge
.
matches
.
index
({
id
:
settings
.
modules
.
challonge
.
tournament_id
,
callback
:
function
(
err
,
data
)
{
var
len4
,
len5
,
match
,
o
,
p
,
player
,
ref4
,
ref5
;
if
(
err
||
!
data
)
{
if
(
err
)
{
log
.
warn
(
"
Failed loading Challonge match info
"
,
err
);
}
ygopro
.
stoc_die
(
client
,
'
${challonge_match_load_failed}
'
);
return
;
}
found
=
false
;
for
(
k
in
data
)
{
match
=
data
[
k
];
if
(
match
&&
match
.
match
&&
!
match
.
match
.
winnerId
&&
match
.
match
.
player1Id
&&
match
.
match
.
player2Id
&&
(
match
.
match
.
player1Id
===
client
.
challonge_info
.
id
||
match
.
match
.
player2Id
===
client
.
challonge_info
.
id
))
{
found
=
match
.
match
;
break
;
}
}
if
(
!
found
)
{
ygopro
.
stoc_die
(
client
,
'
${challonge_match_not_found}
'
);
return
;
}
room
=
ROOM_find_or_create_by_name
(
'
M#
'
+
found
.
id
);
if
(
room
)
{
room
.
challonge_info
=
found
;
room
.
max_player
=
2
;
room
.
welcome
=
"
${challonge_match_created}
"
;
}
if
(
!
room
)
{
ygopro
.
stoc_die
(
client
,
"
${server_full}
"
);
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_die
(
client
,
room
.
error
);
}
else
if
(
room
.
started
)
{
if
(
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
)
{
client
.
setTimeout
(
300000
);
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${watch_join}
"
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref4
=
room
.
watcher_buffers
;
for
(
o
=
0
,
len4
=
ref4
.
length
;
o
<
len4
;
o
++
)
{
buffer
=
ref4
[
o
];
client
.
write
(
buffer
);
}
}
else
{
ygopro
.
stoc_die
(
client
,
"
${watch_denied}
"
);
}
}
else
{
ref5
=
room
.
players
;
for
(
p
=
0
,
len5
=
ref5
.
length
;
p
<
len5
;
p
++
)
{
player
=
ref5
[
p
];
if
(
!
(
player
&&
player
!==
client
&&
player
.
name
===
client
.
name
))
{
continue
;
}
ygopro
.
stoc_die
(
client
,
"
${challonge_player_already_in}
"
);
return
;
}
client
.
setTimeout
(
300000
);
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
room
.
connect
(
client
);
}
}
});
}
});
}
}
else
if
(
!
client
.
name
||
client
.
name
===
""
)
{
ygopro
.
stoc_die
(
client
,
"
${bad_user_name}
"
);
}
else
if
(
ROOM_connected_ip
[
client
.
ip
]
>
5
)
{
...
...
@@ -1834,9 +1968,9 @@
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${watch_join}
"
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref
3
=
room
.
watcher_buffers
;
for
(
n
=
0
,
len3
=
ref3
.
length
;
n
<
len3
;
n
++
)
{
buffer
=
ref
3
[
n
];
ref
4
=
room
.
watcher_buffers
;
for
(
o
=
0
,
len4
=
ref4
.
length
;
o
<
len4
;
o
++
)
{
buffer
=
ref
4
[
o
];
client
.
write
(
buffer
);
}
}
else
{
...
...
@@ -2141,6 +2275,33 @@
room
.
winner_name
=
room
.
dueling_players
[
pos
].
name
;
room
.
scores
[
room
.
winner_name
]
=
room
.
scores
[
room
.
winner_name
]
+
1
;
}
if
(
settings
.
modules
.
challonge
.
enabled
)
{
if
(
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
>
room
.
scores
[
room
.
dueling_players
[
1
].
name
])
{
room
.
challonge_duel_log
.
winnerId
=
room
.
dueling_players
[
0
].
challonge_info
.
id
;
}
else
if
(
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
<
room
.
scores
[
room
.
dueling_players
[
1
].
name
])
{
room
.
challonge_duel_log
.
winnerId
=
room
.
dueling_players
[
1
].
challonge_info
.
id
;
}
else
if
(
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
!==
0
||
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
!==
0
)
{
room
.
challonge_duel_log
.
winnerId
=
"
tie
"
;
}
if
(
settings
.
modules
.
challonge
.
post_detailed_score
)
{
if
(
room
.
dueling_players
[
0
].
challonge_info
.
id
===
room
.
challonge_info
.
player1Id
&&
room
.
dueling_players
[
1
].
challonge_info
.
id
===
room
.
challonge_info
.
player2Id
)
{
room
.
challonge_duel_log
.
scoresCsv
=
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
+
"
-
"
+
room
.
scores
[
room
.
dueling_players
[
1
].
name
];
}
else
if
(
room
.
dueling_players
[
1
].
challonge_info
.
id
===
room
.
challonge_info
.
player1Id
&&
room
.
dueling_players
[
0
].
challonge_info
.
id
===
room
.
challonge_info
.
player2Id
)
{
room
.
challonge_duel_log
.
scoresCsv
=
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
+
"
-
"
+
room
.
scores
[
room
.
dueling_players
[
0
].
name
];
}
else
{
room
.
challonge_duel_log
.
scoresCsv
=
"
0-0
"
;
log
.
warn
(
"
Score mismatch.
"
,
room
.
name
);
}
}
else
{
if
(
room
.
challonge_duel_log
.
winnerId
===
room
.
challonge_info
.
player1Id
)
{
room
.
challonge_duel_log
.
scoresCsv
=
"
1-0
"
;
}
else
if
(
room
.
challonge_duel_log
.
winnerId
===
room
.
challonge_info
.
player2Id
)
{
room
.
challonge_duel_log
.
scoresCsv
=
"
0-1
"
;
}
else
{
room
.
challonge_duel_log
.
scoresCsv
=
"
0-0
"
;
}
}
}
if
(
room
.
death
)
{
if
(
settings
.
modules
.
http
.
quick_death_rule
===
1
||
settings
.
modules
.
http
.
quick_death_rule
===
3
)
{
room
.
death
=
-
1
;
...
...
@@ -2271,7 +2432,7 @@
if
(
!
room
)
{
return
;
}
if
(
!
room
.
arena
||
client
.
is_local
)
{
if
(
(
!
room
.
arena
&&
!
settings
.
modules
.
challonge
.
enabled
)
||
client
.
is_local
)
{
return
false
;
}
ref2
=
room
.
players
;
...
...
@@ -2295,7 +2456,7 @@
for
(
m
=
0
,
len2
=
ref2
.
length
;
m
<
len2
;
m
++
)
{
player
=
ref2
[
m
];
if
(
player
&&
player
.
pos
===
info
.
pos
&&
player
!==
client
)
{
if
(
room
.
arena
===
"
athletic
"
)
{
if
(
room
.
arena
===
"
athletic
"
||
settings
.
modules
.
challonge
.
enabled
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${kicked_by_system}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
CLIENT_kick
(
client
);
return
true
;
...
...
@@ -3103,7 +3264,7 @@
var
duellog
,
dueltime
,
i
,
len2
,
len3
,
m
,
n
,
player
,
ref2
,
ref3
,
replay_filename
,
room
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
return
settings
.
modules
.
tournament_mode
.
enabled
&&
settings
.
modules
.
tournament_mode
.
replay_safe
;
return
settings
.
modules
.
tournament_mode
.
enabled
&&
settings
.
modules
.
tournament_mode
.
replay_safe
&&
settings
.
modules
.
tournament_mode
.
block_replay_to_player
;
}
if
(
settings
.
modules
.
cloud_replay
.
enabled
&&
room
.
random_type
)
{
Cloud_replay_ids
.
push
(
room
.
cloud_replay_id
);
...
...
@@ -3244,7 +3405,7 @@
return
callback
+
"
(
"
+
text
+
"
);
"
;
};
requestListener
=
function
(
request
,
response
)
{
var
archive_args
,
archive_name
,
archive_process
,
check
,
death_room_found
,
duellog
,
error
,
filename
,
getpath
,
len2
,
len3
,
len4
,
len5
,
m
,
n
,
o
,
oppo_pos
,
p
,
parseQueryString
,
pass_validated
,
player
,
ref2
,
replay
,
room
,
roomsjson
,
u
,
win_pos
;
var
archive_args
,
archive_name
,
archive_process
,
check
,
death_room_found
,
duellog
,
error
,
filename
,
getpath
,
kick_room_found
,
len2
,
len3
,
len4
,
len5
,
len6
,
m
,
n
,
o
,
oppo_pos
,
p
,
parseQueryString
,
pass_validated
,
player
,
q
,
ref2
,
replay
,
room
,
roomsjson
,
u
,
win_pos
;
parseQueryString
=
true
;
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
...
...
@@ -3453,11 +3614,32 @@
ban_user
(
u
.
query
.
ban
);
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['ban ok', '
"
+
u
.
query
.
ban
+
"
']
"
));
}
else
if
(
u
.
query
.
death
)
{
death
_room_found
=
false
;
}
else
if
(
u
.
query
.
kick
)
{
kick
_room_found
=
false
;
for
(
o
=
0
,
len4
=
ROOM_all
.
length
;
o
<
len4
;
o
++
)
{
room
=
ROOM_all
[
o
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
!
room
.
death
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
port
.
toString
())))
{
if
(
!
(
room
&&
room
.
established
&&
(
u
.
query
.
kick
===
"
all
"
||
u
.
query
.
kick
===
room
.
port
.
toString
()
||
u
.
query
.
kick
===
room
.
name
)))
{
continue
;
}
kick_room_found
=
true
;
if
(
room
.
started
)
{
room
.
scores
[
room
.
dueling_players
[
0
].
name
]
=
0
;
room
.
scores
[
room
.
dueling_players
[
1
].
name
]
=
0
;
}
room
.
process
.
kill
();
room
[
"
delete
"
]();
}
response
.
writeHead
(
200
);
if
(
kick_room_found
)
{
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['kick ok', '
"
+
u
.
query
.
kick
+
"
']
"
));
}
else
{
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['room not found', '
"
+
u
.
query
.
kick
+
"
']
"
));
}
}
else
if
(
u
.
query
.
death
)
{
death_room_found
=
false
;
for
(
p
=
0
,
len5
=
ROOM_all
.
length
;
p
<
len5
;
p
++
)
{
room
=
ROOM_all
[
p
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
!
room
.
death
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
port
.
toString
()
||
u
.
query
.
death
===
room
.
name
)))
{
continue
;
}
death_room_found
=
true
;
...
...
@@ -3516,8 +3698,8 @@
}
}
else
if
(
u
.
query
.
deathcancel
)
{
death_room_found
=
false
;
for
(
p
=
0
,
len5
=
ROOM_all
.
length
;
p
<
len5
;
p
++
)
{
room
=
ROOM_all
[
p
];
for
(
q
=
0
,
len6
=
ROOM_all
.
length
;
q
<
len6
;
q
++
)
{
room
=
ROOM_all
[
q
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
room
.
death
&&
(
u
.
query
.
deathcancel
===
"
all
"
||
u
.
query
.
deathcancel
===
room
.
port
.
toString
())))
{
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment