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
6227f5bd
Commit
6227f5bd
authored
May 27, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MSG_RETRY detection
parent
ad0bcc57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
3 deletions
+70
-3
data/default_config.json
data/default_config.json
+4
-0
data/i18n.json
data/i18n.json
+8
-0
ygopro-server.coffee
ygopro-server.coffee
+26
-2
ygopro-server.js
ygopro-server.js
+32
-1
No files found.
data/default_config.json
View file @
6227f5bd
...
@@ -82,6 +82,10 @@
...
@@ -82,6 +82,10 @@
"chat_color"
:
{
"chat_color"
:
{
"enabled"
:
false
"enabled"
:
false
},
},
"retry_handle"
:
{
"enabled"
:
false
,
"max_retry_count"
:
3
},
"mycard"
:
{
"mycard"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"auth_base_url"
:
"https://ygobbs.com"
,
"auth_base_url"
:
"https://ygobbs.com"
,
...
...
data/i18n.json
View file @
6227f5bd
...
@@ -372,6 +372,14 @@
...
@@ -372,6 +372,14 @@
"color_not_found_part1"
:
"颜色 "
,
"color_not_found_part1"
:
"颜色 "
,
"color_not_found_part2"
:
" 不存在,输入 /color help 查看所有可用的颜色。"
,
"color_not_found_part2"
:
" 不存在,输入 /color help 查看所有可用的颜色。"
,
"show_color_list"
:
"可用的聊天字体颜色有:"
,
"show_color_list"
:
"可用的聊天字体颜色有:"
,
"retry_not_counted"
:
"你的操作不符合规则。"
,
"retry_part1"
:
"你的操作第"
,
"retry_part2"
:
"次不符合规则。若违规操作"
,
"retry_part3"
:
"次,将被请出房间。"
,
"retry_too_much_part1"
:
"你由于在决斗中违规操作"
,
"retry_too_much_part2"
:
"次,已被请出房间。"
,
"retry_too_much_room_part1"
:
" 由于在决斗中违规操作"
,
"retry_too_much_room_part2"
:
"次,已被请出房间。"
,
"athletic_arena_tip"
:
"在竞技匹配中,比赛开始前退出游戏也会视为投降。"
"athletic_arena_tip"
:
"在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
},
"ko-kr"
:
{
"ko-kr"
:
{
...
...
ygopro-server.coffee
View file @
6227f5bd
...
@@ -1351,11 +1351,32 @@ load_dialogues = () ->
...
@@ -1351,11 +1351,32 @@ load_dialogues = () ->
if
settings
.
modules
.
dialogues
.
get
if
settings
.
modules
.
dialogues
.
get
load_dialogues
()
load_dialogues
()
ygopro
.
stoc_follow
'GAME_MSG'
,
fals
e
,
(
buffer
,
info
,
client
,
server
)
->
ygopro
.
stoc_follow
'GAME_MSG'
,
tru
e
,
(
buffer
,
info
,
client
,
server
)
->
room
=
ROOM_all
[
client
.
rid
]
room
=
ROOM_all
[
client
.
rid
]
return
unless
room
return
unless
room
msg
=
buffer
.
readInt8
(
0
)
msg
=
buffer
.
readInt8
(
0
)
if
settings
.
modules
.
retry_handle
.
enabled
if
ygopro
.
constants
.
MSG
[
msg
]
==
'RETRY'
if
!
client
.
retry_count
?
client
.
retry_count
=
0
client
.
retry_count
++
log
.
warn
"MSG_RETRY detected"
,
client
.
name
,
client
.
ip
,
msg
,
client
.
retry_count
if
settings
.
modules
.
retry_handle
.
max_retry_count
and
client
.
retry_count
>=
settings
.
modules
.
retry_handle
.
max_retry_count
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"${retry_too_much_room_part1}"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"${retry_too_much_room_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"${retry_too_much_part1}"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"${retry_too_much_part2}"
,
ygopro
.
constants
.
COLORS
.
RED
)
client
.
destroy
()
return
true
if
client
.
last_game_msg
if
settings
.
modules
.
retry_handle
.
max_retry_count
ygopro
.
stoc_send_chat
(
client
,
"${retry_part1}"
+
client
.
retry_count
+
"${retry_part2}"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"${retry_part3}"
,
ygopro
.
constants
.
COLORS
.
RED
)
else
ygopro
.
stoc_send_chat
(
client
,
"${retry_not_counted}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send
(
client
,
'GAME_MSG'
,
client
.
last_game_msg
)
return
true
else
client
.
last_game_msg
=
buffer
if
(
msg
>=
10
and
msg
<
30
)
or
msg
==
132
or
(
msg
>=
140
and
msg
<
144
)
#SELECT和ANNOUNCE开头的消息
if
(
msg
>=
10
and
msg
<
30
)
or
msg
==
132
or
(
msg
>=
140
and
msg
<
144
)
#SELECT和ANNOUNCE开头的消息
room
.
waiting_for_player
=
client
room
.
waiting_for_player
=
client
room
.
last_active_time
=
moment
()
room
.
last_active_time
=
moment
()
...
@@ -1375,6 +1396,9 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
...
@@ -1375,6 +1396,9 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_final}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_final}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
else
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_extra}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_extra}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
if
settings
.
modules
.
retry_handle
.
enabled
client
.
retry_count
=
0
client
.
last_game_msg
=
null
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
...
@@ -1477,7 +1501,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
...
@@ -1477,7 +1501,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if
dialogues
.
dialogues
[
card
]
and
(
ygopro
.
constants
.
MSG
[
msg
]
!=
'CHAINING'
or
(
trigger_location
&
0x8
)
and
!
(
trigger_location
&
0x200
))
if
dialogues
.
dialogues
[
card
]
and
(
ygopro
.
constants
.
MSG
[
msg
]
!=
'CHAINING'
or
(
trigger_location
&
0x8
)
and
!
(
trigger_location
&
0x200
))
for
line
in
_
.
lines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
for
line
in
_
.
lines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
return
return
false
#房间管理
#房间管理
ygopro
.
ctos_follow
'HS_TOOBSERVER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
ygopro
.
ctos_follow
'HS_TOOBSERVER'
,
true
,
(
buffer
,
info
,
client
,
server
)
->
...
...
ygopro-server.js
View file @
6227f5bd
...
@@ -1635,13 +1635,39 @@
...
@@ -1635,13 +1635,39 @@
load_dialogues
();
load_dialogues
();
}
}
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
fals
e
,
function
(
buffer
,
info
,
client
,
server
)
{
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
tru
e
,
function
(
buffer
,
info
,
client
,
server
)
{
var
card
,
count
,
l
,
len2
,
line
,
loc
,
msg
,
playertype
,
pos
,
reason
,
ref2
,
ref3
,
ref4
,
room
,
trigger_location
,
val
,
win_pos
;
var
card
,
count
,
l
,
len2
,
line
,
loc
,
msg
,
playertype
,
pos
,
reason
,
ref2
,
ref3
,
ref4
,
room
,
trigger_location
,
val
,
win_pos
;
room
=
ROOM_all
[
client
.
rid
];
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
if
(
!
room
)
{
return
;
return
;
}
}
msg
=
buffer
.
readInt8
(
0
);
msg
=
buffer
.
readInt8
(
0
);
if
(
settings
.
modules
.
retry_handle
.
enabled
)
{
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
RETRY
'
)
{
if
(
client
.
retry_count
==
null
)
{
client
.
retry_count
=
0
;
}
client
.
retry_count
++
;
log
.
warn
(
"
MSG_RETRY detected
"
,
client
.
name
,
client
.
ip
,
msg
,
client
.
retry_count
);
if
(
settings
.
modules
.
retry_handle
.
max_retry_count
&&
client
.
retry_count
>=
settings
.
modules
.
retry_handle
.
max_retry_count
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
client
.
name
+
"
${retry_too_much_room_part1}
"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"
${retry_too_much_room_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
"
${retry_too_much_part1}
"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"
${retry_too_much_part2}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
client
.
destroy
();
return
true
;
}
if
(
client
.
last_game_msg
)
{
if
(
settings
.
modules
.
retry_handle
.
max_retry_count
)
{
ygopro
.
stoc_send_chat
(
client
,
"
${retry_part1}
"
+
client
.
retry_count
+
"
${retry_part2}
"
+
settings
.
modules
.
retry_handle
.
max_retry_count
+
"
${retry_part3}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
else
{
ygopro
.
stoc_send_chat
(
client
,
"
${retry_not_counted}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
ygopro
.
stoc_send
(
client
,
'
GAME_MSG
'
,
client
.
last_game_msg
);
return
true
;
}
}
else
{
client
.
last_game_msg
=
buffer
;
}
}
if
((
msg
>=
10
&&
msg
<
30
)
||
msg
===
132
||
(
msg
>=
140
&&
msg
<
144
))
{
if
((
msg
>=
10
&&
msg
<
30
)
||
msg
===
132
||
(
msg
>=
140
&&
msg
<
144
))
{
room
.
waiting_for_player
=
client
;
room
.
waiting_for_player
=
client
;
room
.
last_active_time
=
moment
();
room
.
last_active_time
=
moment
();
...
@@ -1664,6 +1690,10 @@
...
@@ -1664,6 +1690,10 @@
}
}
}
}
}
}
if
(
settings
.
modules
.
retry_handle
.
enabled
)
{
client
.
retry_count
=
0
;
client
.
last_game_msg
=
null
;
}
}
}
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
NEW_TURN
'
)
{
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
NEW_TURN
'
)
{
if
(
client
.
pos
===
0
)
{
if
(
client
.
pos
===
0
)
{
...
@@ -1808,6 +1838,7 @@
...
@@ -1808,6 +1838,7 @@
}
}
}
}
}
}
return
false
;
});
});
ygopro
.
ctos_follow
(
'
HS_TOOBSERVER
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
ygopro
.
ctos_follow
(
'
HS_TOOBSERVER
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
...
...
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