Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-match
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
MyCard
ygopro-match
Commits
8cf45e48
You need to sign in or sign up before continuing.
Commit
8cf45e48
authored
Oct 20, 2018
by
IamI
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'drop-reline' into arena
parents
a5e4a6f2
8c41d407
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
main.js
main.js
+6
-6
No files found.
main.js
View file @
8cf45e48
...
@@ -31,7 +31,7 @@ let getUserConfig = function (user, callback) {
...
@@ -31,7 +31,7 @@ let getUserConfig = function (user, callback) {
// Kick out
// Kick out
errorUser
(
user
);
errorUser
(
user
);
}
}
else
if
(
res
.
statusCode
!=
200
)
{
else
if
(
res
.
statusCode
!=
=
200
)
{
try
{
try
{
localLog
(
"
failed to load user data for
"
+
user
.
username
+
"
with code
"
+
res
.
statusCode
);
localLog
(
"
failed to load user data for
"
+
user
.
username
+
"
with code
"
+
res
.
statusCode
);
localLog
(
"
response:
"
+
JSON
.
stringify
(
res
)
+
"
\n
BODY:
"
+
body
);
localLog
(
"
response:
"
+
JSON
.
stringify
(
res
)
+
"
\n
BODY:
"
+
body
);
...
@@ -196,7 +196,7 @@ let pair = function (userARes, userBRes, serverName) {
...
@@ -196,7 +196,7 @@ let pair = function (userARes, userBRes, serverName) {
let
servers
=
config
.
servers
;
let
servers
=
config
.
servers
;
let
server
=
servers
[
serverName
];
let
server
=
servers
[
serverName
];
if
(
Object
.
prototype
.
toString
.
call
(
server
)
===
'
[object Array]
'
)
if
(
Object
.
prototype
.
toString
.
call
(
server
)
===
'
[object Array]
'
)
server
=
server
[
Math
.
random
()
*
server
.
length
]
server
=
server
[
Math
.
random
()
*
server
.
length
]
;
let
room_id
=
crypto
.
randomBytes
(
6
).
toString
(
'
base64
'
).
slice
(
0
,
11
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
);
let
room_id
=
crypto
.
randomBytes
(
6
).
toString
(
'
base64
'
).
slice
(
0
,
11
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
);
let
options_buffer
=
new
Buffer
(
6
);
let
options_buffer
=
new
Buffer
(
6
);
options_buffer
.
writeUInt8
(
4
<<
4
,
1
);
options_buffer
.
writeUInt8
(
4
<<
4
,
1
);
...
@@ -271,7 +271,7 @@ let closedUser = function (res, pool) {
...
@@ -271,7 +271,7 @@ let closedUser = function (res, pool) {
let
index
=
-
1
;
let
index
=
-
1
;
// 查询用户是否已在匹配池中
// 查询用户是否已在匹配池中
for
(
let
i
=
0
;
i
<
pool
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
pool
.
length
;
i
++
)
if
(
pool
[
i
].
client
==
res
)
if
(
pool
[
i
].
client
==
=
res
)
index
=
i
;
index
=
i
;
// 若用户已在匹配池中,移除
// 若用户已在匹配池中,移除
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
...
@@ -310,14 +310,14 @@ let timeoutUser = function(user) {
...
@@ -310,14 +310,14 @@ let timeoutUser = function(user) {
// 计算预期时间
// 计算预期时间
let
calculatePredictedTime
=
function
()
{
let
calculatePredictedTime
=
function
()
{
if
(
entertainRequestCountInTime
==
0
)
if
(
entertainRequestCountInTime
==
=
0
)
predictedEntertainTime
=
600
;
predictedEntertainTime
=
600
;
else
{
else
{
predictedEntertainTime
=
600
/
entertainRequestCountInTime
;
predictedEntertainTime
=
600
/
entertainRequestCountInTime
;
entertainRequestCountInTime
=
0
;
entertainRequestCountInTime
=
0
;
}
}
localLog
(
"
entertain adjust predicted time to
"
+
predictedEntertainTime
+
"
s.
"
);
localLog
(
"
entertain adjust predicted time to
"
+
predictedEntertainTime
+
"
s.
"
);
if
(
athleticRequestCountInTime
==
0
)
if
(
athleticRequestCountInTime
==
=
0
)
predictedAthleticTime
=
600
;
predictedAthleticTime
=
600
;
else
{
else
{
predictedAthleticTime
=
600
/
athleticRequestCountInTime
;
predictedAthleticTime
=
600
/
athleticRequestCountInTime
;
...
@@ -371,7 +371,7 @@ let matchResponse = function(req, res) {
...
@@ -371,7 +371,7 @@ let matchResponse = function(req, res) {
joinPool
(
res
,
ans
,
pool
);
joinPool
(
res
,
ans
,
pool
);
});
});
// 统计器
// 统计器
if
(
arg
.
arena
==
'
athletic
'
)
athleticRequestCountInTime
+=
1
;
if
(
arg
.
arena
==
=
'
athletic
'
)
athleticRequestCountInTime
+=
1
;
else
entertainRequestCountInTime
+=
1
;
else
entertainRequestCountInTime
+=
1
;
}
}
catch
(
error
)
{
catch
(
error
)
{
...
...
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