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
e840e9aa
Commit
e840e9aa
authored
Dec 29, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:purerosefallen/ygopro-server
parents
ecabe5b4
ecb27c12
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
48 deletions
+59
-48
data/i18n.json
data/i18n.json
+2
-2
ygopro-server.coffee
ygopro-server.coffee
+29
-23
ygopro-server.js
ygopro-server.js
+28
-23
No files found.
data/i18n.json
View file @
e840e9aa
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
"invalid_password_existed"
:
"Password invalid (Already Existed)"
,
"invalid_password_existed"
:
"Password invalid (Already Existed)"
,
"invalid_password_not_found"
:
"Password invalid (Not Found)"
,
"invalid_password_not_found"
:
"Password invalid (Not Found)"
,
"invalid_password_action"
:
"Password invalid (Invalid Action)"
,
"invalid_password_action"
:
"Password invalid (Invalid Action)"
,
"invalid_password_checksum"
:
"Password incorrect (Checksum Failed)"
,
"invalid_password_checksum"
:
"Password incorrect (Checksum Failed)
(Please re-login your account.)
"
,
"bad_user_name"
:
"Please enter the correct ID"
,
"bad_user_name"
:
"Please enter the correct ID"
,
"server_full"
:
"Server is full, please try again later."
,
"server_full"
:
"Server is full, please try again later."
,
"too_much_connection"
:
"Too many clients running at the moment! "
,
"too_much_connection"
:
"Too many clients running at the moment! "
,
...
@@ -371,7 +371,7 @@
...
@@ -371,7 +371,7 @@
"invalid_password_existed"
:
"主机密码不正确 (Already Existed)"
,
"invalid_password_existed"
:
"主机密码不正确 (Already Existed)"
,
"invalid_password_not_found"
:
"主机密码不正确 (Not Found)"
,
"invalid_password_not_found"
:
"主机密码不正确 (Not Found)"
,
"invalid_password_action"
:
"主机密码不正确 (Invalid Action)"
,
"invalid_password_action"
:
"主机密码不正确 (Invalid Action)"
,
"invalid_password_checksum"
:
"主机密码不正确 (Checksum Failed)"
,
"invalid_password_checksum"
:
"主机密码不正确 (Checksum Failed)
(请退出并重新登录你的账号)
"
,
"bad_user_name"
:
"请输入正确的用户名"
,
"bad_user_name"
:
"请输入正确的用户名"
,
"server_full"
:
"服务器已经爆满,请稍候再试"
,
"server_full"
:
"服务器已经爆满,请稍候再试"
,
"too_much_connection"
:
"同时开启的客户端数量过多 "
,
"too_much_connection"
:
"同时开启的客户端数量过多 "
,
...
...
ygopro-server.coffee
View file @
e840e9aa
...
@@ -378,36 +378,36 @@ if settings.modules.challonge.enabled
...
@@ -378,36 +378,36 @@ if settings.modules.challonge.enabled
if
settings
.
modules
.
challonge
.
cache_ttl
if
settings
.
modules
.
challonge
.
cache_ttl
challonge_cache
=
[]
challonge_cache
=
[]
challonge_queue_callbacks
=
[[],
[]]
challonge_queue_callbacks
=
[[],
[]]
is_requesting
=
[
false
,
false
]
is_requesting
=
[
null
,
null
]
get_callback
=
(
challonge_type
,
_callback
)
->
get_callback
=
(
challonge_type
,
_callback
)
->
return
((
err
,
data
)
->
return
((
err
,
data
)
->
if
settings
.
modules
.
challonge
.
cache_ttl
and
!
err
and
data
if
settings
.
modules
.
challonge
.
cache_ttl
and
!
err
and
data
challonge_cache
[
challonge_type
]
=
data
challonge_cache
[
challonge_type
]
=
data
is_requesting
[
challonge_type
]
=
null
_callback
(
err
,
data
)
_callback
(
err
,
data
)
while
challonge_queue_callbacks
[
challonge_type
].
length
while
challonge_queue_callbacks
[
challonge_type
].
length
cur_callback
=
challonge_queue_callbacks
[
challonge_type
].
splice
(
0
,
1
)[
0
]
cur_callback
=
challonge_queue_callbacks
[
challonge_type
].
splice
(
0
,
1
)[
0
]
cur_callback
(
err
,
data
)
cur_callback
(
err
,
data
)
is_requesting
[
challonge_type
]
=
false
return
return
)
)
challonge
.
participants
.
_index
=
(
_data
)
->
challonge
.
participants
.
_index
=
(
_data
)
->
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
0
]
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
0
]
_data
.
callback
(
null
,
challonge_cache
[
0
])
_data
.
callback
(
null
,
challonge_cache
[
0
])
else
if
is_requesting
[
0
]
else
if
is_requesting
[
0
]
and
moment
()
-
is_requesting
[
0
]
<=
5000
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
)
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
)
else
else
_data
.
callback
=
get_callback
(
0
,
_data
.
callback
)
_data
.
callback
=
get_callback
(
0
,
_data
.
callback
)
is_requesting
[
0
]
=
true
is_requesting
[
0
]
=
moment
()
challonge
.
participants
.
index
(
_data
)
challonge
.
participants
.
index
(
_data
)
return
return
challonge
.
matches
.
_index
=
(
_data
)
->
challonge
.
matches
.
_index
=
(
_data
)
->
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
1
]
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
1
]
_data
.
callback
(
null
,
challonge_cache
[
1
])
_data
.
callback
(
null
,
challonge_cache
[
1
])
else
if
is_requesting
[
1
]
else
if
is_requesting
[
1
]
and
moment
()
-
is_requesting
[
1
]
<=
5000
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
)
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
)
else
else
_data
.
callback
=
get_callback
(
1
,
_data
.
callback
)
_data
.
callback
=
get_callback
(
1
,
_data
.
callback
)
is_requesting
[
1
]
=
true
is_requesting
[
1
]
=
moment
()
challonge
.
matches
.
index
(
_data
)
challonge
.
matches
.
index
(
_data
)
return
return
refresh_challonge_cache
=
()
->
refresh_challonge_cache
=
()
->
...
@@ -849,7 +849,7 @@ CLIENT_send_reconnect_info = (client, server, room) ->
...
@@ -849,7 +849,7 @@ CLIENT_send_reconnect_info = (client, server, room) ->
client
.
reconnecting
=
false
client
.
reconnecting
=
false
else
if
room
.
selecting_tp
else
if
room
.
selecting_tp
ygopro
.
stoc_send
(
client
,
'DUEL_START'
)
ygopro
.
stoc_send
(
client
,
'DUEL_START'
)
if
client
==
room
.
selecting_tp
and
!
client
.
selected_preduel
if
client
==
room
.
selecting_tp
#
and !client.selected_preduel
ygopro
.
stoc_send
(
client
,
'SELECT_TP'
)
ygopro
.
stoc_send
(
client
,
'SELECT_TP'
)
client
.
reconnecting
=
false
client
.
reconnecting
=
false
else
else
...
@@ -1106,6 +1106,7 @@ class Room
...
@@ -1106,6 +1106,7 @@ class Room
try
try
@
process
=
spawn
'./ygopro'
,
param
,
{
cwd
:
'ygopro'
}
@
process
=
spawn
'./ygopro'
,
param
,
{
cwd
:
'ygopro'
}
@
process_pid
=
@
process
.
pid
@
process
.
on
'error'
,
(
err
)
=>
@
process
.
on
'error'
,
(
err
)
=>
_
.
each
@
players
,
(
player
)
->
_
.
each
@
players
,
(
player
)
->
ygopro
.
stoc_die
(
player
,
"${create_room_failed}"
)
ygopro
.
stoc_die
(
player
,
"${create_room_failed}"
)
...
@@ -1763,9 +1764,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1763,9 +1764,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
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
.
started
room_buffer
.
writeInt8
((
if
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
].
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
)
buffer_pos
+=
4
buffer_pos
+=
4
else
else
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
...
@@ -1780,9 +1781,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1780,9 +1781,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
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
.
started
room_buffer
.
writeInt8
((
if
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
].
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
)
buffer_pos
+=
4
buffer_pos
+=
4
else
else
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
...
@@ -2799,7 +2800,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
...
@@ -2799,7 +2800,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
deck_arena
=
deck_arena
+
'custom'
deck_arena
=
deck_arena
+
'custom'
#log.info "DECK LOG START", client.name, room.arena
#log.info "DECK LOG START", client.name, room.arena
if
settings
.
modules
.
deck_log
.
local
if
settings
.
modules
.
deck_log
.
local
deck_name
=
moment
().
format
(
'YYYY-MM-DD HH-mm-ss'
)
+
' '
+
room
.
p
ort
+
' '
+
client
.
pos
+
' '
+
client
.
ip
.
slice
(
7
)
+
' '
+
client
.
name
.
replace
(
/[\/\\\?\*]/g
,
'_'
)
deck_name
=
moment
().
format
(
'YYYY-MM-DD HH-mm-ss'
)
+
' '
+
room
.
p
rocess_pid
+
' '
+
client
.
pos
+
' '
+
client
.
ip
.
slice
(
7
)
+
' '
+
client
.
name
.
replace
(
/[\/\\\?\*]/g
,
'_'
)
fs
.
writeFile
settings
.
modules
.
deck_log
.
local
+
deck_name
+
'.ydk'
,
deck_text
,
'utf-8'
,
(
err
)
->
fs
.
writeFile
settings
.
modules
.
deck_log
.
local
+
deck_name
+
'.ydk'
,
deck_text
,
'utf-8'
,
(
err
)
->
if
err
if
err
log
.
warn
'DECK SAVE ERROR'
,
err
log
.
warn
'DECK SAVE ERROR'
,
err
...
@@ -2902,7 +2903,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
...
@@ -2902,7 +2903,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
ygopro
.
stoc_send_random_tip
(
client
)
if
settings
.
modules
.
tips
.
enabled
ygopro
.
stoc_send_random_tip
(
client
)
if
settings
.
modules
.
tips
.
enabled
when
'/ai'
when
'/ai'
if
settings
.
modules
.
windbot
.
enabled
and
client
.
is_host
and
!
settings
.
modules
.
challonge
.
enabled
if
settings
.
modules
.
windbot
.
enabled
and
client
.
is_host
and
!
settings
.
modules
.
challonge
.
enabled
and
!
room
.
arena
and
room
.
random_type
!=
'M'
if
name
=
cmd
[
1
]
if
name
=
cmd
[
1
]
windbot
=
_
.
sample
_
.
filter
windbots
,
(
w
)
->
windbot
=
_
.
sample
_
.
filter
windbots
,
(
w
)
->
w
.
name
==
name
or
w
.
deck
==
name
w
.
name
==
name
or
w
.
deck
==
name
...
@@ -3279,7 +3280,7 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server)->
...
@@ -3279,7 +3280,7 @@ ygopro.ctos_follow 'TP_RESULT', false, (buffer, info, client, server)->
room
=
ROOM_all
[
client
.
rid
]
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
return
unless
room
client
.
selected_preduel
=
true
client
.
selected_preduel
=
true
room
.
selecting_tp
=
false
#
room.selecting_tp = false
return
unless
room
.
random_type
or
room
.
arena
return
unless
room
.
random_type
or
room
.
arena
room
.
last_active_time
=
moment
()
room
.
last_active_time
=
moment
()
return
return
...
@@ -3401,7 +3402,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
...
@@ -3401,7 +3402,7 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
duellog
=
{
duellog
=
{
time
:
dueltime
,
time
:
dueltime
,
name
:
room
.
name
+
(
if
settings
.
modules
.
tournament_mode
.
show_info
then
(
" (Duel:"
+
room
.
duel_count
+
")"
)
else
""
),
name
:
room
.
name
+
(
if
settings
.
modules
.
tournament_mode
.
show_info
then
(
" (Duel:"
+
room
.
duel_count
+
")"
)
else
""
),
roomid
:
room
.
p
ort
.
toString
(),
roomid
:
room
.
p
rocess_pid
.
toString
(),
cloud_replay_id
:
"R#"
+
room
.
cloud_replay_id
,
cloud_replay_id
:
"R#"
+
room
.
cloud_replay_id
,
replay_filename
:
replay_filename
,
replay_filename
:
replay_filename
,
roommode
:
room
.
hostinfo
.
mode
,
roommode
:
room
.
hostinfo
.
mode
,
...
@@ -3520,16 +3521,21 @@ if settings.modules.http
...
@@ -3520,16 +3521,21 @@ if settings.modules.http
else
else
response
.
writeHead
(
200
)
response
.
writeHead
(
200
)
roomsjson
=
JSON
.
stringify
rooms
:
(
for
room
in
ROOM_all
when
room
and
room
.
established
roomsjson
=
JSON
.
stringify
rooms
:
(
for
room
in
ROOM_all
when
room
and
room
.
established
pid
:
room
.
process
.
pid
.
toString
(),
roomid
:
room
.
process_pid
.
toString
(),
roomid
:
room
.
port
.
toString
(),
roomname
:
if
pass_validated
then
room
.
name
else
room
.
name
.
split
(
'$'
,
2
)[
0
],
roomname
:
if
pass_validated
then
room
.
name
else
room
.
name
.
split
(
'$'
,
2
)[
0
],
roommode
:
room
.
hostinfo
.
mode
,
roommode
:
room
.
hostinfo
.
mode
,
needpass
:
(
room
.
name
.
indexOf
(
'$'
)
!=
-
1
).
toString
(),
needpass
:
(
room
.
name
.
indexOf
(
'$'
)
!=
-
1
).
toString
(),
users
:
(
for
player
in
room
.
players
when
player
.
pos
?
users
:
_
.
sortBy
(
(
for
player
in
room
.
players
when
player
.
pos
?
id
:
(
-
1
).
toString
(),
id
:
(
-
1
).
toString
(),
name
:
player
.
name
+
(
if
settings
.
modules
.
http
.
show_ip
and
pass_validated
and
!
player
.
is_local
then
(
" (IP: "
+
player
.
ip
.
slice
(
7
)
+
")"
)
else
""
)
+
(
if
settings
.
modules
.
http
.
show_info
and
room
.
started
and
player
.
pos
!=
7
and
not
(
room
.
hostinfo
.
mode
==
2
and
player
.
pos
%
2
>
0
)
then
(
" (Score:"
+
room
.
scores
[
player
.
name_vpass
]
+
" LP:"
+
(
if
player
.
lp
?
then
player
.
lp
else
room
.
hostinfo
.
start_lp
)
+
(
if
room
.
hostinfo
.
mode
!=
2
then
(
" Cards:"
+
(
if
player
.
card_count
?
then
player
.
card_count
else
room
.
hostinfo
.
start_hand
))
else
""
)
+
")"
)
else
""
),
name
:
player
.
name
,
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
(
score
:
room
.
scores
[
player
.
name_vpass
],
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
)
else
null
,
pos
:
player
.
pos
pos
:
player
.
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
.
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'
),
null
,
2
),
null
,
2
response
.
end
(
addCallback
(
u
.
query
.
callback
,
roomsjson
))
response
.
end
(
addCallback
(
u
.
query
.
callback
,
roomsjson
))
...
@@ -3691,7 +3697,7 @@ if settings.modules.http
...
@@ -3691,7 +3697,7 @@ if settings.modules.http
else
if
u
.
query
.
kick
else
if
u
.
query
.
kick
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
.
p
ort
.
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
.
p
rocess_pid
.
toString
()
or
u
.
query
.
kick
==
room
.
name
)
kick_room_found
=
true
kick_room_found
=
true
if
room
.
started
if
room
.
started
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
=
0
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
=
0
...
@@ -3707,7 +3713,7 @@ if settings.modules.http
...
@@ -3707,7 +3713,7 @@ if settings.modules.http
else
if
u
.
query
.
death
else
if
u
.
query
.
death
death_room_found
=
false
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
.
p
ort
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
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
.
p
rocess_pid
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
death_room_found
=
true
death_room_found
=
true
oppo_pos
=
if
room
.
hostinfo
.
mode
==
2
then
2
else
1
oppo_pos
=
if
room
.
hostinfo
.
mode
==
2
then
2
else
1
if
!
room
.
changing_side
and
(
!
room
.
duel_count
or
room
.
turn
)
if
!
room
.
changing_side
and
(
!
room
.
duel_count
or
room
.
turn
)
...
@@ -3751,7 +3757,7 @@ if settings.modules.http
...
@@ -3751,7 +3757,7 @@ if settings.modules.http
else
if
u
.
query
.
deathcancel
else
if
u
.
query
.
deathcancel
death_room_found
=
false
death_room_found
=
false
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
room
.
death
and
(
u
.
query
.
deathcancel
==
"all"
or
u
.
query
.
deathcancel
==
room
.
p
ort
.
toString
())
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
room
.
death
and
(
u
.
query
.
deathcancel
==
"all"
or
u
.
query
.
deathcancel
==
room
.
p
rocess_pid
.
toString
())
death_room_found
=
true
death_room_found
=
true
room
.
death
=
0
room
.
death
=
0
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_cancel}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_cancel}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
ygopro-server.js
View file @
e840e9aa
...
@@ -470,40 +470,40 @@
...
@@ -470,40 +470,40 @@
challonge_cache
=
[];
challonge_cache
=
[];
}
}
challonge_queue_callbacks
=
[[],
[]];
challonge_queue_callbacks
=
[[],
[]];
is_requesting
=
[
false
,
false
];
is_requesting
=
[
null
,
null
];
get_callback
=
function
(
challonge_type
,
_callback
)
{
get_callback
=
function
(
challonge_type
,
_callback
)
{
return
(
function
(
err
,
data
)
{
return
(
function
(
err
,
data
)
{
var
cur_callback
;
var
cur_callback
;
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
!
err
&&
data
)
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
!
err
&&
data
)
{
challonge_cache
[
challonge_type
]
=
data
;
challonge_cache
[
challonge_type
]
=
data
;
}
}
is_requesting
[
challonge_type
]
=
null
;
_callback
(
err
,
data
);
_callback
(
err
,
data
);
while
(
challonge_queue_callbacks
[
challonge_type
].
length
)
{
while
(
challonge_queue_callbacks
[
challonge_type
].
length
)
{
cur_callback
=
challonge_queue_callbacks
[
challonge_type
].
splice
(
0
,
1
)[
0
];
cur_callback
=
challonge_queue_callbacks
[
challonge_type
].
splice
(
0
,
1
)[
0
];
cur_callback
(
err
,
data
);
cur_callback
(
err
,
data
);
}
}
is_requesting
[
challonge_type
]
=
false
;
});
});
};
};
challonge
.
participants
.
_index
=
function
(
_data
)
{
challonge
.
participants
.
_index
=
function
(
_data
)
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
0
])
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
0
])
{
_data
.
callback
(
null
,
challonge_cache
[
0
]);
_data
.
callback
(
null
,
challonge_cache
[
0
]);
}
else
if
(
is_requesting
[
0
])
{
}
else
if
(
is_requesting
[
0
]
&&
moment
()
-
is_requesting
[
0
]
<=
5000
)
{
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
);
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
);
}
else
{
}
else
{
_data
.
callback
=
get_callback
(
0
,
_data
.
callback
);
_data
.
callback
=
get_callback
(
0
,
_data
.
callback
);
is_requesting
[
0
]
=
true
;
is_requesting
[
0
]
=
moment
()
;
challonge
.
participants
.
index
(
_data
);
challonge
.
participants
.
index
(
_data
);
}
}
};
};
challonge
.
matches
.
_index
=
function
(
_data
)
{
challonge
.
matches
.
_index
=
function
(
_data
)
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
1
])
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
1
])
{
_data
.
callback
(
null
,
challonge_cache
[
1
]);
_data
.
callback
(
null
,
challonge_cache
[
1
]);
}
else
if
(
is_requesting
[
1
])
{
}
else
if
(
is_requesting
[
1
]
&&
moment
()
-
is_requesting
[
1
]
<=
5000
)
{
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
);
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
);
}
else
{
}
else
{
_data
.
callback
=
get_callback
(
1
,
_data
.
callback
);
_data
.
callback
=
get_callback
(
1
,
_data
.
callback
);
is_requesting
[
1
]
=
true
;
is_requesting
[
1
]
=
moment
()
;
challonge
.
matches
.
index
(
_data
);
challonge
.
matches
.
index
(
_data
);
}
}
};
};
...
@@ -1121,7 +1121,7 @@
...
@@ -1121,7 +1121,7 @@
client
.
reconnecting
=
false
;
client
.
reconnecting
=
false
;
}
else
if
(
room
.
selecting_tp
)
{
}
else
if
(
room
.
selecting_tp
)
{
ygopro
.
stoc_send
(
client
,
'
DUEL_START
'
);
ygopro
.
stoc_send
(
client
,
'
DUEL_START
'
);
if
(
client
===
room
.
selecting_tp
&&
!
client
.
selected_preduel
)
{
if
(
client
===
room
.
selecting_tp
)
{
ygopro
.
stoc_send
(
client
,
'
SELECT_TP
'
);
ygopro
.
stoc_send
(
client
,
'
SELECT_TP
'
);
}
}
client
.
reconnecting
=
false
;
client
.
reconnecting
=
false
;
...
@@ -1419,6 +1419,7 @@
...
@@ -1419,6 +1419,7 @@
this
.
process
=
spawn
(
'
./ygopro
'
,
param
,
{
this
.
process
=
spawn
(
'
./ygopro
'
,
param
,
{
cwd
:
'
ygopro
'
cwd
:
'
ygopro
'
});
});
this
.
process_pid
=
this
.
process
.
pid
;
this
.
process
.
on
(
'
error
'
,
(
function
(
_this
)
{
this
.
process
.
on
(
'
error
'
,
(
function
(
_this
)
{
return
function
(
err
)
{
return
function
(
err
)
{
_
.
each
(
_this
.
players
,
function
(
player
)
{
_
.
each
(
_this
.
players
,
function
(
player
)
{
...
@@ -2235,9 +2236,9 @@
...
@@ -2235,9 +2236,9 @@
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
.
started
)
{
room_buffer
.
writeInt8
((
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
]
.
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
);
buffer_pos
+=
4
;
buffer_pos
+=
4
;
}
else
{
}
else
{
room_buffer
.
writeInt8
(
0
,
buffer_pos
);
room_buffer
.
writeInt8
(
0
,
buffer_pos
);
...
@@ -2255,9 +2256,9 @@
...
@@ -2255,9 +2256,9 @@
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
.
started
)
{
room_buffer
.
writeInt8
((
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
]
.
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
);
buffer_pos
+=
4
;
buffer_pos
+=
4
;
}
else
{
}
else
{
room_buffer
.
writeInt8
(
0
,
buffer_pos
);
room_buffer
.
writeInt8
(
0
,
buffer_pos
);
...
@@ -3551,7 +3552,7 @@
...
@@ -3551,7 +3552,7 @@
deck_arena
=
deck_arena
+
'
custom
'
;
deck_arena
=
deck_arena
+
'
custom
'
;
}
}
if
(
settings
.
modules
.
deck_log
.
local
)
{
if
(
settings
.
modules
.
deck_log
.
local
)
{
deck_name
=
moment
().
format
(
'
YYYY-MM-DD HH-mm-ss
'
)
+
'
'
+
room
.
p
ort
+
'
'
+
client
.
pos
+
'
'
+
client
.
ip
.
slice
(
7
)
+
'
'
+
client
.
name
.
replace
(
/
[\/\\\?\*]
/g
,
'
_
'
);
deck_name
=
moment
().
format
(
'
YYYY-MM-DD HH-mm-ss
'
)
+
'
'
+
room
.
p
rocess_pid
+
'
'
+
client
.
pos
+
'
'
+
client
.
ip
.
slice
(
7
)
+
'
'
+
client
.
name
.
replace
(
/
[\/\\\?\*]
/g
,
'
_
'
);
fs
.
writeFile
(
settings
.
modules
.
deck_log
.
local
+
deck_name
+
'
.ydk
'
,
deck_text
,
'
utf-8
'
,
function
(
err
)
{
fs
.
writeFile
(
settings
.
modules
.
deck_log
.
local
+
deck_name
+
'
.ydk
'
,
deck_text
,
'
utf-8
'
,
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
return
log
.
warn
(
'
DECK SAVE ERROR
'
,
err
);
return
log
.
warn
(
'
DECK SAVE ERROR
'
,
err
);
...
@@ -3700,7 +3701,7 @@
...
@@ -3700,7 +3701,7 @@
}
}
break
;
break
;
case
'
/ai
'
:
case
'
/ai
'
:
if
(
settings
.
modules
.
windbot
.
enabled
&&
client
.
is_host
&&
!
settings
.
modules
.
challonge
.
enabled
)
{
if
(
settings
.
modules
.
windbot
.
enabled
&&
client
.
is_host
&&
!
settings
.
modules
.
challonge
.
enabled
&&
!
room
.
arena
&&
room
.
random_type
!==
'
M
'
)
{
if
(
name
=
cmd
[
1
])
{
if
(
name
=
cmd
[
1
])
{
windbot
=
_
.
sample
(
_
.
filter
(
windbots
,
function
(
w
)
{
windbot
=
_
.
sample
(
_
.
filter
(
windbots
,
function
(
w
)
{
return
w
.
name
===
name
||
w
.
deck
===
name
;
return
w
.
name
===
name
||
w
.
deck
===
name
;
...
@@ -4200,7 +4201,6 @@
...
@@ -4200,7 +4201,6 @@
return
;
return
;
}
}
client
.
selected_preduel
=
true
;
client
.
selected_preduel
=
true
;
room
.
selecting_tp
=
false
;
if
(
!
(
room
.
random_type
||
room
.
arena
))
{
if
(
!
(
room
.
random_type
||
room
.
arena
))
{
return
;
return
;
}
}
...
@@ -4368,7 +4368,7 @@
...
@@ -4368,7 +4368,7 @@
duellog
=
{
duellog
=
{
time
:
dueltime
,
time
:
dueltime
,
name
:
room
.
name
+
(
settings
.
modules
.
tournament_mode
.
show_info
?
"
(Duel:
"
+
room
.
duel_count
+
"
)
"
:
""
),
name
:
room
.
name
+
(
settings
.
modules
.
tournament_mode
.
show_info
?
"
(Duel:
"
+
room
.
duel_count
+
"
)
"
:
""
),
roomid
:
room
.
p
ort
.
toString
(),
roomid
:
room
.
p
rocess_pid
.
toString
(),
cloud_replay_id
:
"
R#
"
+
room
.
cloud_replay_id
,
cloud_replay_id
:
"
R#
"
+
room
.
cloud_replay_id
,
replay_filename
:
replay_filename
,
replay_filename
:
replay_filename
,
roommode
:
room
.
hostinfo
.
mode
,
roommode
:
room
.
hostinfo
.
mode
,
...
@@ -4535,12 +4535,11 @@
...
@@ -4535,12 +4535,11 @@
room
=
ROOM_all
[
m
];
room
=
ROOM_all
[
m
];
if
(
room
&&
room
.
established
)
{
if
(
room
&&
room
.
established
)
{
results
.
push
({
results
.
push
({
pid
:
room
.
process
.
pid
.
toString
(),
roomid
:
room
.
process_pid
.
toString
(),
roomid
:
room
.
port
.
toString
(),
roomname
:
pass_validated
?
room
.
name
:
room
.
name
.
split
(
'
$
'
,
2
)[
0
],
roomname
:
pass_validated
?
room
.
name
:
room
.
name
.
split
(
'
$
'
,
2
)[
0
],
roommode
:
room
.
hostinfo
.
mode
,
roommode
:
room
.
hostinfo
.
mode
,
needpass
:
(
room
.
name
.
indexOf
(
'
$
'
)
!==
-
1
).
toString
(),
needpass
:
(
room
.
name
.
indexOf
(
'
$
'
)
!==
-
1
).
toString
(),
users
:
(
function
()
{
users
:
_
.
sortBy
(
(
function
()
{
var
len3
,
n
,
ref3
,
results1
;
var
len3
,
n
,
ref3
,
results1
;
ref3
=
room
.
players
;
ref3
=
room
.
players
;
results1
=
[];
results1
=
[];
...
@@ -4549,13 +4548,19 @@
...
@@ -4549,13 +4548,19 @@
if
(
player
.
pos
!=
null
)
{
if
(
player
.
pos
!=
null
)
{
results1
.
push
({
results1
.
push
({
id
:
(
-
1
).
toString
(),
id
:
(
-
1
).
toString
(),
name
:
player
.
name
+
(
settings
.
modules
.
http
.
show_ip
&&
pass_validated
&&
!
player
.
is_local
?
"
(IP:
"
+
player
.
ip
.
slice
(
7
)
+
"
)
"
:
""
)
+
(
settings
.
modules
.
http
.
show_info
&&
room
.
started
&&
player
.
pos
!==
7
&&
!
(
room
.
hostinfo
.
mode
===
2
&&
player
.
pos
%
2
>
0
)
?
"
(Score:
"
+
room
.
scores
[
player
.
name_vpass
]
+
"
LP:
"
+
(
player
.
lp
!=
null
?
player
.
lp
:
room
.
hostinfo
.
start_lp
)
+
(
room
.
hostinfo
.
mode
!==
2
?
"
Cards:
"
+
(
player
.
card_count
!=
null
?
player
.
card_count
:
room
.
hostinfo
.
start_hand
)
:
""
)
+
"
)
"
:
""
),
name
:
player
.
name
,
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
?
{
score
:
room
.
scores
[
player
.
name_vpass
],
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
}
:
null
,
pos
:
player
.
pos
pos
:
player
.
pos
});
});
}
}
}
}
return
results1
;
return
results1
;
})(),
})(),
"
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
.
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
'
});
});
}
}
...
@@ -4752,7 +4757,7 @@
...
@@ -4752,7 +4757,7 @@
kick_room_found
=
false
;
kick_room_found
=
false
;
for
(
p
=
0
,
len5
=
ROOM_all
.
length
;
p
<
len5
;
p
++
)
{
for
(
p
=
0
,
len5
=
ROOM_all
.
length
;
p
<
len5
;
p
++
)
{
room
=
ROOM_all
[
p
];
room
=
ROOM_all
[
p
];
if
(
!
(
room
&&
room
.
established
&&
(
u
.
query
.
kick
===
"
all
"
||
u
.
query
.
kick
===
room
.
p
ort
.
toString
()
||
u
.
query
.
kick
===
room
.
name
)))
{
if
(
!
(
room
&&
room
.
established
&&
(
u
.
query
.
kick
===
"
all
"
||
u
.
query
.
kick
===
room
.
p
rocess_pid
.
toString
()
||
u
.
query
.
kick
===
room
.
name
)))
{
continue
;
continue
;
}
}
kick_room_found
=
true
;
kick_room_found
=
true
;
...
@@ -4774,7 +4779,7 @@
...
@@ -4774,7 +4779,7 @@
death_room_found
=
false
;
death_room_found
=
false
;
for
(
q
=
0
,
len6
=
ROOM_all
.
length
;
q
<
len6
;
q
++
)
{
for
(
q
=
0
,
len6
=
ROOM_all
.
length
;
q
<
len6
;
q
++
)
{
room
=
ROOM_all
[
q
];
room
=
ROOM_all
[
q
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
!
room
.
death
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
p
ort
.
toString
()
||
u
.
query
.
death
===
room
.
name
)))
{
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
!
room
.
death
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
p
rocess_pid
.
toString
()
||
u
.
query
.
death
===
room
.
name
)))
{
continue
;
continue
;
}
}
death_room_found
=
true
;
death_room_found
=
true
;
...
@@ -4836,7 +4841,7 @@
...
@@ -4836,7 +4841,7 @@
death_room_found
=
false
;
death_room_found
=
false
;
for
(
r
=
0
,
len7
=
ROOM_all
.
length
;
r
<
len7
;
r
++
)
{
for
(
r
=
0
,
len7
=
ROOM_all
.
length
;
r
<
len7
;
r
++
)
{
room
=
ROOM_all
[
r
];
room
=
ROOM_all
[
r
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
room
.
death
&&
(
u
.
query
.
deathcancel
===
"
all
"
||
u
.
query
.
deathcancel
===
room
.
p
ort
.
toString
())))
{
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
room
.
death
&&
(
u
.
query
.
deathcancel
===
"
all
"
||
u
.
query
.
deathcancel
===
room
.
p
rocess_pid
.
toString
())))
{
continue
;
continue
;
}
}
death_room_found
=
true
;
death_room_found
=
true
;
...
...
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