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
c51e57a9
Commit
c51e57a9
authored
Apr 29, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rearrange death
parent
29861e81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
100 deletions
+128
-100
data/default_config.json
data/default_config.json
+1
-1
ygopro-server.coffee
ygopro-server.coffee
+52
-41
ygopro-server.js
ygopro-server.js
+75
-58
No files found.
data/default_config.json
View file @
c51e57a9
...
...
@@ -283,7 +283,7 @@
"public_roomlist"
:
false
,
"show_ip"
:
false
,
"show_info"
:
true
,
"quick_death_rule"
:
false
,
"quick_death_rule"
:
2
,
"ssl"
:
{
"enabled"
:
false
,
"port"
:
7923
,
...
...
ygopro-server.coffee
View file @
c51e57a9
...
...
@@ -1363,6 +1363,52 @@ class Room
client
.
server
.
destroy
()
return
start_death
:
()
->
unless
@
established
and
@
started
and
!
@
death
return
false
oppo_pos
=
if
@
hostinfo
.
mode
==
2
then
2
else
1
if
!
@
changing_side
and
(
!
@
duel_count
or
@
turn
)
# Extra duel started in duel
switch
settings
.
modules
.
http
.
quick_death_rule
when
3
@
death
=
-
2
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start_phase}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
@
death
=
(
if
@
turn
then
@
turn
+
4
else
5
)
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
# Extra duel started in siding
switch
settings
.
modules
.
http
.
quick_death_rule
when
2
,
3
if
@
scores
[
@
dueling_players
[
0
].
name_vpass
]
==
@
scores
[
@
dueling_players
[
oppo_pos
].
name_vpass
]
if
settings
.
modules
.
http
.
quick_death_rule
==
3
@
death
=
-
1
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start_quick}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
@
death
=
5
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start_siding}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
win_pos
=
if
@
scores
[
@
dueling_players
[
0
].
name_vpass
]
>
@
scores
[
@
dueling_players
[
oppo_pos
].
name_vpass
]
then
0
else
oppo_pos
@
finished_by_death
=
true
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death2_finish_part1}"
+
@
dueling_players
[
win_pos
].
name
+
"${death2_finish_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
CLIENT_send_replays
(
@
dueling_players
[
oppo_pos
-
win_pos
],
this
)
if
@
hostinfo
.
mode
==
1
ygopro
.
stoc_send
(
@
dueling_players
[
oppo_pos
-
win_pos
],
'DUEL_END'
)
ygopro
.
stoc_send
(
@
dueling_players
[
oppo_pos
-
win_pos
+
1
],
'DUEL_END'
)
if
@
hostinfo
.
mode
==
2
@
scores
[
@
dueling_players
[
oppo_pos
-
win_pos
].
name_vpass
]
=
-
1
CLIENT_kick
(
@
dueling_players
[
oppo_pos
-
win_pos
])
CLIENT_kick
(
@
dueling_players
[
oppo_pos
-
win_pos
+
1
])
if
@
hostinfo
.
mode
==
2
when
1
@
death
=
-
1
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start_quick}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
@
death
=
5
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_start_siding}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
true
cancel_death
:
()
->
unless
@
established
and
@
started
and
@
death
return
false
@
death
=
0
ygopro
.
stoc_send_chat_to_room
(
this
,
"${death_cancel}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
return
true
# 网络连接
net
.
createServer
(
client
)
->
...
...
@@ -3529,43 +3575,9 @@ if settings.modules.http
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['密码错误', 0]"
))
return
death_room_found
=
false
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
!
room
.
death
and
(
u
.
query
.
death
==
"all"
or
u
.
query
.
death
==
room
.
process_pid
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
death_room_found
=
true
oppo_pos
=
if
room
.
hostinfo
.
mode
==
2
then
2
else
1
if
!
room
.
changing_side
and
(
!
room
.
duel_count
or
room
.
turn
)
switch
settings
.
modules
.
http
.
quick_death_rule
when
3
room
.
death
=
-
2
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_phase}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
room
.
death
=
(
if
room
.
turn
then
room
.
turn
+
4
else
5
)
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
switch
settings
.
modules
.
http
.
quick_death_rule
when
2
,
3
if
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
==
room
.
scores
[
room
.
dueling_players
[
oppo_pos
].
name_vpass
]
if
settings
.
modules
.
http
.
quick_death_rule
==
3
room
.
death
=
-
1
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_quick}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
room
.
death
=
5
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_siding}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
win_pos
=
if
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
>
room
.
scores
[
room
.
dueling_players
[
oppo_pos
].
name_vpass
]
then
0
else
oppo_pos
room
.
finished_by_death
=
true
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death2_finish_part1}"
+
room
.
dueling_players
[
win_pos
].
name
+
"${death2_finish_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
CLIENT_send_replays
(
room
.
dueling_players
[
oppo_pos
-
win_pos
],
room
)
if
room
.
hostinfo
.
mode
==
1
ygopro
.
stoc_send
(
room
.
dueling_players
[
oppo_pos
-
win_pos
],
'DUEL_END'
)
ygopro
.
stoc_send
(
room
.
dueling_players
[
oppo_pos
-
win_pos
+
1
],
'DUEL_END'
)
if
room
.
hostinfo
.
mode
==
2
room
.
scores
[
room
.
dueling_players
[
oppo_pos
-
win_pos
].
name_vpass
]
=
-
1
CLIENT_kick
(
room
.
dueling_players
[
oppo_pos
-
win_pos
])
CLIENT_kick
(
room
.
dueling_players
[
oppo_pos
-
win_pos
+
1
])
if
room
.
hostinfo
.
mode
==
2
when
1
room
.
death
=
-
1
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_quick}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
room
.
death
=
5
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_start_siding}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
for
room
in
ROOM_all
when
room
and
(
u
.
query
.
death
==
"all"
or
u
.
query
.
death
==
room
.
process_pid
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
if
room
.
start_death
()
death_room_found
=
true
response
.
writeHead
(
200
)
if
death_room_found
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['death ok', '"
+
u
.
query
.
death
+
"']"
))
...
...
@@ -3578,10 +3590,9 @@ if settings.modules.http
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['密码错误', 0]"
))
return
death_room_found
=
false
for
room
in
ROOM_all
when
room
and
room
.
established
and
room
.
started
and
room
.
death
and
(
u
.
query
.
deathcancel
==
"all"
or
u
.
query
.
deathcancel
==
room
.
process_pid
.
toString
())
death_room_found
=
true
room
.
death
=
0
ygopro
.
stoc_send_chat_to_room
(
room
,
"${death_cancel}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
for
room
in
ROOM_all
when
room
and
(
u
.
query
.
death
==
"all"
or
u
.
query
.
death
==
room
.
process_pid
.
toString
()
or
u
.
query
.
death
==
room
.
name
)
if
room
.
cancel_death
()
death_room_found
=
true
response
.
writeHead
(
200
)
if
death_room_found
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"['death cancel ok', '"
+
u
.
query
.
deathcancel
+
"']"
))
...
...
ygopro-server.js
View file @
c51e57a9
...
...
@@ -1777,6 +1777,73 @@
}
};
Room
.
prototype
.
start_death
=
function
()
{
var
oppo_pos
,
win_pos
;
if
(
!
(
this
.
established
&&
this
.
started
&&
!
this
.
death
))
{
return
false
;
}
oppo_pos
=
this
.
hostinfo
.
mode
===
2
?
2
:
1
;
if
(
!
this
.
changing_side
&&
(
!
this
.
duel_count
||
this
.
turn
))
{
switch
(
settings
.
modules
.
http
.
quick_death_rule
)
{
case
3
:
this
.
death
=
-
2
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start_phase}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
break
;
default
:
this
.
death
=
(
this
.
turn
?
this
.
turn
+
4
:
5
);
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
switch
(
settings
.
modules
.
http
.
quick_death_rule
)
{
case
2
:
case
3
:
if
(
this
.
scores
[
this
.
dueling_players
[
0
].
name_vpass
]
===
this
.
scores
[
this
.
dueling_players
[
oppo_pos
].
name_vpass
])
{
if
(
settings
.
modules
.
http
.
quick_death_rule
===
3
)
{
this
.
death
=
-
1
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start_quick}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
this
.
death
=
5
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start_siding}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
win_pos
=
this
.
scores
[
this
.
dueling_players
[
0
].
name_vpass
]
>
this
.
scores
[
this
.
dueling_players
[
oppo_pos
].
name_vpass
]
?
0
:
oppo_pos
;
this
.
finished_by_death
=
true
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death2_finish_part1}
"
+
this
.
dueling_players
[
win_pos
].
name
+
"
${death2_finish_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
if
(
this
.
hostinfo
.
mode
===
1
)
{
CLIENT_send_replays
(
this
.
dueling_players
[
oppo_pos
-
win_pos
],
this
);
}
ygopro
.
stoc_send
(
this
.
dueling_players
[
oppo_pos
-
win_pos
],
'
DUEL_END
'
);
if
(
this
.
hostinfo
.
mode
===
2
)
{
ygopro
.
stoc_send
(
this
.
dueling_players
[
oppo_pos
-
win_pos
+
1
],
'
DUEL_END
'
);
}
this
.
scores
[
this
.
dueling_players
[
oppo_pos
-
win_pos
].
name_vpass
]
=
-
1
;
CLIENT_kick
(
this
.
dueling_players
[
oppo_pos
-
win_pos
]);
if
(
this
.
hostinfo
.
mode
===
2
)
{
CLIENT_kick
(
this
.
dueling_players
[
oppo_pos
-
win_pos
+
1
]);
}
}
break
;
case
1
:
this
.
death
=
-
1
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start_quick}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
break
;
default
:
this
.
death
=
5
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_start_siding}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
return
true
;
};
Room
.
prototype
.
cancel_death
=
function
()
{
if
(
!
(
this
.
established
&&
this
.
started
&&
this
.
death
))
{
return
false
;
}
this
.
death
=
0
;
ygopro
.
stoc_send_chat_to_room
(
this
,
"
${death_cancel}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
return
true
;
};
return
Room
;
})();
...
...
@@ -4250,7 +4317,7 @@
return
callback
+
"
(
"
+
text
+
"
);
"
;
};
requestListener
=
function
(
request
,
response
)
{
var
archive_args
,
archive_name
,
archive_process
,
check
,
death_room_found
,
duellog
,
error
,
filename
,
getpath
,
kick_room_found
,
len2
,
len3
,
len4
,
len5
,
len6
,
m
,
n
,
o
,
oppo_pos
,
p
,
parseQueryString
,
pass_validated
,
player
,
q
,
ref2
,
replay
,
room
,
roomsjson
,
u
,
win_pos
;
var
archive_args
,
archive_name
,
archive_process
,
check
,
death_room_found
,
duellog
,
error
,
filename
,
getpath
,
kick_room_found
,
len2
,
len3
,
len4
,
len5
,
len6
,
m
,
n
,
o
,
p
,
parseQueryString
,
pass_validated
,
player
,
q
,
ref2
,
replay
,
room
,
roomsjson
,
u
;
parseQueryString
=
true
;
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
if
(
u
.
pathname
===
'
/api/getrooms
'
)
{
...
...
@@ -4524,58 +4591,9 @@
death_room_found
=
false
;
for
(
p
=
0
,
len5
=
ROOM_all
.
length
;
p
<
len5
;
p
++
)
{
room
=
ROOM_all
[
p
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
!
room
.
death
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
process_pid
.
toString
()
||
u
.
query
.
death
===
room
.
name
)))
{
continue
;
}
death_room_found
=
true
;
oppo_pos
=
room
.
hostinfo
.
mode
===
2
?
2
:
1
;
if
(
!
room
.
changing_side
&&
(
!
room
.
duel_count
||
room
.
turn
))
{
switch
(
settings
.
modules
.
http
.
quick_death_rule
)
{
case
3
:
room
.
death
=
-
2
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start_phase}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
break
;
default
:
room
.
death
=
(
room
.
turn
?
room
.
turn
+
4
:
5
);
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
switch
(
settings
.
modules
.
http
.
quick_death_rule
)
{
case
2
:
case
3
:
if
(
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
===
room
.
scores
[
room
.
dueling_players
[
oppo_pos
].
name_vpass
])
{
if
(
settings
.
modules
.
http
.
quick_death_rule
===
3
)
{
room
.
death
=
-
1
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start_quick}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
room
.
death
=
5
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start_siding}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
{
win_pos
=
room
.
scores
[
room
.
dueling_players
[
0
].
name_vpass
]
>
room
.
scores
[
room
.
dueling_players
[
oppo_pos
].
name_vpass
]
?
0
:
oppo_pos
;
room
.
finished_by_death
=
true
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death2_finish_part1}
"
+
room
.
dueling_players
[
win_pos
].
name
+
"
${death2_finish_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
if
(
room
.
hostinfo
.
mode
===
1
)
{
CLIENT_send_replays
(
room
.
dueling_players
[
oppo_pos
-
win_pos
],
room
);
}
ygopro
.
stoc_send
(
room
.
dueling_players
[
oppo_pos
-
win_pos
],
'
DUEL_END
'
);
if
(
room
.
hostinfo
.
mode
===
2
)
{
ygopro
.
stoc_send
(
room
.
dueling_players
[
oppo_pos
-
win_pos
+
1
],
'
DUEL_END
'
);
}
room
.
scores
[
room
.
dueling_players
[
oppo_pos
-
win_pos
].
name_vpass
]
=
-
1
;
CLIENT_kick
(
room
.
dueling_players
[
oppo_pos
-
win_pos
]);
if
(
room
.
hostinfo
.
mode
===
2
)
{
CLIENT_kick
(
room
.
dueling_players
[
oppo_pos
-
win_pos
+
1
]);
}
}
break
;
case
1
:
room
.
death
=
-
1
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start_quick}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
break
;
default
:
room
.
death
=
5
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_start_siding}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
if
(
room
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
process_pid
.
toString
()
||
u
.
query
.
death
===
room
.
name
))
{
if
(
room
.
start_death
())
{
death_room_found
=
true
;
}
}
}
...
...
@@ -4594,12 +4612,11 @@
death_room_found
=
false
;
for
(
q
=
0
,
len6
=
ROOM_all
.
length
;
q
<
len6
;
q
++
)
{
room
=
ROOM_all
[
q
];
if
(
!
(
room
&&
room
.
established
&&
room
.
started
&&
room
.
death
&&
(
u
.
query
.
deathcancel
===
"
all
"
||
u
.
query
.
deathcancel
===
room
.
process_pid
.
toString
())))
{
continue
;
if
(
room
&&
(
u
.
query
.
death
===
"
all
"
||
u
.
query
.
death
===
room
.
process_pid
.
toString
()
||
u
.
query
.
death
===
room
.
name
))
{
if
(
room
.
cancel_death
())
{
death_room_found
=
true
;
}
}
death_room_found
=
true
;
room
.
death
=
0
;
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${death_cancel}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
response
.
writeHead
(
200
);
if
(
death_room_found
)
{
...
...
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