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
5855be9b
Commit
5855be9b
authored
Dec 19, 2016
by
Peter Xin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add server differ.
parent
95789df3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
configSample.json
configSample.json
+21
-0
main.js
main.js
+7
-5
No files found.
configSample.json
0 → 100644
View file @
5855be9b
{
"servers"
:
{
"entertain"
:
{
"address"
:
"127.0.0.1"
,
"port"
:
"9999"
},
"athletic"
:
{
"address"
:
"127.0.0.1"
,
"port"
:
"9998"
}
},
"arena"
:
{
"address"
:
"http://path/to/query?username="
},
"match"
:
{
"timeInterval"
:
10000
,
"athleticTrueSkillGate"
:
0.4
,
"entertainExpGate"
:
100
,
"atheleticPtGate"
:
50
}
}
\ No newline at end of file
main.js
View file @
5855be9b
...
@@ -93,7 +93,7 @@ let updateAthleticMatch = function() {
...
@@ -93,7 +93,7 @@ let updateAthleticMatch = function() {
break
;
break
;
if
(
masks
[
value
.
i
]
||
masks
[
value
.
j
])
if
(
masks
[
value
.
i
]
||
masks
[
value
.
j
])
continue
;
continue
;
pair
(
athleticUserPool
[
value
.
i
].
client
,
athleticUserPool
[
value
.
j
].
client
);
pair
(
athleticUserPool
[
value
.
i
].
client
,
athleticUserPool
[
value
.
j
].
client
,
'
athletic
'
);
masks
[
value
.
i
]
=
true
;
masks
[
value
.
i
]
=
true
;
masks
[
value
.
j
]
=
true
;
masks
[
value
.
j
]
=
true
;
}
}
...
@@ -126,7 +126,7 @@ updateAthleticMatch = function () {
...
@@ -126,7 +126,7 @@ updateAthleticMatch = function () {
// 若 exp 之差小于门限,则匹配房间
// 若 exp 之差小于门限,则匹配房间
if
(
userA
.
data
.
pt
-
userB
.
data
.
pt
<
config
.
match
.
atheleticPtGate
)
if
(
userA
.
data
.
pt
-
userB
.
data
.
pt
<
config
.
match
.
atheleticPtGate
)
{
{
pair
(
userA
.
client
,
userB
.
client
);
pair
(
userA
.
client
,
userB
.
client
,
'
athletic
'
);
i
+=
1
;
i
+=
1
;
}
}
// 否则留存
// 否则留存
...
@@ -160,7 +160,7 @@ let updateEntertainMatch = function () {
...
@@ -160,7 +160,7 @@ let updateEntertainMatch = function () {
// 若 exp 之差小于门限,则匹配房间
// 若 exp 之差小于门限,则匹配房间
if
(
userA
.
data
.
exp
-
userB
.
data
.
exp
<
config
.
match
.
entertainExpGate
)
if
(
userA
.
data
.
exp
-
userB
.
data
.
exp
<
config
.
match
.
entertainExpGate
)
{
{
pair
(
userA
.
client
,
userB
.
client
);
pair
(
userA
.
client
,
userB
.
client
,
'
entertain
'
);
i
+=
1
;
i
+=
1
;
}
}
// 否则留存
// 否则留存
...
@@ -176,9 +176,11 @@ let update = function () {
...
@@ -176,9 +176,11 @@ let update = function () {
};
};
// 为两名玩家匹配房间
// 为两名玩家匹配房间
let
pair
=
function
(
userARes
,
userBRes
)
{
let
pair
=
function
(
userARes
,
userBRes
,
serverName
)
{
let
servers
=
config
.
servers
;
let
servers
=
config
.
servers
;
let
server
=
servers
[
Math
.
floor
(
Math
.
random
()
*
servers
.
length
)];
let
server
=
servers
[
serverName
];
if
(
Object
.
prototype
.
toString
.
call
(
server
)
===
'
[object Array]
'
)
server
=
server
[
Math
.
random
()
*
server
.
length
]
let
room_id
=
crypto
.
randomBytes
(
9
).
toString
(
'
base64
'
).
slice
(
0
,
11
).
replace
(
'
+
'
,
'
-
'
).
replace
(
'
/
'
,
'
_
'
);
let
room_id
=
crypto
.
randomBytes
(
9
).
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
);
...
...
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