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
a1cbc654
Commit
a1cbc654
authored
Oct 29, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
18653c2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
16 deletions
+24
-16
ygopro-server.coffee
ygopro-server.coffee
+11
-8
ygopro-server.js
ygopro-server.js
+13
-8
No files found.
ygopro-server.coffee
View file @
a1cbc654
...
@@ -260,6 +260,7 @@ ROOM_find_or_create_ai = (name)->
...
@@ -260,6 +260,7 @@ ROOM_find_or_create_ai = (name)->
return
{
"error"
:
"AI房间名过长,请在建立房间后输入 /ai 来添加AI"
}
return
{
"error"
:
"AI房间名过长,请在建立房间后输入 /ai 来添加AI"
}
result
=
new
Room
(
name
)
result
=
new
Room
(
name
)
result
.
windbot
=
windbot
result
.
windbot
=
windbot
result
.
private
=
true
return
result
return
result
ROOM_find_by_name
=
(
name
)
->
ROOM_find_by_name
=
(
name
)
->
...
@@ -451,9 +452,9 @@ class Room
...
@@ -451,9 +452,9 @@ class Room
arena
:
if
@
hostinfo
.
mode
==
1
then
'athletic'
else
'entertain'
#settings.modules.arena_mode.mode
arena
:
if
@
hostinfo
.
mode
==
1
then
'athletic'
else
'entertain'
#settings.modules.arena_mode.mode
}},
(
error
,
response
,
body
)
=>
}},
(
error
,
response
,
body
)
=>
if
error
if
error
log
.
warn
'SCORE POST ERROR'
,
error
,
response
.
statusCode
,
response
.
statusMessage
,
body
log
.
warn
'SCORE POST ERROR'
,
error
else
else
if
response
.
statusCode
!=
204
if
response
.
statusCode
!=
204
or
response
.
statusCode
!=
200
log
.
warn
'SCORE POST FAIL'
,
response
.
statusCode
,
response
.
statusMessage
,
@
name
,
body
log
.
warn
'SCORE POST FAIL'
,
response
.
statusCode
,
response
.
statusMessage
,
@
name
,
body
else
else
log
.
info
'SCORE POST OK'
,
response
.
statusCode
,
response
.
statusMessage
,
@
name
,
body
log
.
info
'SCORE POST OK'
,
response
.
statusCode
,
response
.
statusMessage
,
@
name
,
body
...
@@ -524,7 +525,7 @@ class Room
...
@@ -524,7 +525,7 @@ class Room
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
)
=>
,
(
error
,
response
,
body
)
=>
if
error
if
error
log
.
warn
'windbot add error'
,
error
,
this
.
name
,
response
log
.
warn
'windbot add error'
,
error
,
this
.
name
ygopro
.
stoc_send_chat_to_room
(
this
,
"添加AI失败,可尝试输入 /ai 重新添加"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send_chat_to_room
(
this
,
"添加AI失败,可尝试输入 /ai 重新添加"
,
ygopro
.
constants
.
COLORS
.
RED
)
#else
#else
#log.info "windbot added"
#log.info "windbot added"
...
@@ -888,7 +889,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -888,7 +889,7 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
enable_random_duel
and
!
settings
.
modules
.
enable_windbot
else
if
!
info
.
pass
.
length
and
!
settings
.
modules
.
enable_random_duel
and
!
settings
.
modules
.
enable_windbot
ygopro
.
stoc_die
(
client
,
"房间名不能为空,请在主机密码处填写房间名"
)
ygopro
.
stoc_die
(
client
,
"房间名不能为空,请在主机密码处填写房间名"
)
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard_auth
and
info
.
pass
[
0
...
2
]
!=
'AI
'
else
if
info
.
pass
.
length
and
settings
.
modules
.
mycard_auth
and
info
.
pass
[
0
...
3
]
!=
'AI_'
and
info
.
pass
[
0
...
3
]
!=
'AI#
'
ygopro
.
stoc_send_chat
(
client
,
'正在读取用户信息...'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
'正在读取用户信息...'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
info
.
pass
.
length
<=
8
if
info
.
pass
.
length
<=
8
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Length)'
)
ygopro
.
stoc_die
(
client
,
'主机密码不正确 (Invalid Length)'
)
...
@@ -1086,8 +1087,10 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1086,8 +1087,10 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
url
:
settings
.
modules
.
arena_mode
.
get_score
+
encodeURIComponent
(
client
.
name
),
url
:
settings
.
modules
.
arena_mode
.
get_score
+
encodeURIComponent
(
client
.
name
),
json
:
true
json
:
true
,
(
error
,
response
,
body
)
->
,
(
error
,
response
,
body
)
->
if
error
or
!
body
or
_
.
isString
body
if
error
log
.
warn
'LOAD SCORE ERROR'
,
client
.
name
,
error
,
response
.
statusCode
,
response
.
statusMessage
,
body
log
.
warn
'LOAD SCORE ERROR'
,
client
.
name
,
error
else
if
!
body
or
_
.
isString
body
log
.
warn
'LOAD SCORE FAIL'
,
client
.
name
,
response
.
statusCode
,
response
.
statusMessage
,
body
else
else
log
.
info
'LOAD SCORE'
,
client
.
name
,
body
log
.
info
'LOAD SCORE'
,
client
.
name
,
body
rank_txt
=
if
body
.
arena_rank
>
0
then
"排名第"
+
body
.
arena_rank
else
"暂无排名"
rank_txt
=
if
body
.
arena_rank
>
0
then
"排名第"
+
body
.
arena_rank
else
"暂无排名"
...
@@ -1347,7 +1350,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
...
@@ -1347,7 +1350,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
arena
:
if
room
.
hostinfo
.
mode
==
1
then
'athletic'
else
'entertain'
arena
:
if
room
.
hostinfo
.
mode
==
1
then
'athletic'
else
'entertain'
}},
(
error
,
response
,
body
)
->
}},
(
error
,
response
,
body
)
->
if
error
if
error
log
.
warn
'DECK POST ERROR'
,
error
,
response
log
.
warn
'DECK POST ERROR'
,
error
else
else
if
response
.
statusCode
!=
200
if
response
.
statusCode
!=
200
log
.
warn
'DECK POST FAIL'
,
response
.
statusCode
,
client
.
name
,
body
log
.
warn
'DECK POST FAIL'
,
response
.
statusCode
,
client
.
name
,
body
...
@@ -1368,7 +1371,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
...
@@ -1368,7 +1371,7 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
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 显示这个帮助信息"
)
ygopro
.
stoc_send_chat
(
client
,
"/roomname 显示当前房间的名字"
)
ygopro
.
stoc_send_chat
(
client
,
"/roomname 显示当前房间的名字"
)
if
!
settings
.
modules
.
mycard_auth
ygopro
.
stoc_send_chat
(
client
,
"/ai 添加一个AI,/ai 角色名 可指定添加的角色"
)
if
settings
.
modules
.
enable_windbot
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
,
"/tip 显示一条提示"
)
if
settings
.
modules
.
tips
...
...
ygopro-server.js
View file @
a1cbc654
...
@@ -359,6 +359,7 @@
...
@@ -359,6 +359,7 @@
}
}
result
=
new
Room
(
name
);
result
=
new
Room
(
name
);
result
.
windbot
=
windbot
;
result
.
windbot
=
windbot
;
result
[
"
private
"
]
=
true
;
return
result
;
return
result
;
};
};
...
@@ -609,9 +610,9 @@
...
@@ -609,9 +610,9 @@
},
(
function
(
_this
)
{
},
(
function
(
_this
)
{
return
function
(
error
,
response
,
body
)
{
return
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
log
.
warn
(
'
SCORE POST ERROR
'
,
error
,
response
.
statusCode
,
response
.
statusMessage
,
body
);
log
.
warn
(
'
SCORE POST ERROR
'
,
error
);
}
else
{
}
else
{
if
(
response
.
statusCode
!==
204
)
{
if
(
response
.
statusCode
!==
204
||
response
.
statusCode
!==
200
)
{
log
.
warn
(
'
SCORE POST FAIL
'
,
response
.
statusCode
,
response
.
statusMessage
,
_this
.
name
,
body
);
log
.
warn
(
'
SCORE POST FAIL
'
,
response
.
statusCode
,
response
.
statusMessage
,
_this
.
name
,
body
);
}
else
{
}
else
{
log
.
info
(
'
SCORE POST OK
'
,
response
.
statusCode
,
response
.
statusMessage
,
_this
.
name
,
body
);
log
.
info
(
'
SCORE POST OK
'
,
response
.
statusCode
,
response
.
statusMessage
,
_this
.
name
,
body
);
...
@@ -701,7 +702,7 @@
...
@@ -701,7 +702,7 @@
},
(
function
(
_this
)
{
},
(
function
(
_this
)
{
return
function
(
error
,
response
,
body
)
{
return
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
log
.
warn
(
'
windbot add error
'
,
error
,
_this
.
name
,
response
);
log
.
warn
(
'
windbot add error
'
,
error
,
_this
.
name
);
ygopro
.
stoc_send_chat_to_room
(
_this
,
"
添加AI失败,可尝试输入 /ai 重新添加
"
,
ygopro
.
constants
.
COLORS
.
RED
);
ygopro
.
stoc_send_chat_to_room
(
_this
,
"
添加AI失败,可尝试输入 /ai 重新添加
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
}
};
};
...
@@ -1102,7 +1103,7 @@
...
@@ -1102,7 +1103,7 @@
client
.
destroy
();
client
.
destroy
();
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
enable_random_duel
&&
!
settings
.
modules
.
enable_windbot
)
{
}
else
if
(
!
info
.
pass
.
length
&&
!
settings
.
modules
.
enable_random_duel
&&
!
settings
.
modules
.
enable_windbot
)
{
ygopro
.
stoc_die
(
client
,
"
房间名不能为空,请在主机密码处填写房间名
"
);
ygopro
.
stoc_die
(
client
,
"
房间名不能为空,请在主机密码处填写房间名
"
);
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard_auth
&&
info
.
pass
.
slice
(
0
,
2
)
!==
'
AI
'
)
{
}
else
if
(
info
.
pass
.
length
&&
settings
.
modules
.
mycard_auth
&&
info
.
pass
.
slice
(
0
,
3
)
!==
'
AI_
'
&&
info
.
pass
.
slice
(
0
,
3
)
!==
'
AI#
'
)
{
ygopro
.
stoc_send_chat
(
client
,
'
正在读取用户信息...
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
'
正在读取用户信息...
'
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
if
(
info
.
pass
.
length
<=
8
)
{
if
(
info
.
pass
.
length
<=
8
)
{
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Length)
'
);
ygopro
.
stoc_die
(
client
,
'
主机密码不正确 (Invalid Length)
'
);
...
@@ -1316,8 +1317,10 @@
...
@@ -1316,8 +1317,10 @@
json
:
true
json
:
true
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
var
rank_txt
;
var
rank_txt
;
if
(
error
||
!
body
||
_
.
isString
(
body
))
{
if
(
error
)
{
log
.
warn
(
'
LOAD SCORE ERROR
'
,
client
.
name
,
error
,
response
.
statusCode
,
response
.
statusMessage
,
body
);
log
.
warn
(
'
LOAD SCORE ERROR
'
,
client
.
name
,
error
);
}
else
if
(
!
body
||
_
.
isString
(
body
))
{
log
.
warn
(
'
LOAD SCORE FAIL
'
,
client
.
name
,
response
.
statusCode
,
response
.
statusMessage
,
body
);
}
else
{
}
else
{
log
.
info
(
'
LOAD SCORE
'
,
client
.
name
,
body
);
log
.
info
(
'
LOAD SCORE
'
,
client
.
name
,
body
);
rank_txt
=
body
.
arena_rank
>
0
?
"
排名第
"
+
body
.
arena_rank
:
"
暂无排名
"
;
rank_txt
=
body
.
arena_rank
>
0
?
"
排名第
"
+
body
.
arena_rank
:
"
暂无排名
"
;
...
@@ -1657,7 +1660,7 @@
...
@@ -1657,7 +1660,7 @@
}
}
},
function
(
error
,
response
,
body
)
{
},
function
(
error
,
response
,
body
)
{
if
(
error
)
{
if
(
error
)
{
log
.
warn
(
'
DECK POST ERROR
'
,
error
,
response
);
log
.
warn
(
'
DECK POST ERROR
'
,
error
);
}
else
{
}
else
{
if
(
response
.
statusCode
!==
200
)
{
if
(
response
.
statusCode
!==
200
)
{
log
.
warn
(
'
DECK POST FAIL
'
,
response
.
statusCode
,
client
.
name
,
body
);
log
.
warn
(
'
DECK POST FAIL
'
,
response
.
statusCode
,
client
.
name
,
body
);
...
@@ -1687,7 +1690,9 @@
...
@@ -1687,7 +1690,9 @@
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 显示这个帮助信息
"
);
ygopro
.
stoc_send_chat
(
client
,
"
/roomname 显示当前房间的名字
"
);
if
(
!
settings
.
modules
.
mycard_auth
)
{
ygopro
.
stoc_send_chat
(
client
,
"
/roomname 显示当前房间的名字
"
);
}
if
(
settings
.
modules
.
enable_windbot
)
{
if
(
settings
.
modules
.
enable_windbot
)
{
ygopro
.
stoc_send_chat
(
client
,
"
/ai 添加一个AI,/ai 角色名 可指定添加的角色
"
);
ygopro
.
stoc_send_chat
(
client
,
"
/ai 添加一个AI,/ai 角色名 可指定添加的角色
"
);
}
}
...
...
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