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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
MyCard
srvpro
Commits
ae8ee1a4
Commit
ae8ee1a4
authored
May 25, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean code
parent
a0863d1f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
344 deletions
+88
-344
ygopro-server.coffee
ygopro-server.coffee
+28
-167
ygopro-server.js
ygopro-server.js
+25
-164
ygopro.coffee
ygopro.coffee
+22
-13
ygopro.js
ygopro.js
+13
-0
No files found.
ygopro-server.coffee
View file @
ae8ee1a4
...
@@ -138,12 +138,7 @@ net.createServer (client) ->
...
@@ -138,12 +138,7 @@ net.createServer (client) ->
if
settings
.
modules
.
enable_cloud_replay
if
settings
.
modules
.
enable_cloud_replay
client
.
open_cloud_replay
=
(
err
,
replay
)
->
client
.
open_cloud_replay
=
(
err
,
replay
)
->
if
err
or
!
replay
if
err
or
!
replay
ygopro
.
stoc_send_chat
(
client
,
"没有找到录像"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"没有找到录像"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,{
msg
:
1
code
:
2
}
client
.
end
()
return
return
redisdb
.
expire
(
"replay:"
+
replay
.
replay_id
,
60
*
60
*
48
)
redisdb
.
expire
(
"replay:"
+
replay
.
replay_id
,
60
*
60
*
48
)
buffer
=
new
Buffer
(
replay
.
replay_buffer
,
'binary'
)
buffer
=
new
Buffer
(
replay
.
replay_buffer
,
'binary'
)
...
@@ -291,13 +286,7 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server)->
...
@@ -291,13 +286,7 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server)->
ygopro
.
ctos_follow
'JOIN_GAME'
,
false
,
(
buffer
,
info
,
client
,
server
)
->
ygopro
.
ctos_follow
'JOIN_GAME'
,
false
,
(
buffer
,
info
,
client
,
server
)
->
#log.info info
#log.info info
if
settings
.
modules
.
stop
if
settings
.
modules
.
stop
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
stop
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
stop
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
info
.
pass
.
toUpperCase
()
==
"R"
and
settings
.
modules
.
enable_cloud_replay
else
if
info
.
pass
.
toUpperCase
()
==
"R"
and
settings
.
modules
.
enable_cloud_replay
ygopro
.
stoc_send_chat
(
client
,
"以下是您近期的云录像,密码处输入 R#录像编号 即可观看"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"以下是您近期的云录像,密码处输入 R#录像编号 即可观看"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
@@ -325,25 +314,14 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -325,25 +314,14 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
redisdb
.
lindex
client
.
remoteAddress
+
":replays"
,
replay_id
-
1
,
(
err
,
replay_id
)
->
redisdb
.
lindex
client
.
remoteAddress
+
":replays"
,
replay_id
-
1
,
(
err
,
replay_id
)
->
if
err
or
!
replay_id
if
err
or
!
replay_id
log
.
info
err
log
.
info
err
ygopro
.
stoc_send_chat
(
client
,
"没有找到录像"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"没有找到录像"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,{
msg
:
1
code
:
2
}
client
.
end
()
return
return
redisdb
.
hgetall
"replay:"
+
replay_id
,
client
.
open_cloud_replay
redisdb
.
hgetall
"replay:"
+
replay_id
,
client
.
open_cloud_replay
return
return
else
if
replay_id
else
if
replay_id
redisdb
.
hgetall
"replay:"
+
replay_id
,
client
.
open_cloud_replay
redisdb
.
hgetall
"replay:"
+
replay_id
,
client
.
open_cloud_replay
else
else
ygopro
.
stoc_send_chat
(
client
,
"没有找到录像"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"没有找到录像"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,{
msg
:
1
code
:
2
}
client
.
end
()
else
if
info
.
version
!=
settings
.
version
else
if
info
.
version
!=
settings
.
version
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
update
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
update
,
ygopro
.
constants
.
COLORS
.
RED
)
...
@@ -354,12 +332,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -354,12 +332,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client
.
end
()
client
.
end
()
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
enable_random_duel
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
enable_random_duel
ygopro
.
stoc_send_chat
(
client
,
"房间名为空,请填写主机密码"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"房间名为空,请填写主机密码"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
settings
.
modules
.
enable_windbot
and
info
.
pass
[
0
...
2
]
==
'AI'
else
if
settings
.
modules
.
enable_windbot
and
info
.
pass
[
0
...
2
]
==
'AI'
...
@@ -368,31 +341,16 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -368,31 +341,16 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
windbot
=
_
.
sample
_
.
filter
settings
.
modules
.
windbots
,
(
w
)
->
windbot
=
_
.
sample
_
.
filter
settings
.
modules
.
windbots
,
(
w
)
->
w
.
name
==
name
or
w
.
deck
==
name
w
.
name
==
name
or
w
.
deck
==
name
if
!
windbot
if
!
windbot
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Invalid Windbot Name)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Windbot Name)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
else
else
windbot
=
_
.
sample
settings
.
modules
.
windbots
windbot
=
_
.
sample
settings
.
modules
.
windbots
room
=
Room
.
find_or_create_by_name
(
'AI#'
+
Math
.
floor
(
Math
.
random
()
*
100000
))
# 这个 AI# 没有特殊作用, 仅作为标记
room
=
Room
.
find_or_create_by_name
(
'AI#'
+
Math
.
floor
(
Math
.
random
()
*
100000
))
# 这个 AI# 没有特殊作用, 仅作为标记
if
!
room
if
!
room
ygopro
.
stoc_send_chat
(
client
,
"服务器已经爆满,请稍候再试"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"服务器已经爆满,请稍候再试"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
room
.
error
else
if
room
.
error
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
room
.
error
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
else
room
.
windbot
=
windbot
room
.
windbot
=
windbot
room
.
private
=
true
room
.
private
=
true
...
@@ -400,25 +358,15 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -400,25 +358,15 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client
.
room
.
connect
(
client
)
client
.
room
.
connect
(
client
)
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard_auth
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard_auth
ygopro
.
stoc_send_chat
(
client
,
'正在读取用户信息...'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send_chat
(
client
,
'正在读取用户信息...'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
info
.
pass
.
length
<=
8
if
info
.
pass
.
length
<=
8
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Invalid Length)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Length)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
buffer
=
new
Buffer
(
info
.
pass
[
0
...
8
],
'base64'
)
buffer
=
new
Buffer
(
info
.
pass
[
0
...
8
],
'base64'
)
if
buffer
.
length
!=
6
if
buffer
.
length
!=
6
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Invalid Payload Length)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Payload Length)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
check
=
(
buf
)
->
check
=
(
buf
)
->
...
@@ -430,12 +378,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -430,12 +378,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
finish
=
(
buffer
)
->
finish
=
(
buffer
)
->
action
=
buffer
.
readUInt8
(
1
)
>>
4
action
=
buffer
.
readUInt8
(
1
)
>>
4
if
buffer
!=
decrypted_buffer
and
action
in
[
1
,
2
,
4
]
if
buffer
!=
decrypted_buffer
and
action
in
[
1
,
2
,
4
]
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Unauthorized)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Unauthorized)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
# 1 create public room
# 1 create public room
...
@@ -446,12 +389,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -446,12 +389,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
when
1
,
2
when
1
,
2
name
=
crypto
.
createHash
(
'md5'
).
update
(
info
.
pass
+
client
.
name
).
digest
(
'base64'
)[
0
...
10
].
replace
(
'+'
,
'-'
).
replace
(
'/'
,
'_'
)
name
=
crypto
.
createHash
(
'md5'
).
update
(
info
.
pass
+
client
.
name
).
digest
(
'base64'
)[
0
...
10
].
replace
(
'+'
,
'-'
).
replace
(
'/'
,
'_'
)
if
Room
.
find_by_name
(
name
)
if
Room
.
find_by_name
(
name
)
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Already Existed)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Already Existed)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
opt1
=
buffer
.
readUInt8
(
2
)
opt1
=
buffer
.
readUInt8
(
2
)
...
@@ -477,41 +415,23 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -477,41 +415,23 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
name
=
info
.
pass
.
slice
(
8
)
name
=
info
.
pass
.
slice
(
8
)
room
=
Room
.
find_by_name
(
name
)
room
=
Room
.
find_by_name
(
name
)
if
(
!
room
)
if
(
!
room
)
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Not Found)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Not Found)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
when
4
when
4
room
=
Room
.
find_or_create_by_name
(
'M#'
+
info
.
pass
.
slice
(
8
))
room
=
Room
.
find_or_create_by_name
(
'M#'
+
info
.
pass
.
slice
(
8
))
room
.
private
=
true
room
.
private
=
true
else
else
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Invalid Action)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Action)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
if
!
room
if
!
room
ygopro
.
stoc_send_chat
(
client
,
"服务器已经爆满,请稍候再试"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"服务器已经爆满,请稍候再试"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
room
.
error
else
if
room
.
error
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
room
.
error
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
else
client
.
room
=
room
client
.
room
=
room
client
.
room
.
connect
(
client
)
client
.
room
.
connect
(
client
)
return
if
id
=
users_cache
[
client
.
name
]
if
id
=
users_cache
[
client
.
name
]
secret
=
id
%
65535
+
1
secret
=
id
%
65535
+
1
...
@@ -542,71 +462,30 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -542,71 +462,30 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
# buffer != decrypted_buffer ==> auth failed
# buffer != decrypted_buffer ==> auth failed
if
!
check
(
buffer
)
if
!
check
(
buffer
)
ygopro
.
stoc_send_chat
(
client
,
'主机密码不正确 (Checksum Failed)'
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Checksum Failed)'
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
return
return
users_cache
[
client
.
name
]
=
body
.
user
.
id
users_cache
[
client
.
name
]
=
body
.
user
.
id
finish
(
buffer
)
finish
(
buffer
)
else
if
info
.
pass
.
length
&&
!
Room
.
validate
(
info
.
pass
)
else
if
info
.
pass
.
length
&&
!
Room
.
validate
(
info
.
pass
)
#ygopro.stoc_send client, 'ERROR_MSG',{
ygopro
.
stoc_die
(
client
,
"房间密码不正确"
)
# msg: 1
# code: 1 #这返错有问题,直接双ygopro直连怎么都正常,在这里就经常弹不出提示
#}
ygopro
.
stoc_send_chat
(
client
,
"房间密码不正确"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
client
.
name
==
'[INCORRECT]'
#模拟用户验证
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
_
.
indexOf
(
settings
.
BANNED_user
,
client
.
name
)
>
-
1
#账号被封
else
if
_
.
indexOf
(
settings
.
BANNED_user
,
client
.
name
)
>
-
1
#账号被封
settings
.
BANNED_IP
.
push
(
client
.
remoteAddress
)
settings
.
BANNED_IP
.
push
(
client
.
remoteAddress
)
log
.
info
(
"BANNED USER LOGIN"
,
client
.
name
,
client
.
remoteAddress
)
log
.
info
(
"BANNED USER LOGIN"
,
client
.
name
,
client
.
remoteAddress
)
ygopro
.
stoc_send_chat
(
client
,
"您的账号已被封禁"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"您的账号已被封禁"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
_
.
indexOf
(
settings
.
BANNED_IP
,
client
.
remoteAddress
)
>
-
1
#IP被封
else
if
_
.
indexOf
(
settings
.
BANNED_IP
,
client
.
remoteAddress
)
>
-
1
#IP被封
log
.
info
(
"BANNED IP LOGIN"
,
client
.
name
,
client
.
remoteAddress
)
log
.
info
(
"BANNED IP LOGIN"
,
client
.
name
,
client
.
remoteAddress
)
ygopro
.
stoc_send_chat
(
client
,
"您的账号已被封禁"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"您的账号已被封禁"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
else
#log.info 'join_game',info.pass, client.name
#log.info 'join_game',info.pass, client.name
room
=
Room
.
find_or_create_by_name
(
info
.
pass
,
client
.
remoteAddress
)
room
=
Room
.
find_or_create_by_name
(
info
.
pass
,
client
.
remoteAddress
)
if
!
room
if
!
room
ygopro
.
stoc_send_chat
(
client
,
"服务器已经爆满,请稍候再试"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"服务器已经爆满,请稍候再试"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
room
.
error
else
if
room
.
error
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
room
.
error
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
if
room
.
started
else
if
room
.
started
if
settings
.
modules
.
enable_halfway_watch
if
settings
.
modules
.
enable_halfway_watch
client
.
room
=
room
client
.
room
=
room
...
@@ -617,12 +496,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -617,12 +496,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
for
buffer
in
client
.
room
.
watcher_buffers
for
buffer
in
client
.
room
.
watcher_buffers
client
.
write
buffer
client
.
write
buffer
else
else
ygopro
.
stoc_send_chat
(
client
,
"决斗已开始,不允许观战"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_die
(
client
,
"决斗已开始,不允许观战"
)
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
client
.
end
()
else
else
client
.
room
=
room
client
.
room
=
room
client
.
room
.
connect
(
client
)
client
.
room
.
connect
(
client
)
...
@@ -863,19 +737,6 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
...
@@ -863,19 +737,6 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
cancel
=
_
.
startsWith
(
_
.
trim
(
info
.
msg
),
"/"
)
cancel
=
_
.
startsWith
(
_
.
trim
(
info
.
msg
),
"/"
)
client
.
room
.
last_active_time
=
moment
()
unless
cancel
or
not
client
.
room
.
random_type
client
.
room
.
last_active_time
=
moment
()
unless
cancel
or
not
client
.
room
.
random_type
switch
_
.
trim
(
info
.
msg
)
switch
_
.
trim
(
info
.
msg
)
when
'/ping'
execFile
'ss'
,
[
'-it'
,
"dst
#{
client
.
remoteAddress
}
:
#{
client
.
remotePort
}
"
],
(
error
,
stdout
,
stderr
)
->
if
error
ygopro
.
stoc_send_chat_to_room
client
.
room
,
error
else
line
=
_
.
lines
(
stdout
)[
2
]
if
line
.
indexOf
(
'rtt'
)
!=
-
1
ygopro
.
stoc_send_chat_to_room
client
.
room
,
line
else
#log.warn 'ping', stdout
ygopro
.
stoc_send_chat_to_room
client
.
room
,
stdout
return
when
'/help'
when
'/help'
ygopro
.
stoc_send_chat
(
client
,
"YGOSrv233 指令帮助"
)
ygopro
.
stoc_send_chat
(
client
,
"YGOSrv233 指令帮助"
)
ygopro
.
stoc_send_chat
(
client
,
"/help 显示这个帮助信息"
)
ygopro
.
stoc_send_chat
(
client
,
"/help 显示这个帮助信息"
)
...
@@ -888,8 +749,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
...
@@ -888,8 +749,8 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
when
'/roomname'
when
'/roomname'
ygopro
.
stoc_send_chat
(
client
,
"您当前的房间名是 "
+
client
.
room
.
name
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
client
.
room
ygopro
.
stoc_send_chat
(
client
,
"您当前的房间名是 "
+
client
.
room
.
name
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
client
.
room
when
'/test'
#
when '/test'
ygopro
.
stoc_send_hint_card_to_room
(
client
.
room
,
2333365
)
#
ygopro.stoc_send_hint_card_to_room(client.room, 2333365)
return
cancel
return
cancel
...
...
ygopro-server.js
View file @
ae8ee1a4
...
@@ -187,12 +187,7 @@
...
@@ -187,12 +187,7 @@
client
.
open_cloud_replay
=
function
(
err
,
replay
)
{
client
.
open_cloud_replay
=
function
(
err
,
replay
)
{
var
buffer
;
var
buffer
;
if
(
err
||
!
replay
)
{
if
(
err
||
!
replay
)
{
ygopro
.
stoc_send_chat
(
client
,
"
没有找到录像
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
没有找到录像
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
redisdb
.
expire
(
"
replay:
"
+
replay
.
replay_id
,
60
*
60
*
48
);
redisdb
.
expire
(
"
replay:
"
+
replay
.
replay_id
,
60
*
60
*
48
);
...
@@ -347,12 +342,7 @@
...
@@ -347,12 +342,7 @@
ygopro
.
ctos_follow
(
'
JOIN_GAME
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
ygopro
.
ctos_follow
(
'
JOIN_GAME
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
var
check
,
decrypted_buffer
,
finish
,
i
,
id
,
k
,
l
,
len
,
len1
,
name
,
ref
,
ref1
,
replay_id
,
room
,
secret
,
windbot
;
var
check
,
decrypted_buffer
,
finish
,
i
,
id
,
k
,
l
,
len
,
len1
,
name
,
ref
,
ref1
,
replay_id
,
room
,
secret
,
windbot
;
if
(
settings
.
modules
.
stop
)
{
if
(
settings
.
modules
.
stop
)
{
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
stop
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
stop
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
R
"
&&
settings
.
modules
.
enable_cloud_replay
)
{
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
R
"
&&
settings
.
modules
.
enable_cloud_replay
)
{
ygopro
.
stoc_send_chat
(
client
,
"
以下是您近期的云录像,密码处输入 R#录像编号 即可观看
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
"
以下是您近期的云录像,密码处输入 R#录像编号 即可观看
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
redisdb
.
lrange
(
client
.
remoteAddress
+
"
:replays
"
,
0
,
2
,
function
(
err
,
result
)
{
redisdb
.
lrange
(
client
.
remoteAddress
+
"
:replays
"
,
0
,
2
,
function
(
err
,
result
)
{
...
@@ -379,12 +369,7 @@
...
@@ -379,12 +369,7 @@
redisdb
.
lindex
(
client
.
remoteAddress
+
"
:replays
"
,
replay_id
-
1
,
function
(
err
,
replay_id
)
{
redisdb
.
lindex
(
client
.
remoteAddress
+
"
:replays
"
,
replay_id
-
1
,
function
(
err
,
replay_id
)
{
if
(
err
||
!
replay_id
)
{
if
(
err
||
!
replay_id
)
{
log
.
info
(
err
);
log
.
info
(
err
);
ygopro
.
stoc_send_chat
(
client
,
"
没有找到录像
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
没有找到录像
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
redisdb
.
hgetall
(
"
replay:
"
+
replay_id
,
client
.
open_cloud_replay
);
redisdb
.
hgetall
(
"
replay:
"
+
replay_id
,
client
.
open_cloud_replay
);
...
@@ -392,12 +377,7 @@
...
@@ -392,12 +377,7 @@
}
else
if
(
replay_id
)
{
}
else
if
(
replay_id
)
{
redisdb
.
hgetall
(
"
replay:
"
+
replay_id
,
client
.
open_cloud_replay
);
redisdb
.
hgetall
(
"
replay:
"
+
replay_id
,
client
.
open_cloud_replay
);
}
else
{
}
else
{
ygopro
.
stoc_send_chat
(
client
,
"
没有找到录像
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
没有找到录像
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
}
}
else
if
(
info
.
version
!==
settings
.
version
)
{
}
else
if
(
info
.
version
!==
settings
.
version
)
{
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
update
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
update
,
ygopro
.
constants
.
COLORS
.
RED
);
...
@@ -407,12 +387,7 @@
...
@@ -407,12 +387,7 @@
});
});
client
.
end
();
client
.
end
();
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
enable_random_duel
)
{
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
enable_random_duel
)
{
ygopro
.
stoc_send_chat
(
client
,
"
房间名为空,请填写主机密码
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
房间名为空,请填写主机密码
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
settings
.
modules
.
enable_windbot
&&
info
.
pass
.
slice
(
0
,
2
)
===
'
AI
'
)
{
}
else
if
(
settings
.
modules
.
enable_windbot
&&
info
.
pass
.
slice
(
0
,
2
)
===
'
AI
'
)
{
if
(
info
.
pass
.
length
>
3
&&
info
.
pass
.
slice
(
0
,
3
)
===
'
AI#
'
||
info
.
pass
.
slice
(
0
,
3
)
===
'
AI_
'
)
{
if
(
info
.
pass
.
length
>
3
&&
info
.
pass
.
slice
(
0
,
3
)
===
'
AI#
'
||
info
.
pass
.
slice
(
0
,
3
)
===
'
AI_
'
)
{
name
=
info
.
pass
.
slice
(
3
);
name
=
info
.
pass
.
slice
(
3
);
...
@@ -420,12 +395,7 @@
...
@@ -420,12 +395,7 @@
return
w
.
name
===
name
||
w
.
deck
===
name
;
return
w
.
name
===
name
||
w
.
deck
===
name
;
}));
}));
if
(
!
windbot
)
{
if
(
!
windbot
)
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Invalid Windbot Name)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Windbot Name)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
}
else
{
}
else
{
...
@@ -433,19 +403,9 @@
...
@@ -433,19 +403,9 @@
}
}
room
=
Room
.
find_or_create_by_name
(
'
AI#
'
+
Math
.
floor
(
Math
.
random
()
*
100000
));
room
=
Room
.
find_or_create_by_name
(
'
AI#
'
+
Math
.
floor
(
Math
.
random
()
*
100000
));
if
(
!
room
)
{
if
(
!
room
)
{
ygopro
.
stoc_send_chat
(
client
,
"
服务器已经爆满,请稍候再试
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
服务器已经爆满,请稍候再试
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
room
.
error
)
{
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
room
.
error
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
{
}
else
{
room
.
windbot
=
windbot
;
room
.
windbot
=
windbot
;
room
[
"
private
"
]
=
true
;
room
[
"
private
"
]
=
true
;
...
@@ -453,24 +413,14 @@
...
@@ -453,24 +413,14 @@
client
.
room
.
connect
(
client
);
client
.
room
.
connect
(
client
);
}
}
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard_auth
)
{
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard_auth
)
{
ygopro
.
stoc_send_chat
(
client
,
'
正在读取用户信息...
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_send_chat
(
client
,
'
正在读取用户信息...
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
if
(
info
.
pass
.
length
<=
8
)
{
if
(
info
.
pass
.
length
<=
8
)
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Invalid Length)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Length)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
buffer
=
new
Buffer
(
info
.
pass
.
slice
(
0
,
8
),
'
base64
'
);
buffer
=
new
Buffer
(
info
.
pass
.
slice
(
0
,
8
),
'
base64
'
);
if
(
buffer
.
length
!==
6
)
{
if
(
buffer
.
length
!==
6
)
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Invalid Payload Length)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Payload Length)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
check
=
function
(
buf
)
{
check
=
function
(
buf
)
{
...
@@ -485,12 +435,7 @@
...
@@ -485,12 +435,7 @@
var
action
,
opt1
,
opt2
,
opt3
,
options
;
var
action
,
opt1
,
opt2
,
opt3
,
options
;
action
=
buffer
.
readUInt8
(
1
)
>>
4
;
action
=
buffer
.
readUInt8
(
1
)
>>
4
;
if
(
buffer
!==
decrypted_buffer
&&
(
action
===
1
||
action
===
2
||
action
===
4
))
{
if
(
buffer
!==
decrypted_buffer
&&
(
action
===
1
||
action
===
2
||
action
===
4
))
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Unauthorized)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Unauthorized)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
switch
(
action
)
{
switch
(
action
)
{
...
@@ -498,12 +443,7 @@
...
@@ -498,12 +443,7 @@
case
2
:
case
2
:
name
=
crypto
.
createHash
(
'
md5
'
).
update
(
info
.
pass
+
client
.
name
).
digest
(
'
base64
'
).
slice
(
0
,
10
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
);
name
=
crypto
.
createHash
(
'
md5
'
).
update
(
info
.
pass
+
client
.
name
).
digest
(
'
base64
'
).
slice
(
0
,
10
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
);
if
(
Room
.
find_by_name
(
name
))
{
if
(
Room
.
find_by_name
(
name
))
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Already Existed)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Already Existed)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
opt1
=
buffer
.
readUInt8
(
2
);
opt1
=
buffer
.
readUInt8
(
2
);
...
@@ -532,12 +472,7 @@
...
@@ -532,12 +472,7 @@
name
=
info
.
pass
.
slice
(
8
);
name
=
info
.
pass
.
slice
(
8
);
room
=
Room
.
find_by_name
(
name
);
room
=
Room
.
find_by_name
(
name
);
if
(
!
room
)
{
if
(
!
room
)
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Not Found)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Not Found)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
break
;
break
;
...
@@ -546,31 +481,16 @@
...
@@ -546,31 +481,16 @@
room
[
"
private
"
]
=
true
;
room
[
"
private
"
]
=
true
;
break
;
break
;
default
:
default
:
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Invalid Action)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Action)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
if
(
!
room
)
{
if
(
!
room
)
{
ygopro
.
stoc_send_chat
(
client
,
"
服务器已经爆满,请稍候再试
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
服务器已经爆满,请稍候再试
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
return
client
.
end
();
}
else
if
(
room
.
error
)
{
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
room
.
error
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
return
client
.
end
();
}
else
{
}
else
{
client
.
room
=
room
;
client
.
room
=
room
;
return
client
.
room
.
connect
(
client
);
client
.
room
.
connect
(
client
);
}
}
};
};
if
(
id
=
users_cache
[
client
.
name
])
{
if
(
id
=
users_cache
[
client
.
name
])
{
...
@@ -609,63 +529,27 @@
...
@@ -609,63 +529,27 @@
}
}
}
}
if
(
!
check
(
buffer
))
{
if
(
!
check
(
buffer
))
{
ygopro
.
stoc_send_chat
(
client
,
'
主机密码不正确 (Checksum Failed)
'
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Checksum Failed)
'
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
return
;
return
;
}
}
users_cache
[
client
.
name
]
=
body
.
user
.
id
;
users_cache
[
client
.
name
]
=
body
.
user
.
id
;
return
finish
(
buffer
);
return
finish
(
buffer
);
});
});
}
else
if
(
info
.
pass
.
length
&&
!
Room
.
validate
(
info
.
pass
))
{
}
else
if
(
info
.
pass
.
length
&&
!
Room
.
validate
(
info
.
pass
))
{
ygopro
.
stoc_send_chat
(
client
,
"
房间密码不正确
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
房间密码不正确
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
client
.
name
===
'
[INCORRECT]
'
)
{
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
_
.
indexOf
(
settings
.
BANNED_user
,
client
.
name
)
>
-
1
)
{
}
else
if
(
_
.
indexOf
(
settings
.
BANNED_user
,
client
.
name
)
>
-
1
)
{
settings
.
BANNED_IP
.
push
(
client
.
remoteAddress
);
settings
.
BANNED_IP
.
push
(
client
.
remoteAddress
);
log
.
info
(
"
BANNED USER LOGIN
"
,
client
.
name
,
client
.
remoteAddress
);
log
.
info
(
"
BANNED USER LOGIN
"
,
client
.
name
,
client
.
remoteAddress
);
ygopro
.
stoc_send_chat
(
client
,
"
您的账号已被封禁
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
您的账号已被封禁
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
_
.
indexOf
(
settings
.
BANNED_IP
,
client
.
remoteAddress
)
>
-
1
)
{
}
else
if
(
_
.
indexOf
(
settings
.
BANNED_IP
,
client
.
remoteAddress
)
>
-
1
)
{
log
.
info
(
"
BANNED IP LOGIN
"
,
client
.
name
,
client
.
remoteAddress
);
log
.
info
(
"
BANNED IP LOGIN
"
,
client
.
name
,
client
.
remoteAddress
);
ygopro
.
stoc_send_chat
(
client
,
"
您的账号已被封禁
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
您的账号已被封禁
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
{
}
else
{
room
=
Room
.
find_or_create_by_name
(
info
.
pass
,
client
.
remoteAddress
);
room
=
Room
.
find_or_create_by_name
(
info
.
pass
,
client
.
remoteAddress
);
if
(
!
room
)
{
if
(
!
room
)
{
ygopro
.
stoc_send_chat
(
client
,
"
服务器已经爆满,请稍候再试
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
服务器已经爆满,请稍候再试
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
room
.
error
)
{
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_send_chat
(
client
,
room
.
error
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
room
.
error
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
else
if
(
room
.
started
)
{
}
else
if
(
room
.
started
)
{
if
(
settings
.
modules
.
enable_halfway_watch
)
{
if
(
settings
.
modules
.
enable_halfway_watch
)
{
client
.
room
=
room
;
client
.
room
=
room
;
...
@@ -679,12 +563,7 @@
...
@@ -679,12 +563,7 @@
client
.
write
(
buffer
);
client
.
write
(
buffer
);
}
}
}
else
{
}
else
{
ygopro
.
stoc_send_chat
(
client
,
"
决斗已开始,不允许观战
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_die
(
client
,
"
决斗已开始,不允许观战
"
);
ygopro
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
client
.
end
();
}
}
}
else
{
}
else
{
client
.
room
=
room
;
client
.
room
=
room
;
...
@@ -1019,21 +898,6 @@
...
@@ -1019,21 +898,6 @@
client
.
room
.
last_active_time
=
moment
();
client
.
room
.
last_active_time
=
moment
();
}
}
switch
(
_
.
trim
(
info
.
msg
))
{
switch
(
_
.
trim
(
info
.
msg
))
{
case
'
/ping
'
:
execFile
(
'
ss
'
,
[
'
-it
'
,
"
dst
"
+
client
.
remoteAddress
+
"
:
"
+
client
.
remotePort
],
function
(
error
,
stdout
,
stderr
)
{
var
line
;
if
(
error
)
{
ygopro
.
stoc_send_chat_to_room
(
client
.
room
,
error
);
}
else
{
line
=
_
.
lines
(
stdout
)[
2
];
if
(
line
.
indexOf
(
'
rtt
'
)
!==
-
1
)
{
ygopro
.
stoc_send_chat_to_room
(
client
.
room
,
line
);
}
else
{
ygopro
.
stoc_send_chat_to_room
(
client
.
room
,
stdout
);
}
}
});
break
;
case
'
/help
'
:
case
'
/help
'
:
ygopro
.
stoc_send_chat
(
client
,
"
YGOSrv233 指令帮助
"
);
ygopro
.
stoc_send_chat
(
client
,
"
YGOSrv233 指令帮助
"
);
ygopro
.
stoc_send_chat
(
client
,
"
/help 显示这个帮助信息
"
);
ygopro
.
stoc_send_chat
(
client
,
"
/help 显示这个帮助信息
"
);
...
@@ -1051,9 +915,6 @@
...
@@ -1051,9 +915,6 @@
if
(
client
.
room
)
{
if
(
client
.
room
)
{
ygopro
.
stoc_send_chat
(
client
,
"
您当前的房间名是
"
+
client
.
room
.
name
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
"
您当前的房间名是
"
+
client
.
room
.
name
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
break
;
case
'
/test
'
:
ygopro
.
stoc_send_hint_card_to_room
(
client
.
room
,
2333365
);
}
}
return
cancel
;
return
cancel
;
});
});
...
...
ygopro.coffee
View file @
ae8ee1a4
_
=
require
'underscore'
_
=
require
'underscore'
_
.
str
=
require
'underscore.string'
_
.
str
=
require
'underscore.string'
_
.
mixin
(
_
.
str
.
exports
())
;
_
.
mixin
(
_
.
str
.
exports
())
Struct
=
require
(
'struct'
).
Struct
Struct
=
require
(
'struct'
).
Struct
...
@@ -137,17 +137,26 @@ for name, declaration of structs_declaration
...
@@ -137,17 +137,26 @@ for name, declaration of structs_declaration
console
.
log
"err stoc_send_hint_card_to_room"
console
.
log
"err stoc_send_hint_card_to_room"
return
return
for
client
in
room
.
players
for
client
in
room
.
players
@
stoc_send
client
,
'GAME_MSG'
,{
@
stoc_send
client
,
'GAME_MSG'
,
{
curmsg
:
2
,
curmsg
:
2
,
type
:
10
,
type
:
10
,
player
:
0
,
player
:
0
,
data
:
card
data
:
card
}
if
client
}
if
client
for
client
in
room
.
watchers
for
client
in
room
.
watchers
@
stoc_send
client
,
'GAME_MSG'
,{
@
stoc_send
client
,
'GAME_MSG'
,
{
curmsg
:
2
,
curmsg
:
2
,
type
:
10
,
type
:
10
,
player
:
0
,
player
:
0
,
data
:
card
data
:
card
}
if
client
}
if
client
return
return
@
stoc_die
=
(
client
,
msg
)
->
@
stoc_send_chat
(
client
,
msg
,
@
constants
.
COLORS
.
RED
)
@
stoc_send
client
,
'ERROR_MSG'
,
{
msg
:
1
code
:
2
}
if
client
client
.
end
()
if
client
return
\ No newline at end of file
ygopro.js
View file @
ae8ee1a4
...
@@ -245,4 +245,17 @@
...
@@ -245,4 +245,17 @@
}
}
};
};
this
.
stoc_die
=
function
(
client
,
msg
)
{
this
.
stoc_send_chat
(
client
,
msg
,
this
.
constants
.
COLORS
.
RED
);
if
(
client
)
{
this
.
stoc_send
(
client
,
'
ERROR_MSG
'
,
{
msg
:
1
,
code
:
2
});
}
if
(
client
)
{
client
.
end
();
}
};
}).
call
(
this
);
}).
call
(
this
);
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