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
1fe34a6b
Commit
1fe34a6b
authored
Nov 29, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tcg_random
parents
d89a5238
81446259
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
267 additions
and
54 deletions
+267
-54
data/constants.json
data/constants.json
+2
-1
data/default_config.json
data/default_config.json
+6
-1
data/i18n.json
data/i18n.json
+2
-0
ygopro-server.coffee
ygopro-server.coffee
+93
-2
ygopro-server.js
ygopro-server.js
+164
-50
No files found.
data/constants.json
View file @
1fe34a6b
...
@@ -53,7 +53,8 @@
...
@@ -53,7 +53,8 @@
"32"
:
"HS_PLAYER_ENTER"
,
"32"
:
"HS_PLAYER_ENTER"
,
"33"
:
"HS_PLAYER_CHANGE"
,
"33"
:
"HS_PLAYER_CHANGE"
,
"34"
:
"HS_WATCH_CHANGE"
,
"34"
:
"HS_WATCH_CHANGE"
,
"48"
:
"FIELD_FINISH"
"48"
:
"FIELD_FINISH"
,
"49"
:
"SRVPRO_ROOMLIST"
},
},
"PLAYERCHANGE"
:{
"PLAYERCHANGE"
:{
"8"
:
"OBSERVE"
,
"8"
:
"OBSERVE"
,
...
...
data/default_config.json
View file @
1fe34a6b
...
@@ -69,6 +69,9 @@
...
@@ -69,6 +69,9 @@
"enabled"
:
true
,
"enabled"
:
true
,
"get"
:
false
"get"
:
false
},
},
"koishi_roomlist"
:
{
"enabled"
:
true
},
"vip"
:
{
"vip"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"generate_count"
:
500
"generate_count"
:
500
...
@@ -76,7 +79,9 @@
...
@@ -76,7 +79,9 @@
"random_duel"
:
{
"random_duel"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"no_rematch_check"
:
false
,
"no_rematch_check"
:
false
,
"record_match_scores"
:
true
,
"record_match_scores"
:
false
,
"post_match_scores"
:
false
,
"post_match_accesskey"
:
"123456"
,
"blank_pass_match"
:
true
,
"blank_pass_match"
:
true
,
"ready_time"
:
20
,
"ready_time"
:
20
,
"hang_timeout"
:
90
"hang_timeout"
:
90
...
...
data/i18n.json
View file @
1fe34a6b
...
@@ -89,6 +89,7 @@
...
@@ -89,6 +89,7 @@
"chat_order_vip_dialogues"
:
"/vip dialogues CARD_CODE DIALOGUE to set a dialogue for a specific card"
,
"chat_order_vip_dialogues"
:
"/vip dialogues CARD_CODE DIALOGUE to set a dialogue for a specific card"
,
"chat_order_vip_words"
:
"/vip words WORD to set your word when joining in the server"
,
"chat_order_vip_words"
:
"/vip words WORD to set your word when joining in the server"
,
"chat_order_vip_victory"
:
"/vip victory WORD to set your word when you win a duel"
,
"chat_order_vip_victory"
:
"/vip victory WORD to set your word when you win a duel"
,
"koishi_roomlist_hint"
:
"Checking room list ..."
,
"room_name"
:
"Room name is"
,
"room_name"
:
"Room name is"
,
"banned_chat_tip"
:
"You are banned from chatting."
,
"banned_chat_tip"
:
"You are banned from chatting."
,
"banned_duel_tip"
:
"You are banned from the random duel system for sending inappropriate messages."
,
"banned_duel_tip"
:
"You are banned from the random duel system for sending inappropriate messages."
,
...
@@ -421,6 +422,7 @@
...
@@ -421,6 +422,7 @@
"chat_order_vip_dialogues"
:
"/vip dialogues 卡号 台词 设置特定卡的召唤台词"
,
"chat_order_vip_dialogues"
:
"/vip dialogues 卡号 台词 设置特定卡的召唤台词"
,
"chat_order_vip_words"
:
"/vip words 台词 设置自己的进场台词"
,
"chat_order_vip_words"
:
"/vip words 台词 设置自己的进场台词"
,
"chat_order_vip_victory"
:
"/vip victory 台词 设置自己的胜利台词"
,
"chat_order_vip_victory"
:
"/vip victory 台词 设置自己的胜利台词"
,
"koishi_roomlist_hint"
:
"正在获取房间列表……"
,
"room_name"
:
"您当前的房间名是"
,
"room_name"
:
"您当前的房间名是"
,
"banned_chat_tip"
:
"您已被禁言!"
,
"banned_chat_tip"
:
"您已被禁言!"
,
"banned_duel_tip"
:
"您的发言存在严重不适当的内容,禁止您使用随机对战功能!"
,
"banned_duel_tip"
:
"您的发言存在严重不适当的内容,禁止您使用随机对战功能!"
,
...
...
ygopro-server.coffee
View file @
1fe34a6b
...
@@ -528,7 +528,7 @@ ROOM_player_get_score = (player)->
...
@@ -528,7 +528,7 @@ ROOM_player_get_score = (player)->
score
=
ROOM_players_scores
[
name
]
score
=
ROOM_players_scores
[
name
]
if
!
score
if
!
score
return
"
#{
player
.
name
}
${random_score_blank}"
return
"
#{
player
.
name
}
${random_score_blank}"
total
=
score
.
win
+
score
.
lose
+
score
.
flee
total
=
score
.
win
+
score
.
lose
if
score
.
win
<
2
and
total
<
3
if
score
.
win
<
2
and
total
<
3
return
"
#{
player
.
name
}
${random_score_not_enough}"
return
"
#{
player
.
name
}
${random_score_not_enough}"
if
score
.
combo
>=
2
if
score
.
combo
>=
2
...
@@ -538,6 +538,28 @@ ROOM_player_get_score = (player)->
...
@@ -538,6 +538,28 @@ ROOM_player_get_score = (player)->
return
"${random_score_part1}
#{
player
.
name
}
${random_score_part2}
#{
Math
.
ceil
(
score
.
win
/
total
*
100
)
}
${random_score_part3}
#{
Math
.
ceil
(
score
.
flee
/
total
*
100
)
}
${random_score_part4}"
return
"${random_score_part1}
#{
player
.
name
}
${random_score_part2}
#{
Math
.
ceil
(
score
.
win
/
total
*
100
)
}
${random_score_part3}
#{
Math
.
ceil
(
score
.
flee
/
total
*
100
)
}
${random_score_part4}"
return
return
if
settings
.
modules
.
random_duel
.
post_match_scores
setInterval
(()
->
scores_pair
=
_
.
pairs
ROOM_players_scores
scores_by_lose
=
_
.
sortBy
(
scores_pair
,
(
score
)
->
return
score
[
1
].
lose
).
reverse
()
# 败场由高到低
scores_by_win
=
_
.
sortBy
(
scores_by_lose
,
(
score
)
->
return
score
[
1
].
win
).
reverse
()
# 然后胜场由低到高,再逆转,就是先排胜场再排败场
scores
=
_
.
first
(
scores_by_win
,
10
)
#log.info scores
request
.
post
{
url
:
settings
.
modules
.
random_duel
.
post_match_scores
,
form
:
{
accesskey
:
settings
.
modules
.
random_duel
.
post_match_accesskey
,
rank
:
JSON
.
stringify
(
scores
)
}},
(
error
,
response
,
body
)
=>
if
error
log
.
warn
'RANDOM SCORE POST ERROR'
,
error
else
if
response
.
statusCode
!=
204
and
response
.
statusCode
!=
200
log
.
warn
'RANDOM SCORE POST FAIL'
,
response
.
statusCode
,
response
.
statusMessage
,
body
#else
# log.info 'RANDOM SCORE POST OK', response.statusCode, response.statusMessage
return
return
,
60000
)
ROOM_find_or_create_by_name
=
(
name
,
player_ip
)
->
ROOM_find_or_create_by_name
=
(
name
,
player_ip
)
->
uname
=
name
.
toUpperCase
()
uname
=
name
.
toUpperCase
()
if
settings
.
modules
.
windbot
.
enabled
and
(
uname
[
0
...
2
]
==
'AI'
or
(
!
settings
.
modules
.
random_duel
.
enabled
and
uname
==
''
))
if
settings
.
modules
.
windbot
.
enabled
and
(
uname
[
0
...
2
]
==
'AI'
or
(
!
settings
.
modules
.
random_duel
.
enabled
and
uname
==
''
))
...
@@ -1381,6 +1403,7 @@ class Room
...
@@ -1381,6 +1403,7 @@ class Room
@
scores
[
client
.
name_vpass
]
=
-
9
@
scores
[
client
.
name_vpass
]
=
-
9
if
@
random_type
and
not
client
.
flee_free
and
(
!
settings
.
modules
.
reconnect
.
enabled
or
@
get_disconnected_count
()
==
0
)
if
@
random_type
and
not
client
.
flee_free
and
(
!
settings
.
modules
.
reconnect
.
enabled
or
@
get_disconnected_count
()
==
0
)
ROOM_ban_player
(
client
.
name
,
client
.
ip
,
"${random_ban_reason_flee}"
)
ROOM_ban_player
(
client
.
name
,
client
.
ip
,
"${random_ban_reason_flee}"
)
if
settings
.
modules
.
random_duel
.
record_match_scores
and
@
random_type
==
'M'
ROOM_player_flee
(
client
.
name_vpass
)
ROOM_player_flee
(
client
.
name_vpass
)
if
@
players
.
length
and
!
(
@
windbot
and
client
.
is_host
)
and
!
(
@
arena
and
!
@
started
and
client
.
pos
<=
3
)
if
@
players
.
length
and
!
(
@
windbot
and
client
.
is_host
)
and
!
(
@
arena
and
!
@
started
and
client
.
pos
<=
3
)
ygopro
.
stoc_send_chat_to_room
this
,
"
#{
client
.
name
}
${left_game}"
+
if
error
then
":
#{
error
}
"
else
''
ygopro
.
stoc_send_chat_to_room
this
,
"
#{
client
.
name
}
${left_game}"
+
if
error
then
":
#{
error
}
"
else
''
...
@@ -1746,6 +1769,74 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -1746,6 +1769,74 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
CLIENT_kick
(
client
)
CLIENT_kick
(
client
)
return
),
500
return
),
500
else
if
info
.
pass
.
toUpperCase
()
==
"L"
and
settings
.
modules
.
koishi_roomlist
.
enabled
ygopro
.
stoc_send_chat
(
client
,
"${koishi_roomlist_hint}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
room_showed
=
[]
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
name
.
indexOf
(
'$'
)
<
0
room_showed
.
push
(
room
)
buffer_pos
=
0
room_buffer
=
Buffer
.
alloc
(
2
+
333
*
room_showed
.
length
)
room_buffer
.
writeUInt16LE
(
room_showed
.
length
,
buffer_pos
)
buffer_pos
+=
2
for
room
in
room_showed
room_buffer
.
write
(
room
.
name
,
buffer_pos
,
64
,
"utf8"
)
buffer_pos
+=
64
oppo_pos
=
if
room
.
hostinfo
.
mode
==
2
then
2
else
1
room_buffer
.
writeUInt8
((
if
!
room
.
started
then
0
else
if
room
.
changing_side
then
2
else
1
),
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt8
(
room
.
duel_count
,
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt8
((
if
room
.
turn
?
then
room
.
turn
else
0
),
buffer_pos
)
buffer_pos
++
room_players
=
[]
for
player
in
room
.
get_playing_player
()
when
player
room_players
[
player
.
pos
]
=
player
player_string
=
"???"
if
room_players
[
0
]
player_string
=
room_players
[
0
].
name
if
room
.
hostinfo
.
mode
==
2
player_string
=
player_string
+
"+"
+
(
if
room_players
[
1
]
then
room_players
[
1
].
name
else
"???"
)
room_buffer
.
write
(
player_string
,
buffer_pos
,
128
,
"utf8"
)
buffer_pos
+=
128
if
room
.
started
room_buffer
.
writeInt8
((
if
room
.
scores
[
room_players
[
0
].
name_vpass
]
?
then
room
.
scores
[
room_players
[
0
].
name_vpass
]
else
0
),
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt32LE
((
if
room_players
[
0
].
lp
?
then
room_players
[
0
].
lp
else
room
.
hostinfo
.
start_lp
),
buffer_pos
)
buffer_pos
+=
4
else
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt32LE
(
0
,
buffer_pos
)
buffer_pos
+=
4
player_string
=
"???"
if
room_players
[
oppo_pos
]
player_string
=
room_players
[
oppo_pos
].
name
if
room
.
hostinfo
.
mode
==
2
player_string
=
player_string
+
"+"
+
(
if
room_players
[
oppo_pos
+
1
]
then
room_players
[
oppo_pos
+
1
].
name
else
"???"
)
room_buffer
.
write
(
player_string
,
buffer_pos
,
128
,
"utf8"
)
buffer_pos
+=
128
if
room
.
started
room_buffer
.
writeInt8
((
if
room
.
scores
[
room_players
[
oppo_pos
].
name_vpass
]
?
then
room
.
scores
[
room_players
[
oppo_pos
].
name_vpass
]
else
0
),
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt32LE
((
if
room_players
[
oppo_pos
].
lp
?
then
room_players
[
oppo_pos
].
lp
else
room
.
hostinfo
.
start_lp
),
buffer_pos
)
buffer_pos
+=
4
else
room_buffer
.
writeInt8
(
0
,
buffer_pos
)
buffer_pos
++
room_buffer
.
writeInt32LE
(
0
,
buffer_pos
)
buffer_pos
+=
4
#console.log(room_buffer.length)
ygopro
.
stoc_send
(
client
,
"SRVPRO_ROOMLIST"
,
room_buffer
)
setTimeout
(()
->
ygopro
.
stoc_send
client
,
'ERROR_MSG'
,{
msg
:
1
code
:
9
}
CLIENT_kick
(
client
)
return
),
500
else
if
info
.
pass
[
0
...
2
].
toUpperCase
()
==
"R#"
and
settings
.
modules
.
cloud_replay
.
enabled
else
if
info
.
pass
[
0
...
2
].
toUpperCase
()
==
"R#"
and
settings
.
modules
.
cloud_replay
.
enabled
replay_id
=
info
.
pass
.
split
(
"#"
)[
1
]
replay_id
=
info
.
pass
.
split
(
"#"
)[
1
]
if
(
replay_id
>
0
and
replay_id
<=
9
)
if
(
replay_id
>
0
and
replay_id
<=
9
)
...
...
ygopro-server.js
View file @
1fe34a6b
This diff is collapsed.
Click to expand it.
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