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
91c6c3ed
Commit
91c6c3ed
authored
Dec 21, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update config
parent
236cf33b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
172 additions
and
134 deletions
+172
-134
config.json
config.json
+51
-26
mycard.config.json
mycard.config.json
+16
-7
ygopro-server.coffee
ygopro-server.coffee
+54
-50
ygopro-server.js
ygopro-server.js
+51
-51
No files found.
config.json
View file @
91c6c3ed
{
"port"
:
7911
,
"version"
:
4924
,
"hostinfo"
:
{
"lflist"
:
0
,
"rule"
:
0
,
"mode"
:
0
,
"comment"
:
"rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG"
,
"enable_priority"
:
false
,
"no_check_deck"
:
false
,
"no_shuffle_deck"
:
false
,
"start_lp"
:
8000
,
"start_hand"
:
5
,
"draw_count"
:
1
,
"time_limit"
:
180
},
"modules"
:
{
"welcome"
:
"YGOPRO Server"
,
"welcome"
:
"
Mycard
YGOPRO Server"
,
"update"
:
"请更新游戏版本"
,
"stop"
:
false
,
"tips"
:
"http://mercury233.me/ygosrv233/tips.json"
,
"dialogues"
:
"http://mercury233.me/ygosrv233/dialogues.json"
,
"enable_random_duel"
:
false
,
"enable_halfway_watch"
:
true
,
"enable_cloud_replay"
:
false
,
"enable_windbot"
:
false
,
"enable_websocket_roomlist"
:
false
,
"enable_public_roomlist"
:
false
,
"redis_port"
:
6379
,
"windbot_port"
:
2399
,
"spawn_windbot"
:
false
,
"hang_timeout"
:
90
,
"default_version"
:
4924
,
"default_room_info"
:
{
"lflist"
:
0
,
"rule"
:
0
,
"mode"
:
0
,
"comment"
:
"rule: 0=OCGONLY, 1=TCGONLY, 2=OT; mode: 0=SINGLE, 1=MATCH, 2=TAG"
,
"enable_priority"
:
false
,
"no_check_deck"
:
false
,
"no_shuffle_deck"
:
false
,
"start_lp"
:
8000
,
"start_hand"
:
5
,
"draw_count"
:
1
,
"time_limit"
:
180
"tips"
:
{
"enabled"
:
true
,
"get"
:
false
},
"dialogues"
:
{
"enabled"
:
true
,
"get"
:
"http://mercury233.me/ygosrv233/dialogues.json"
},
"random_duel"
:
{
"enabled"
:
false
,
"hang_timeout"
:
90
},
"cloud_replay"
:
{
"enabled"
:
false
,
"redis_port"
:
6379
,
"enable_halfway_watch"
:
true
},
"windbot"
:
{
"enabled"
:
false
,
"botlist"
:
"./windbot/bots.json"
,
"spawn"
:
false
,
"port"
:
2399
},
"mycard"
:
{
"enabled"
:
false
,
...
...
@@ -87,6 +98,8 @@
"http"
:
{
"port"
:
7922
,
"password"
:
"123456"
,
"websocket_roomlist"
:
false
,
"public_roomlist"
:
false
,
"ssl"
:
{
"enabled"
:
false
,
"port"
:
7923
,
...
...
@@ -103,5 +116,17 @@
"badword_level2"
:
[
"死妈"
,
"草你妈"
],
"badword_level3"
:
[
"迷奸"
,
"仿真枪"
],
"illegal_id"
:
[
"^Lv.
\\
d+"
,
"^VIP.
\\
d+"
]
},
"tip"
:
[
"欢迎来到本服务器"
,
"本服务器使用萌卡代码搭建"
],
"dialogues"
:
{
"46986414"
:
[
"出来吧,我最强的仆人,黑魔导!"
],
"58481572"
:
[
"我们来做朋友吧!"
]
}
}
\ No newline at end of file
mycard.config.json
View file @
91c6c3ed
...
...
@@ -2,13 +2,15 @@
"port"
:
7911
,
"modules"
:
{
"welcome"
:
"Mycard YGOPro Server"
,
"update"
:
"请更新游戏版本,可在社区手动下载更新包"
,
"tips"
:
"http://mycard.moe/tips.json"
,
"dialogues"
:
"http://mercury233.me/ygosrv233/dialogues.json"
,
"enable_windbot"
:
true
,
"enable_websocket_roomlist"
:
true
,
"windbot_port"
:
2399
,
"spawn_windbot"
:
true
,
"update"
:
"请更新游戏版本,可在社区(https://ygobbs.com)手动下载更新包"
,
"tips"
:
{
"enabled"
:
true
,
"get"
:
"http://mycard.moe/tips.json"
},
"dialogues"
:
{
"enabled"
:
true
,
"get"
:
"http://mercury233.me/ygosrv233/dialogues.json"
},
"mycard"
:
{
"enabled"
:
true
,
"auth_base_url"
:
"https://ygobbs.com"
,
...
...
@@ -28,9 +30,16 @@
"post_score"
:
"https://mycard.moe/ygopro/arena/index.php?c=update"
,
"get_score"
:
"https://mycard.moe/ygopro/arena/index.php?c=query&username="
},
"windbot"
:
{
"enabled"
:
true
,
"botlist"
:
"./windbot/bots.json"
,
"spawn"
:
false
,
"port"
:
2399
},
"http"
:
{
"port"
:
7922
,
"password"
:
"123456"
,
"websocket_roomlist"
:
true
,
"ssl"
:
{
"enabled"
:
true
,
"port"
:
7923
,
...
...
ygopro-server.coffee
View file @
91c6c3ed
...
...
@@ -83,10 +83,11 @@ ban_user = (name) ->
return
try
settings
.
version
=
parseInt
(
fs
.
readFileSync
(
'ygopro/gframe/game.cpp'
,
'utf8'
).
match
(
/PRO_VERSION = ([x\dABCDEF]+)/
)[
1
],
'16'
)
cppversion
=
parseInt
(
fs
.
readFileSync
(
'ygopro/gframe/game.cpp'
,
'utf8'
).
match
(
/PRO_VERSION = ([x\dABCDEF]+)/
)[
1
],
'16'
)
nconf
.
myset
(
settings
,
"version"
,
cppversion
)
log
.
info
"ygopro version 0x"
+
settings
.
version
.
toString
(
16
),
"(from source code)"
catch
settings
.
version
=
settings
.
modules
.
default_version
#settings.version = settings.version_default
log
.
info
"ygopro version 0x"
+
settings
.
version
.
toString
(
16
),
"(from config)"
# load the lflist of current date
settings
.
lflist
=
(
for
list
in
fs
.
readFileSync
(
'ygopro/lflist.conf'
,
'utf8'
).
match
(
/!.*/g
)
...
...
@@ -94,20 +95,20 @@ settings.lflist = (for list in fs.readFileSync('ygopro/lflist.conf', 'utf8').mat
continue
unless
date
{
date
:
moment
(
list
.
match
(
/!([\d\.]+)/
)[
1
],
'YYYY.MM.DD'
).
utcOffset
(
"-08:00"
),
tcg
:
list
.
indexOf
(
'TCG'
)
!=
-
1
})
if
settings
.
modules
.
enable_cloud_replay
if
settings
.
modules
.
cloud_replay
.
enabled
redis
=
require
'redis'
zlib
=
require
'zlib'
redisdb
=
redis
.
createClient
host
:
"127.0.0.1"
,
port
:
settings
.
modules
.
redis_port
redisdb
=
redis
.
createClient
host
:
"127.0.0.1"
,
port
:
settings
.
modules
.
cloud_replay
.
redis_port
redisdb
.
on
'error'
,
(
err
)
->
log
.
warn
err
return
if
settings
.
modules
.
enable_windbot
settings
.
modules
.
windbots
=
require
(
'./windbot/bots.json'
).
windbots
if
settings
.
modules
.
windbot
.
enabled
settings
.
modules
.
windbots
=
require
(
settings
.
modules
.
windbot
.
botlist
).
windbots
# 组件
ygopro
=
require
'./ygopro.js'
roomlist
=
require
'./roomlist.js'
if
settings
.
modules
.
enable_
websocket_roomlist
roomlist
=
require
'./roomlist.js'
if
settings
.
modules
.
http
.
websocket_roomlist
# cache users of mycard login
users_cache
=
{}
...
...
@@ -189,9 +190,9 @@ ROOM_ban_player = (name, ip, reason, countadd = 1)->
ROOM_find_or_create_by_name
=
(
name
,
player_ip
)
->
uname
=
name
.
toUpperCase
()
if
settings
.
modules
.
enable_windbot
and
(
uname
[
0
...
2
]
==
'AI'
or
(
!
settings
.
modules
.
enable_random_duel
and
uname
==
''
))
if
settings
.
modules
.
windbot
.
enabled
and
(
uname
[
0
...
2
]
==
'AI'
or
(
!
settings
.
modules
.
random_duel
.
enabled
and
uname
==
''
))
return
ROOM_find_or_create_ai
(
name
)
if
settings
.
modules
.
enable_random_duel
and
(
uname
==
''
or
uname
==
'S'
or
uname
==
'M'
or
uname
==
'T'
)
if
settings
.
modules
.
random_duel
.
enabled
and
(
uname
==
''
or
uname
==
'S'
or
uname
==
'M'
or
uname
==
'T'
)
return
ROOM_find_or_create_random
(
uname
,
player_ip
)
if
room
=
ROOM_find_by_name
(
name
)
return
room
...
...
@@ -306,7 +307,7 @@ class Room
@
scores
=
{}
ROOM_all
.
push
this
@
hostinfo
||=
settings
.
modules
.
default_room_
info
@
hostinfo
||=
settings
.
host
info
if
settings
.
lflist
.
length
if
@
hostinfo
.
rule
==
1
and
@
hostinfo
.
lflist
==
0
@
hostinfo
.
lflist
=
_
.
findIndex
settings
.
lflist
,
(
list
)
->
list
.
tcg
...
...
@@ -406,7 +407,7 @@ class Room
@
process
.
stdout
.
setEncoding
(
'utf8'
)
@
process
.
stdout
.
once
'data'
,
(
data
)
=>
@
established
=
true
roomlist
.
create
(
this
)
if
!
@
private
and
settings
.
modules
.
enable_
websocket_roomlist
roomlist
.
create
(
this
)
if
!
@
private
and
settings
.
modules
.
http
.
websocket_roomlist
@
port
=
parseInt
data
_
.
each
@
players
,
(
player
)
=>
player
.
server
.
connect
@
port
,
'127.0.0.1'
,
->
...
...
@@ -457,7 +458,7 @@ class Room
else
log
.
info
'SCORE POST OK'
,
response
.
statusCode
,
response
.
statusMessage
,
@
name
,
body
return
if
@
player_datas
.
length
and
settings
.
modules
.
enable_cloud_replay
if
@
player_datas
.
length
and
settings
.
modules
.
cloud_replay
.
enabled
replay_id
=
@
cloud_replay_id
if
@
has_ygopro_error
log_rep_id
=
true
...
...
@@ -500,7 +501,7 @@ class Room
index
=
_
.
indexOf
(
ROOM_all
,
this
)
ROOM_all
[
index
]
=
null
unless
index
==
-
1
#ROOM_all.splice(index, 1) unless index == -1
roomlist
.
delete
@
name
if
!
@
private
and
!
@
started
and
@
established
and
settings
.
modules
.
enable_
websocket_roomlist
roomlist
.
delete
@
name
if
!
@
private
and
!
@
started
and
@
established
and
settings
.
modules
.
http
.
websocket_roomlist
return
get_playing_player
:
->
...
...
@@ -520,7 +521,7 @@ class Room
add_windbot
:
(
botdata
)
->
@
windbot
=
botdata
request
url
:
"http://127.0.0.1:
#{
settings
.
modules
.
windbot
_
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=127.0.0.1&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
url
:
"http://127.0.0.1:
#{
settings
.
modules
.
windbot
.
port
}
/?name=
#{
encodeURIComponent
(
botdata
.
name
)
}
&deck=
#{
encodeURIComponent
(
botdata
.
deck
)
}
&host=127.0.0.1&port=
#{
settings
.
port
}
&dialog=
#{
encodeURIComponent
(
botdata
.
dialog
)
}
&version=
#{
settings
.
version
}
&password=
#{
encodeURIComponent
(
@
name
)
}
"
,
(
error
,
response
,
body
)
=>
if
error
log
.
warn
'windbot add error'
,
error
,
this
.
name
...
...
@@ -544,7 +545,7 @@ class Room
ROOM_players_oppentlist
[
client
.
ip
]
=
null
if
@
established
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
enable_
websocket_roomlist
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
http
.
websocket_roomlist
client
.
server
.
connect
@
port
,
'127.0.0.1'
,
->
client
.
server
.
write
buffer
for
buffer
in
client
.
pre_establish_buffers
client
.
established
=
true
...
...
@@ -569,7 +570,7 @@ class Room
ROOM_ban_player
(
client
.
name
,
client
.
ip
,
"强退"
)
if
@
players
.
length
and
!
(
@
windbot
and
client
.
is_host
)
ygopro
.
stoc_send_chat_to_room
this
,
"
#{
client
.
name
}
离开了游戏"
+
if
error
then
":
#{
error
}
"
else
''
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
enable_
websocket_roomlist
roomlist
.
update
(
this
)
if
!
@
private
and
!
@
started
and
settings
.
modules
.
http
.
websocket_roomlist
#client.room = null
else
@
process
.
kill
()
...
...
@@ -657,7 +658,7 @@ net.createServer (client) ->
client
.
destroy
()
return
if
settings
.
modules
.
enable_cloud_replay
if
settings
.
modules
.
cloud_replay
.
enabled
client
.
open_cloud_replay
=
(
err
,
replay
)
->
if
err
or
!
replay
ygopro
.
stoc_die
(
client
,
"没有找到录像"
)
...
...
@@ -836,7 +837,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
if
settings
.
modules
.
stop
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
stop
)
else
if
info
.
pass
.
toUpperCase
()
==
"R"
and
settings
.
modules
.
enable_cloud_replay
else
if
info
.
pass
.
toUpperCase
()
==
"R"
and
settings
.
modules
.
cloud_replay
.
enabled
ygopro
.
stoc_send_chat
(
client
,
"以下是您近期的云录像,密码处输入 R#录像编号 即可观看"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
redisdb
.
lrange
client
.
ip
+
":replays"
,
0
,
2
,
(
err
,
result
)
->
_
.
each
result
,
(
replay_id
,
id
)
->
...
...
@@ -857,7 +858,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
client
.
destroy
()
return
),
500
else
if
info
.
pass
[
0
...
2
].
toUpperCase
()
==
"R#"
and
settings
.
modules
.
enable_cloud_replay
else
if
info
.
pass
[
0
...
2
].
toUpperCase
()
==
"R#"
and
settings
.
modules
.
cloud_replay
.
enabled
replay_id
=
info
.
pass
.
split
(
"#"
)[
1
]
if
(
replay_id
>
0
and
replay_id
<=
9
)
redisdb
.
lindex
client
.
ip
+
":replays"
,
replay_id
-
1
,
(
err
,
replay_id
)
->
...
...
@@ -872,7 +873,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else
ygopro
.
stoc_die
(
client
,
"没有找到录像"
)
else
if
info
.
pass
.
toUpperCase
()
==
"W"
and
settings
.
modules
.
enable_cloud_replay
else
if
info
.
pass
.
toUpperCase
()
==
"W"
and
settings
.
modules
.
cloud_replay
.
enabled
replay_id
=
Cloud_replay_ids
[
Math
.
floor
(
Math
.
random
()
*
Cloud_replay_ids
.
length
)]
redisdb
.
hgetall
"replay:"
+
replay_id
,
client
.
open_cloud_replay
...
...
@@ -884,7 +885,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
}
client
.
destroy
()
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
enable_random_duel
and
!
settings
.
modules
.
enable_windbot
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
random_duel
.
enabled
and
!
settings
.
modules
.
windbot
.
enabled
ygopro
.
stoc_die
(
client
,
"房间名不能为空,请在主机密码处填写房间名"
)
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard
.
enabled
and
info
.
pass
[
0
...
3
]
!=
'AI#'
...
...
@@ -1055,7 +1056,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else
if
room
.
error
ygopro
.
stoc_die
(
client
,
room
.
error
)
else
if
room
.
started
if
settings
.
modules
.
enable_halfway_watch
if
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
...
...
@@ -1112,14 +1113,14 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
recorder
.
on
'data'
,
(
data
)
->
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
and
settings
.
modules
.
enable_cloud_replay
return
unless
room
and
settings
.
modules
.
cloud_replay
.
enabled
room
.
recorder_buffers
.
push
data
return
recorder
.
on
'error'
,
(
error
)
->
return
if
settings
.
modules
.
enable_halfway_watch
and
!
room
.
watcher
if
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
and
!
room
.
watcher
room
.
watcher
=
watcher
=
net
.
connect
room
.
port
,
->
ygopro
.
ctos_send
watcher
,
'PLAYER_INFO'
,
{
name
:
"the Big Brother"
...
...
@@ -1149,7 +1150,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
# 登场台词
load_dialogues
=
()
->
request
url
:
settings
.
modules
.
dialogues
url
:
settings
.
modules
.
dialogues
.
get
json
:
true
,
(
error
,
response
,
body
)
->
if
_
.
isString
body
...
...
@@ -1162,7 +1163,7 @@ load_dialogues = () ->
return
return
if
settings
.
modules
.
dialogues
if
settings
.
modules
.
dialogues
.
get
load_dialogues
()
ygopro
.
stoc_follow
'GAME_MSG'
,
false
,
(
buffer
,
info
,
client
,
server
)
->
...
...
@@ -1224,7 +1225,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
ygopro
.
stoc_send_chat_to_room
(
room
,
"背水一战!"
,
ygopro
.
constants
.
COLORS
.
PINK
)
#登场台词
if
settings
.
modules
.
dialogues
if
settings
.
modules
.
dialogues
.
enabled
if
ygopro
.
constants
.
MSG
[
msg
]
==
'SUMMONING'
or
ygopro
.
constants
.
MSG
[
msg
]
==
'SPSUMMONING'
card
=
buffer
.
readUInt32LE
(
1
)
if
settings
.
dialogues
[
card
]
...
...
@@ -1289,15 +1290,17 @@ wait_room_start = (room, time)->
#tip
ygopro
.
stoc_send_random_tip
=
(
client
)
->
ygopro
.
stoc_send_chat
(
client
,
"Tip: "
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)])
if
settings
.
modules
.
tips
if
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
ygopro
.
stoc_send_chat
(
client
,
"Tip: "
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)])
return
ygopro
.
stoc_send_random_tip_to_room
=
(
room
)
->
ygopro
.
stoc_send_chat_to_room
(
room
,
"Tip: "
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)])
if
settings
.
modules
.
tips
if
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
ygopro
.
stoc_send_chat_to_room
(
room
,
"Tip: "
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)])
return
load_tips
=
()
->
request
url
:
settings
.
modules
.
tips
url
:
settings
.
modules
.
tips
.
get
json
:
true
,
(
error
,
response
,
body
)
->
if
_
.
isString
body
...
...
@@ -1310,7 +1313,7 @@ load_tips = ()->
return
return
if
settings
.
modules
.
tips
if
settings
.
modules
.
tips
.
get
load_tips
()
setInterval
()
->
for
room
in
ROOM_all
when
room
and
room
.
established
...
...
@@ -1324,14 +1327,14 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
unless
room
.
started
#first start
room
.
started
=
true
room
.
start_time
=
moment
().
format
()
roomlist
.
delete
room
.
name
if
settings
.
modules
.
enable_
websocket_roomlist
and
not
room
.
private
roomlist
.
delete
room
.
name
if
settings
.
modules
.
http
.
websocket_roomlist
and
not
room
.
private
#room.duels = []
room
.
dueling_players
=
[]
for
player
in
room
.
players
when
player
.
pos
!=
7
room
.
dueling_players
[
player
.
pos
]
=
player
room
.
scores
[
player
.
name
]
=
0
room
.
player_datas
.
push
ip
:
player
.
ip
,
name
:
player
.
name
if
settings
.
modules
.
tips
if
settings
.
modules
.
tips
.
enabled
ygopro
.
stoc_send_random_tip
(
client
)
if
settings
.
modules
.
deck_log
.
enabled
and
client
.
main
and
client
.
main
.
length
and
not
client
.
deck_saved
and
client
.
ip
!=
'::ffff:127.0.0.1'
deck_text
=
'#ygopro-server deck log
\n
#main
\n
'
+
client
.
main
.
join
(
'
\n
'
)
+
'
\n
!side
\n
'
+
client
.
side
.
join
(
'
\n
'
)
+
'
\n
'
...
...
@@ -1370,14 +1373,14 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
ygopro
.
stoc_send_chat
(
client
,
"YGOSrv233 指令帮助"
)
ygopro
.
stoc_send_chat
(
client
,
"/help 显示这个帮助信息"
)
ygopro
.
stoc_send_chat
(
client
,
"/roomname 显示当前房间的名字"
)
if
!
settings
.
modules
.
mycard
.
enabled
ygopro
.
stoc_send_chat
(
client
,
"/ai 添加一个AI,/ai 角色名 可指定添加的角色"
)
if
settings
.
modules
.
enable_windbot
ygopro
.
stoc_send_chat
(
client
,
"/tip 显示一条提示"
)
if
settings
.
modules
.
tips
ygopro
.
stoc_send_chat
(
client
,
"/ai 添加一个AI,/ai 角色名 可指定添加的角色"
)
if
settings
.
modules
.
windbot
.
enabled
ygopro
.
stoc_send_chat
(
client
,
"/tip 显示一条提示"
)
if
settings
.
modules
.
tips
.
enabled
when
'/tip'
ygopro
.
stoc_send_random_tip
(
client
)
if
settings
.
modules
.
tips
ygopro
.
stoc_send_random_tip
(
client
)
if
settings
.
modules
.
tips
.
enabled
when
'/ai'
if
settings
.
modules
.
enable_windbot
if
settings
.
modules
.
windbot
.
enabled
if
name
=
cmd
[
1
]
windbot
=
_
.
sample
_
.
filter
settings
.
modules
.
windbots
,
(
w
)
->
w
.
name
==
name
or
w
.
deck
==
name
...
...
@@ -1512,7 +1515,7 @@ ygopro.ctos_follow 'HAND_RESULT', false, (buffer, info, client, server)->
return
unless
room
and
room
.
random_type
if
client
.
is_host
room
.
waiting_for_player
=
room
.
waiting_for_player2
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
hang_timeout
-
19
,
's'
)
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
random_duel
.
hang_timeout
-
19
,
's'
)
return
ygopro
.
ctos_follow
'TP_RESULT'
,
false
,
(
buffer
,
info
,
client
,
server
)
->
...
...
@@ -1528,7 +1531,7 @@ ygopro.stoc_follow 'SELECT_HAND', false, (buffer, info, client, server)->
room
.
waiting_for_player
=
client
else
room
.
waiting_for_player2
=
client
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
hang_timeout
-
19
,
's'
)
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
random_duel
.
hang_timeout
-
19
,
's'
)
return
ygopro
.
stoc_follow
'SELECT_TP'
,
false
,
(
buffer
,
info
,
client
,
server
)
->
...
...
@@ -1551,7 +1554,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
unless
room
if
settings
.
modules
.
enable_cloud_replay
and
room
.
random_type
if
settings
.
modules
.
cloud_replay
.
enabled
and
room
.
random_type
Cloud_replay_ids
.
push
room
.
cloud_replay_id
if
settings
.
modules
.
tournament_mode
.
enabled
if
client
.
is_host
...
...
@@ -1567,29 +1570,30 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
}
settings
.
modules
.
tournament_mode
.
duel_log
.
push
duellog
nconf
.
myset
(
settings
,
"modules:tournament_mode:duel_log"
,
settings
.
modules
.
tournament_mode
.
duel_log
)
if
settings
.
modules
.
enable_cloud_replay
if
settings
.
modules
.
cloud_replay
.
enabled
ygopro
.
stoc_send_chat
(
client
,
"本场比赛云录像:R#
#{
room
.
cloud_replay_id
}
。将于本局结束后可播放。"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
true
else
return
false
if
settings
.
modules
.
enable_random_duel
if
settings
.
modules
.
random_duel
.
enabled
setInterval
()
->
for
room
in
ROOM_all
when
room
and
room
.
started
and
room
.
random_type
and
room
.
last_active_time
and
room
.
waiting_for_player
time_passed
=
Math
.
floor
((
moment
()
-
room
.
last_active_time
)
/
1000
)
#log.info time_passed
if
time_passed
>=
settings
.
modules
.
hang_timeout
if
time_passed
>=
settings
.
modules
.
random_duel
.
hang_timeout
room
.
last_active_time
=
moment
()
ROOM_ban_player
(
room
.
waiting_for_player
.
name
,
room
.
waiting_for_player
.
ip
,
"挂机"
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
room
.
waiting_for_player
.
name
}
被系统请出了房间"
,
ygopro
.
constants
.
COLORS
.
RED
)
room
.
waiting_for_player
.
server
.
destroy
()
else
if
time_passed
>=
(
settings
.
modules
.
hang_timeout
-
20
)
and
not
(
time_passed
%
10
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
room
.
waiting_for_player
.
name
}
已经很久没有操作了,若继续挂机,将于
#{
settings
.
modules
.
hang_timeout
-
time_passed
}
秒后被请出房间"
,
ygopro
.
constants
.
COLORS
.
RED
)
else
if
time_passed
>=
(
settings
.
modules
.
random_duel
.
hang_timeout
-
20
)
and
not
(
time_passed
%
10
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
room
.
waiting_for_player
.
name
}
已经很久没有操作了,若继续挂机,将于
#{
settings
.
modules
.
random_duel
.
hang_timeout
-
time_passed
}
秒后被请出房间"
,
ygopro
.
constants
.
COLORS
.
RED
)
return
,
1000
if
settings
.
modules
.
spawn_windbot
windbot_process
=
spawn
'mono'
,
[
'WindBot.exe'
,
settings
.
modules
.
windbot_port
],
{
cwd
:
'windbot'
}
# spawn windbot
if
settings
.
modules
.
windbot
.
spawn
windbot_process
=
spawn
'mono'
,
[
'WindBot.exe'
,
settings
.
modules
.
windbot
.
port
],
{
cwd
:
'windbot'
}
windbot_process
.
on
'error'
,
(
err
)
->
log
.
warn
'WindBot ERROR'
,
err
return
...
...
@@ -1618,7 +1622,7 @@ if settings.modules.http
pass_validated
=
u
.
query
.
pass
==
settings
.
modules
.
http
.
password
if
u
.
pathname
==
'/api/getrooms'
if
!
pass_validated
and
!
settings
.
modules
.
enable_
public_roomlist
if
!
pass_validated
and
!
settings
.
modules
.
http
.
public_roomlist
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
'{"rooms":[{"roomid":"0","roomname":"密码错误","needpass":"true"}]}'
))
else
...
...
@@ -1678,12 +1682,12 @@ if settings.modules.http
else
if
u
.
query
.
loadtips
load_tips
()
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading tip', '"
+
settings
.
modules
.
tips
+
"']"
))
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading tip', '"
+
settings
.
modules
.
tips
.
get
+
"']"
))
else
if
u
.
query
.
loaddialogues
load_dialogues
()
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading dialogues', '"
+
settings
.
modules
.
dialogues
+
"']"
))
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['loading dialogues', '"
+
settings
.
modules
.
dialogues
.
get
+
"']"
))
else
if
u
.
query
.
ban
ban_user
(
u
.
query
.
ban
)
...
...
ygopro-server.js
View file @
91c6c3ed
// Generated by CoffeeScript 1.12.1
(
function
()
{
var
Cloud_replay_ids
,
Graveyard
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_validate
,
Room
,
_
,
addCallback
,
ban_user
,
bunyan
,
crypto
,
date
,
defaultconfig
,
execFile
,
fs
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
list
,
load_dialogues
,
load_tips
,
log
,
moment
,
nconf
,
net
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
request
,
requestListener
,
roomlist
,
settings
,
spawn
,
spawnSync
,
tribute
,
url
,
users_cache
,
wait_room_start
,
windbot_process
,
ygopro
,
zlib
;
var
Cloud_replay_ids
,
Graveyard
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_port
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_players_banned
,
ROOM_players_oppentlist
,
ROOM_validate
,
Room
,
_
,
addCallback
,
ban_user
,
bunyan
,
c
ppversion
,
c
rypto
,
date
,
defaultconfig
,
execFile
,
fs
,
get_memory_usage
,
http
,
http_server
,
https
,
https_server
,
list
,
load_dialogues
,
load_tips
,
log
,
moment
,
nconf
,
net
,
options
,
os
,
path
,
pgClient
,
pg_client
,
pg_query
,
redis
,
redisdb
,
request
,
requestListener
,
roomlist
,
settings
,
spawn
,
spawnSync
,
tribute
,
url
,
users_cache
,
wait_room_start
,
windbot_process
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -112,10 +112,10 @@
};
try
{
settings
.
version
=
parseInt
(
fs
.
readFileSync
(
'
ygopro/gframe/game.cpp
'
,
'
utf8
'
).
match
(
/PRO_VERSION =
([
x
\d
ABCDEF
]
+
)
/
)[
1
],
'
16
'
);
cppversion
=
parseInt
(
fs
.
readFileSync
(
'
ygopro/gframe/game.cpp
'
,
'
utf8
'
).
match
(
/PRO_VERSION =
([
x
\d
ABCDEF
]
+
)
/
)[
1
],
'
16
'
);
nconf
.
myset
(
settings
,
"
version
"
,
cppversion
);
log
.
info
(
"
ygopro version 0x
"
+
settings
.
version
.
toString
(
16
),
"
(from source code)
"
);
}
catch
(
error1
)
{
settings
.
version
=
settings
.
modules
.
default_version
;
log
.
info
(
"
ygopro version 0x
"
+
settings
.
version
.
toString
(
16
),
"
(from config)
"
);
}
...
...
@@ -137,25 +137,25 @@
return
results
;
})();
if
(
settings
.
modules
.
enable_cloud_replay
)
{
if
(
settings
.
modules
.
cloud_replay
.
enabled
)
{
redis
=
require
(
'
redis
'
);
zlib
=
require
(
'
zlib
'
);
redisdb
=
redis
.
createClient
({
host
:
"
127.0.0.1
"
,
port
:
settings
.
modules
.
redis_port
port
:
settings
.
modules
.
cloud_replay
.
redis_port
});
redisdb
.
on
(
'
error
'
,
function
(
err
)
{
log
.
warn
(
err
);
});
}
if
(
settings
.
modules
.
enable_windbot
)
{
settings
.
modules
.
windbots
=
require
(
'
./windbot/bots.json
'
).
windbots
;
if
(
settings
.
modules
.
windbot
.
enabled
)
{
settings
.
modules
.
windbots
=
require
(
settings
.
modules
.
windbot
.
botlist
).
windbots
;
}
ygopro
=
require
(
'
./ygopro.js
'
);
if
(
settings
.
modules
.
enable_
websocket_roomlist
)
{
if
(
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
=
require
(
'
./roomlist.js
'
);
}
...
...
@@ -264,10 +264,10 @@
ROOM_find_or_create_by_name
=
function
(
name
,
player_ip
)
{
var
room
,
uname
;
uname
=
name
.
toUpperCase
();
if
(
settings
.
modules
.
enable_windbot
&&
(
uname
.
slice
(
0
,
2
)
===
'
AI
'
||
(
!
settings
.
modules
.
enable_random_duel
&&
uname
===
''
)))
{
if
(
settings
.
modules
.
windbot
.
enabled
&&
(
uname
.
slice
(
0
,
2
)
===
'
AI
'
||
(
!
settings
.
modules
.
random_duel
.
enabled
&&
uname
===
''
)))
{
return
ROOM_find_or_create_ai
(
name
);
}
if
(
settings
.
modules
.
enable_random_duel
&&
(
uname
===
''
||
uname
===
'
S
'
||
uname
===
'
M
'
||
uname
===
'
T
'
))
{
if
(
settings
.
modules
.
random_duel
.
enabled
&&
(
uname
===
''
||
uname
===
'
S
'
||
uname
===
'
M
'
||
uname
===
'
T
'
))
{
return
ROOM_find_or_create_random
(
uname
,
player_ip
);
}
if
(
room
=
ROOM_find_by_name
(
name
))
{
...
...
@@ -419,7 +419,7 @@
this
.
welcome
=
''
;
this
.
scores
=
{};
ROOM_all
.
push
(
this
);
this
.
hostinfo
||
(
this
.
hostinfo
=
settings
.
modules
.
default_room_
info
);
this
.
hostinfo
||
(
this
.
hostinfo
=
settings
.
host
info
);
if
(
settings
.
lflist
.
length
)
{
if
(
this
.
hostinfo
.
rule
===
1
&&
this
.
hostinfo
.
lflist
===
0
)
{
this
.
hostinfo
.
lflist
=
_
.
findIndex
(
settings
.
lflist
,
function
(
list
)
{
...
...
@@ -542,7 +542,7 @@
this
.
process
.
stdout
.
once
(
'
data
'
,
(
function
(
_this
)
{
return
function
(
data
)
{
_this
.
established
=
true
;
if
(
!
_this
[
"
private
"
]
&&
settings
.
modules
.
enable_
websocket_roomlist
)
{
if
(
!
_this
[
"
private
"
]
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
.
create
(
_this
);
}
_this
.
port
=
parseInt
(
data
);
...
...
@@ -623,7 +623,7 @@
})(
this
));
}
}
if
(
this
.
player_datas
.
length
&&
settings
.
modules
.
enable_cloud_replay
)
{
if
(
this
.
player_datas
.
length
&&
settings
.
modules
.
cloud_replay
.
enabled
)
{
replay_id
=
this
.
cloud_replay_id
;
if
(
this
.
has_ygopro_error
)
{
log_rep_id
=
true
;
...
...
@@ -669,7 +669,7 @@
if
(
index
!==
-
1
)
{
ROOM_all
[
index
]
=
null
;
}
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
this
.
established
&&
settings
.
modules
.
enable_
websocket_roomlist
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
this
.
established
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
[
"
delete
"
](
this
.
name
);
}
};
...
...
@@ -699,7 +699,7 @@
Room
.
prototype
.
add_windbot
=
function
(
botdata
)
{
this
.
windbot
=
botdata
;
request
({
url
:
"
http://127.0.0.1:
"
+
settings
.
modules
.
windbot
_
port
+
"
/?name=
"
+
(
encodeURIComponent
(
botdata
.
name
))
+
"
&deck=
"
+
(
encodeURIComponent
(
botdata
.
deck
))
+
"
&host=127.0.0.1&port=
"
+
settings
.
port
+
"
&dialog=
"
+
(
encodeURIComponent
(
botdata
.
dialog
))
+
"
&version=
"
+
settings
.
version
+
"
&password=
"
+
(
encodeURIComponent
(
this
.
name
))
url
:
"
http://127.0.0.1:
"
+
settings
.
modules
.
windbot
.
port
+
"
/?name=
"
+
(
encodeURIComponent
(
botdata
.
name
))
+
"
&deck=
"
+
(
encodeURIComponent
(
botdata
.
deck
))
+
"
&host=127.0.0.1&port=
"
+
settings
.
port
+
"
&dialog=
"
+
(
encodeURIComponent
(
botdata
.
dialog
))
+
"
&version=
"
+
settings
.
version
+
"
&password=
"
+
(
encodeURIComponent
(
this
.
name
))
},
(
function
(
_this
)
{
return
function
(
error
,
response
,
body
)
{
if
(
error
)
{
...
...
@@ -724,7 +724,7 @@
}
}
if
(
this
.
established
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
enable_
websocket_roomlist
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
.
update
(
this
);
}
client
.
server
.
connect
(
this
.
port
,
'
127.0.0.1
'
,
function
()
{
...
...
@@ -762,7 +762,7 @@
}
if
(
this
.
players
.
length
&&
!
(
this
.
windbot
&&
client
.
is_host
))
{
ygopro
.
stoc_send_chat_to_room
(
this
,
(
client
.
name
+
"
离开了游戏
"
)
+
(
error
?
"
:
"
+
error
:
''
));
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
enable_
websocket_roomlist
)
{
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
.
update
(
this
);
}
}
else
{
...
...
@@ -857,7 +857,7 @@
client
.
destroy
();
return
;
}
if
(
settings
.
modules
.
enable_cloud_replay
)
{
if
(
settings
.
modules
.
cloud_replay
.
enabled
)
{
client
.
open_cloud_replay
=
function
(
err
,
replay
)
{
var
buffer
;
if
(
err
||
!
replay
)
{
...
...
@@ -1052,7 +1052,7 @@
var
check
,
decrypted_buffer
,
finish
,
i
,
id
,
k
,
l
,
len
,
len1
,
name
,
ref
,
ref1
,
replay_id
,
room
,
secret
,
struct
;
if
(
settings
.
modules
.
stop
)
{
ygopro
.
stoc_die
(
client
,
settings
.
modules
.
stop
);
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
R
"
&&
settings
.
modules
.
enable_cloud_replay
)
{
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
R
"
&&
settings
.
modules
.
cloud_replay
.
enabled
)
{
ygopro
.
stoc_send_chat
(
client
,
"
以下是您近期的云录像,密码处输入 R#录像编号 即可观看
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
redisdb
.
lrange
(
client
.
ip
+
"
:replays
"
,
0
,
2
,
function
(
err
,
result
)
{
_
.
each
(
result
,
function
(
replay_id
,
id
)
{
...
...
@@ -1074,7 +1074,7 @@
});
client
.
destroy
();
}),
500
);
}
else
if
(
info
.
pass
.
slice
(
0
,
2
).
toUpperCase
()
===
"
R#
"
&&
settings
.
modules
.
enable_cloud_replay
)
{
}
else
if
(
info
.
pass
.
slice
(
0
,
2
).
toUpperCase
()
===
"
R#
"
&&
settings
.
modules
.
cloud_replay
.
enabled
)
{
replay_id
=
info
.
pass
.
split
(
"
#
"
)[
1
];
if
(
replay_id
>
0
&&
replay_id
<=
9
)
{
redisdb
.
lindex
(
client
.
ip
+
"
:replays
"
,
replay_id
-
1
,
function
(
err
,
replay_id
)
{
...
...
@@ -1092,7 +1092,7 @@
}
else
{
ygopro
.
stoc_die
(
client
,
"
没有找到录像
"
);
}
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
W
"
&&
settings
.
modules
.
enable_cloud_replay
)
{
}
else
if
(
info
.
pass
.
toUpperCase
()
===
"
W
"
&&
settings
.
modules
.
cloud_replay
.
enabled
)
{
replay_id
=
Cloud_replay_ids
[
Math
.
floor
(
Math
.
random
()
*
Cloud_replay_ids
.
length
)];
redisdb
.
hgetall
(
"
replay:
"
+
replay_id
,
client
.
open_cloud_replay
);
}
else
if
(
info
.
version
!==
settings
.
version
&&
(
info
.
version
!==
4921
||
settings
.
version
!==
4922
))
{
...
...
@@ -1102,7 +1102,7 @@
code
:
settings
.
version
});
client
.
destroy
();
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
enable_random_duel
&&
!
settings
.
modules
.
enable_windbot
)
{
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
random_duel
.
enabled
&&
!
settings
.
modules
.
windbot
.
enabled
)
{
ygopro
.
stoc_die
(
client
,
"
房间名不能为空,请在主机密码处填写房间名
"
);
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard
.
enabled
&&
info
.
pass
.
slice
(
0
,
3
)
!==
'
AI#
'
)
{
ygopro
.
stoc_send_chat
(
client
,
'
正在读取用户信息...
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
...
...
@@ -1277,7 +1277,7 @@
}
else
if
(
room
.
error
)
{
ygopro
.
stoc_die
(
client
,
room
.
error
);
}
else
if
(
room
.
started
)
{
if
(
settings
.
modules
.
enable_halfway_watch
)
{
if
(
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
)
{
client
.
setTimeout
(
300000
);
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
...
...
@@ -1344,14 +1344,14 @@
});
recorder
.
on
(
'
data
'
,
function
(
data
)
{
room
=
ROOM_all
[
client
.
rid
];
if
(
!
(
room
&&
settings
.
modules
.
enable_cloud_replay
))
{
if
(
!
(
room
&&
settings
.
modules
.
cloud_replay
.
enabled
))
{
return
;
}
room
.
recorder_buffers
.
push
(
data
);
});
recorder
.
on
(
'
error
'
,
function
(
error
)
{});
}
if
(
settings
.
modules
.
enable_halfway_watch
&&
!
room
.
watcher
)
{
if
(
settings
.
modules
.
cloud_replay
.
enable_halfway_watch
&&
!
room
.
watcher
)
{
room
.
watcher
=
watcher
=
net
.
connect
(
room
.
port
,
function
()
{
ygopro
.
ctos_send
(
watcher
,
'
PLAYER_INFO
'
,
{
name
:
"
the Big Brother
"
...
...
@@ -1385,7 +1385,7 @@
load_dialogues
=
function
()
{
request
({
url
:
settings
.
modules
.
dialogues
,
url
:
settings
.
modules
.
dialogues
.
get
,
json
:
true
},
function
(
error
,
response
,
body
)
{
if
(
_
.
isString
(
body
))
{
...
...
@@ -1399,7 +1399,7 @@
});
};
if
(
settings
.
modules
.
dialogues
)
{
if
(
settings
.
modules
.
dialogues
.
get
)
{
load_dialogues
();
}
...
...
@@ -1469,7 +1469,7 @@
ygopro
.
stoc_send_chat_to_room
(
room
,
"
背水一战!
"
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
}
if
(
settings
.
modules
.
dialogues
)
{
if
(
settings
.
modules
.
dialogues
.
enabled
)
{
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
SUMMONING
'
||
ygopro
.
constants
.
MSG
[
msg
]
===
'
SPSUMMONING
'
)
{
card
=
buffer
.
readUInt32LE
(
1
);
if
(
settings
.
dialogues
[
card
])
{
...
...
@@ -1568,20 +1568,20 @@
};
ygopro
.
stoc_send_random_tip
=
function
(
client
)
{
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
)
{
ygopro
.
stoc_send_chat
(
client
,
"
Tip:
"
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)]);
}
};
ygopro
.
stoc_send_random_tip_to_room
=
function
(
room
)
{
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
enabled
&&
settings
.
tips
.
length
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
"
Tip:
"
+
settings
.
tips
[
Math
.
floor
(
Math
.
random
()
*
settings
.
tips
.
length
)]);
}
};
load_tips
=
function
()
{
request
({
url
:
settings
.
modules
.
tips
,
url
:
settings
.
modules
.
tips
.
get
,
json
:
true
},
function
(
error
,
response
,
body
)
{
if
(
_
.
isString
(
body
))
{
...
...
@@ -1595,7 +1595,7 @@
});
};
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
get
)
{
load_tips
();
setInterval
(
function
()
{
var
k
,
len
,
room
;
...
...
@@ -1619,7 +1619,7 @@
if
(
!
room
.
started
)
{
room
.
started
=
true
;
room
.
start_time
=
moment
().
format
();
if
(
settings
.
modules
.
enable_
websocket_roomlist
&&
!
room
[
"
private
"
])
{
if
(
settings
.
modules
.
http
.
websocket_roomlist
&&
!
room
[
"
private
"
])
{
roomlist
[
"
delete
"
](
room
.
name
);
}
room
.
dueling_players
=
[];
...
...
@@ -1637,7 +1637,7 @@
});
}
}
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
enabled
)
{
ygopro
.
stoc_send_random_tip
(
client
);
}
if
(
settings
.
modules
.
deck_log
.
enabled
&&
client
.
main
&&
client
.
main
.
length
&&
!
client
.
deck_saved
&&
client
.
ip
!==
'
::ffff:127.0.0.1
'
)
{
...
...
@@ -1694,20 +1694,20 @@
if
(
!
settings
.
modules
.
mycard
.
enabled
)
{
ygopro
.
stoc_send_chat
(
client
,
"
/roomname 显示当前房间的名字
"
);
}
if
(
settings
.
modules
.
enable_windbot
)
{
if
(
settings
.
modules
.
windbot
.
enabled
)
{
ygopro
.
stoc_send_chat
(
client
,
"
/ai 添加一个AI,/ai 角色名 可指定添加的角色
"
);
}
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
enabled
)
{
ygopro
.
stoc_send_chat
(
client
,
"
/tip 显示一条提示
"
);
}
break
;
case
'
/tip
'
:
if
(
settings
.
modules
.
tips
)
{
if
(
settings
.
modules
.
tips
.
enabled
)
{
ygopro
.
stoc_send_random_tip
(
client
);
}
break
;
case
'
/ai
'
:
if
(
settings
.
modules
.
enable_windbot
)
{
if
(
settings
.
modules
.
windbot
.
enabled
)
{
if
(
name
=
cmd
[
1
])
{
windbot
=
_
.
sample
(
_
.
filter
(
settings
.
modules
.
windbots
,
function
(
w
)
{
return
w
.
name
===
name
||
w
.
deck
===
name
;
...
...
@@ -1891,7 +1891,7 @@
if
(
client
.
is_host
)
{
room
.
waiting_for_player
=
room
.
waiting_for_player2
;
}
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
hang_timeout
-
19
,
'
s
'
);
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
random_duel
.
hang_timeout
-
19
,
'
s
'
);
});
ygopro
.
ctos_follow
(
'
TP_RESULT
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
...
...
@@ -1914,7 +1914,7 @@
}
else
{
room
.
waiting_for_player2
=
client
;
}
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
hang_timeout
-
19
,
'
s
'
);
room
.
last_active_time
=
moment
().
subtract
(
settings
.
modules
.
random_duel
.
hang_timeout
-
19
,
'
s
'
);
});
ygopro
.
stoc_follow
(
'
SELECT_TP
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
...
...
@@ -1947,7 +1947,7 @@
if
(
!
room
)
{
return
settings
.
modules
.
tournament_mode
.
enabled
;
}
if
(
settings
.
modules
.
enable_cloud_replay
&&
room
.
random_type
)
{
if
(
settings
.
modules
.
cloud_replay
.
enabled
&&
room
.
random_type
)
{
Cloud_replay_ids
.
push
(
room
.
cloud_replay_id
);
}
if
(
settings
.
modules
.
tournament_mode
.
enabled
)
{
...
...
@@ -1974,7 +1974,7 @@
settings
.
modules
.
tournament_mode
.
duel_log
.
push
(
duellog
);
nconf
.
myset
(
settings
,
"
modules:tournament_mode:duel_log
"
,
settings
.
modules
.
tournament_mode
.
duel_log
);
}
if
(
settings
.
modules
.
enable_cloud_replay
)
{
if
(
settings
.
modules
.
cloud_replay
.
enabled
)
{
ygopro
.
stoc_send_chat
(
client
,
"
本场比赛云录像:R#
"
+
room
.
cloud_replay_id
+
"
。将于本局结束后可播放。
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
return
true
;
...
...
@@ -1983,7 +1983,7 @@
}
});
if
(
settings
.
modules
.
enable_random_duel
)
{
if
(
settings
.
modules
.
random_duel
.
enabled
)
{
setInterval
(
function
()
{
var
k
,
len
,
room
,
time_passed
;
for
(
k
=
0
,
len
=
ROOM_all
.
length
;
k
<
len
;
k
++
)
{
...
...
@@ -1992,20 +1992,20 @@
continue
;
}
time_passed
=
Math
.
floor
((
moment
()
-
room
.
last_active_time
)
/
1000
);
if
(
time_passed
>=
settings
.
modules
.
hang_timeout
)
{
if
(
time_passed
>=
settings
.
modules
.
random_duel
.
hang_timeout
)
{
room
.
last_active_time
=
moment
();
ROOM_ban_player
(
room
.
waiting_for_player
.
name
,
room
.
waiting_for_player
.
ip
,
"
挂机
"
);
ygopro
.
stoc_send_chat_to_room
(
room
,
room
.
waiting_for_player
.
name
+
"
被系统请出了房间
"
,
ygopro
.
constants
.
COLORS
.
RED
);
room
.
waiting_for_player
.
server
.
destroy
();
}
else
if
(
time_passed
>=
(
settings
.
modules
.
hang_timeout
-
20
)
&&
!
(
time_passed
%
10
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
room
.
waiting_for_player
.
name
+
"
已经很久没有操作了,若继续挂机,将于
"
+
(
settings
.
modules
.
hang_timeout
-
time_passed
)
+
"
秒后被请出房间
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
else
if
(
time_passed
>=
(
settings
.
modules
.
random_duel
.
hang_timeout
-
20
)
&&
!
(
time_passed
%
10
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
room
.
waiting_for_player
.
name
+
"
已经很久没有操作了,若继续挂机,将于
"
+
(
settings
.
modules
.
random_duel
.
hang_timeout
-
time_passed
)
+
"
秒后被请出房间
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
}
},
1000
);
}
if
(
settings
.
modules
.
spawn_windbot
)
{
windbot_process
=
spawn
(
'
mono
'
,
[
'
WindBot.exe
'
,
settings
.
modules
.
windbot
_
port
],
{
if
(
settings
.
modules
.
windbot
.
spawn
)
{
windbot_process
=
spawn
(
'
mono
'
,
[
'
WindBot.exe
'
,
settings
.
modules
.
windbot
.
port
],
{
cwd
:
'
windbot
'
});
windbot_process
.
on
(
'
error
'
,
function
(
err
)
{
...
...
@@ -2037,7 +2037,7 @@
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
if
(
u
.
pathname
===
'
/api/getrooms
'
)
{
if
(
!
pass_validated
&&
!
settings
.
modules
.
enable_
public_roomlist
)
{
if
(
!
pass_validated
&&
!
settings
.
modules
.
http
.
public_roomlist
)
{
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
'
{"rooms":[{"roomid":"0","roomname":"密码错误","needpass":"true"}]}
'
));
}
else
{
...
...
@@ -2121,11 +2121,11 @@
}
else
if
(
u
.
query
.
loadtips
)
{
load_tips
();
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['loading tip', '
"
+
settings
.
modules
.
tips
+
"
']
"
));
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['loading tip', '
"
+
settings
.
modules
.
tips
.
get
+
"
']
"
));
}
else
if
(
u
.
query
.
loaddialogues
)
{
load_dialogues
();
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['loading dialogues', '
"
+
settings
.
modules
.
dialogues
+
"
']
"
));
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
['loading dialogues', '
"
+
settings
.
modules
.
dialogues
.
get
+
"
']
"
));
}
else
if
(
u
.
query
.
ban
)
{
ban_user
(
u
.
query
.
ban
);
response
.
writeHead
(
200
);
...
...
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