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
80861d83
Commit
80861d83
authored
Jul 15, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test duel log
parent
064e1a97
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
16 deletions
+73
-16
.gitignore
.gitignore
+1
-0
config.json
config.json
+1
-0
ygopro-server.coffee
ygopro-server.coffee
+27
-4
ygopro-server.js
ygopro-server.js
+44
-12
No files found.
.gitignore
View file @
80861d83
# ignore
# ignore
jsconfig.json
jsconfig.json
coffeelint.json
coffeelint.json
.vscode/
password.json
password.json
config.*.json
config.*.json
...
...
config.json
View file @
80861d83
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
"tournament_mode"
:
{
"tournament_mode"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"deck_path"
:
"./decks/"
,
"deck_path"
:
"./decks/"
,
"duel_log"
:
[],
"password"
:
"123456"
,
"password"
:
"123456"
,
"port"
:
7933
"port"
:
7933
},
},
...
...
ygopro-server.coffee
View file @
80861d83
...
@@ -1110,14 +1110,14 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
...
@@ -1110,14 +1110,14 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
client
.
lp
=
room
.
hostinfo
.
start_lp
client
.
lp
=
room
.
hostinfo
.
start_lp
#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}")
###
if ygopro.constants.MSG[msg] == 'WIN' and
_.startsWith(room.name, 'M#') and
client.is_host
if
ygopro
.
constants
.
MSG
[
msg
]
==
'WIN'
and
client
.
is_host
pos
=
buffer
.
readUInt8
(
1
)
pos
=
buffer
.
readUInt8
(
1
)
pos
=
1
-
pos
unless
client
.
is_first
or
pos
==
2
pos
=
1
-
pos
unless
client
.
is_first
or
pos
==
2
reason
=
buffer
.
readUInt8
(
2
)
reason
=
buffer
.
readUInt8
(
2
)
#log.info {winner: pos, reason: reason}
#log.info {winner: pos, reason: reason}
room.duels.push {winner: pos, reason: reason}
#
room.duels.push {winner: pos, reason: reason}
###
room
.
winner
=
pos
#lp跟踪
#lp跟踪
if
ygopro
.
constants
.
MSG
[
msg
]
==
'DAMAGE'
and
client
.
is_host
if
ygopro
.
constants
.
MSG
[
msg
]
==
'DAMAGE'
and
client
.
is_host
...
@@ -1433,6 +1433,19 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
...
@@ -1433,6 +1433,19 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
room
=
ROOM_all
[
client
.
rid
]
room
=
ROOM_all
[
client
.
rid
]
return
settings
.
modules
.
tournament_mode
.
enabled
unless
room
return
settings
.
modules
.
tournament_mode
.
enabled
unless
room
if
settings
.
modules
.
tournament_mode
.
enabled
if
settings
.
modules
.
tournament_mode
.
enabled
if
client
.
is_host
log
=
{
time
:
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
),
name
:
room
.
name
,
roomid
:
room
.
port
.
toString
(),
cloud_replay_id
:
"R#"
+
room
.
cloud_replay_id
,
players
:
(
for
player
in
room
.
players
name
:
player
.
name
,
winner
:
player
.
pos
==
room
.
winner
)
}
settings
.
modules
.
tournament_mode
.
duel_log
.
push
log
nconf
.
myset
(
settings
,
"modules:tournament_mode:duel_log"
,
settings
.
modules
.
tournament_mode
.
duel_log
)
ygopro
.
stoc_send_chat
(
client
,
"本场比赛云录像:R#
#{
room
.
cloud_replay_id
}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"本场比赛云录像:R#
#{
room
.
cloud_replay_id
}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
true
return
true
else
else
...
@@ -1480,6 +1493,16 @@ if settings.modules.http
...
@@ -1480,6 +1493,16 @@ if settings.modules.http
)
)
response
.
end
(
u
.
query
.
callback
+
"( "
+
roomsjson
+
" );"
)
response
.
end
(
u
.
query
.
callback
+
"( "
+
roomsjson
+
" );"
)
else
if
u
.
pathname
==
'/api/duellog'
and
settings
.
modules
.
tournament_mode
.
enabled
if
!
pass_validated
response
.
writeHead
(
200
)
response
.
end
(
"密码错误"
)
return
else
response
.
writeHead
(
200
)
duellog
=
JSON
.
stringify
settings
.
modules
.
tournament_mode
.
duel_log
response
.
end
(
u
.
query
.
callback
+
"( "
+
duellog
+
" );"
)
else
if
u
.
pathname
==
'/api/message'
else
if
u
.
pathname
==
'/api/message'
if
!
pass_validated
if
!
pass_validated
response
.
writeHead
(
200
)
response
.
writeHead
(
200
)
...
...
ygopro-server.js
View file @
80861d83
...
@@ -1322,7 +1322,7 @@
...
@@ -1322,7 +1322,7 @@
}
}
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
false
,
function
(
buffer
,
info
,
client
,
server
)
{
var
card
,
k
,
len
,
line
,
msg
,
playertype
,
pos
,
ref
,
ref1
,
ref2
,
room
,
val
;
var
card
,
k
,
len
,
line
,
msg
,
playertype
,
pos
,
re
ason
,
re
f
,
ref1
,
ref2
,
room
,
val
;
room
=
ROOM_all
[
client
.
rid
];
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
if
(
!
room
)
{
return
;
return
;
...
@@ -1337,15 +1337,14 @@
...
@@ -1337,15 +1337,14 @@
client
.
is_first
=
!
(
playertype
&
0xf
);
client
.
is_first
=
!
(
playertype
&
0xf
);
client
.
lp
=
room
.
hostinfo
.
start_lp
;
client
.
lp
=
room
.
hostinfo
.
start_lp
;
}
}
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
WIN
'
&&
client
.
is_host
)
{
/*
pos
=
buffer
.
readUInt8
(
1
);
if ygopro.constants.MSG[msg] == 'WIN' and _.startsWith(room.name, 'M#') and client.is_host
if
(
!
(
client
.
is_first
||
pos
===
2
))
{
pos = buffer.readUInt8(1)
pos
=
1
-
pos
;
pos = 1 - pos unless client.is_first or pos == 2
}
reason = buffer.readUInt8(2)
reason
=
buffer
.
readUInt8
(
2
);
#log.info {winner: pos, reason: reason}
room
.
winner
=
pos
;
room.duels.push {winner: pos, reason: reason}
}
*/
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
DAMAGE
'
&&
client
.
is_host
)
{
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
DAMAGE
'
&&
client
.
is_host
)
{
pos
=
buffer
.
readUInt8
(
1
);
pos
=
buffer
.
readUInt8
(
1
);
if
(
!
client
.
is_first
)
{
if
(
!
client
.
is_first
)
{
...
@@ -1801,12 +1800,35 @@
...
@@ -1801,12 +1800,35 @@
});
});
ygopro
.
stoc_follow
(
'
REPLAY
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
ygopro
.
stoc_follow
(
'
REPLAY
'
,
true
,
function
(
buffer
,
info
,
client
,
server
)
{
var
room
;
var
player
,
room
;
room
=
ROOM_all
[
client
.
rid
];
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
if
(
!
room
)
{
return
settings
.
modules
.
tournament_mode
.
enabled
;
return
settings
.
modules
.
tournament_mode
.
enabled
;
}
}
if
(
settings
.
modules
.
tournament_mode
.
enabled
)
{
if
(
settings
.
modules
.
tournament_mode
.
enabled
)
{
if
(
client
.
is_host
)
{
log
=
{
time
:
moment
().
format
(
'
YYYY-MM-DD HH:mm:ss
'
),
name
:
room
.
name
,
roomid
:
room
.
port
.
toString
(),
cloud_replay_id
:
"
R#
"
+
room
.
cloud_replay_id
,
players
:
(
function
()
{
var
k
,
len
,
ref
,
results
;
ref
=
room
.
players
;
results
=
[];
for
(
k
=
0
,
len
=
ref
.
length
;
k
<
len
;
k
++
)
{
player
=
ref
[
k
];
results
.
push
({
name
:
player
.
name
,
winner
:
player
.
pos
===
room
.
winner
});
}
return
results
;
})()
};
settings
.
modules
.
tournament_mode
.
duel_log
.
push
(
log
);
nconf
.
myset
(
settings
,
"
modules:tournament_mode:duel_log
"
,
settings
.
modules
.
tournament_mode
.
duel_log
);
}
ygopro
.
stoc_send_chat
(
client
,
"
本场比赛云录像:R#
"
+
room
.
cloud_replay_id
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
"
本场比赛云录像:R#
"
+
room
.
cloud_replay_id
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -1835,7 +1857,7 @@
...
@@ -1835,7 +1857,7 @@
if
(
settings
.
modules
.
http
)
{
if
(
settings
.
modules
.
http
)
{
requestListener
=
function
(
request
,
response
)
{
requestListener
=
function
(
request
,
response
)
{
var
k
,
len
,
parseQueryString
,
pass_validated
,
player
,
room
,
roomsjson
,
u
;
var
duellog
,
k
,
len
,
parseQueryString
,
pass_validated
,
player
,
room
,
roomsjson
,
u
;
parseQueryString
=
true
;
parseQueryString
=
true
;
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
pass_validated
=
u
.
query
.
pass
===
settings
.
modules
.
http
.
password
;
...
@@ -1882,6 +1904,16 @@
...
@@ -1882,6 +1904,16 @@
});
});
response
.
end
(
u
.
query
.
callback
+
"
(
"
+
roomsjson
+
"
);
"
);
response
.
end
(
u
.
query
.
callback
+
"
(
"
+
roomsjson
+
"
);
"
);
}
}
}
else
if
(
u
.
pathname
===
'
/api/duellog
'
&&
settings
.
modules
.
tournament_mode
.
enabled
)
{
if
(
!
pass_validated
)
{
response
.
writeHead
(
200
);
response
.
end
(
"
密码错误
"
);
return
;
}
else
{
response
.
writeHead
(
200
);
duellog
=
JSON
.
stringify
(
settings
.
modules
.
tournament_mode
.
duel_log
);
response
.
end
(
u
.
query
.
callback
+
"
(
"
+
duellog
+
"
);
"
);
}
}
else
if
(
u
.
pathname
===
'
/api/message
'
)
{
}
else
if
(
u
.
pathname
===
'
/api/message
'
)
{
if
(
!
pass_validated
)
{
if
(
!
pass_validated
)
{
response
.
writeHead
(
200
);
response
.
writeHead
(
200
);
...
...
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