Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro2
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
srvpro2
Commits
d06bf381
Commit
d06bf381
authored
Feb 14, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add player status notify
parent
405b1fc9
Pipeline
#43200
passed with stages
in 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
src/feats/player-status-notify.ts
src/feats/player-status-notify.ts
+28
-0
src/room/room.ts
src/room/room.ts
+11
-1
No files found.
src/feats/player-status-notify.ts
0 → 100644
View file @
d06bf381
import
{
ChatColor
,
NetPlayerType
}
from
'
ygopro-msg-encode
'
;
import
{
Context
}
from
'
../app
'
;
import
{
OnRoomJoinObserver
}
from
'
../room/room-event/on-room-join-observer
'
;
import
{
OnRoomLeave
}
from
'
../room/room-event/on-room-leave
'
;
export
class
PlayerStatusNotify
{
constructor
(
private
ctx
:
Context
)
{
// 观战者加入
this
.
ctx
.
middleware
(
OnRoomJoinObserver
,
async
(
event
,
client
,
next
)
=>
{
const
room
=
event
.
room
;
await
room
.
sendChat
(
`
${
client
.
name
}
#{watch_join}`
,
ChatColor
.
LIGHTBLUE
);
return
next
();
});
// 离开房间(根据 pos 判断是观战者还是玩家)
this
.
ctx
.
middleware
(
OnRoomLeave
,
async
(
event
,
client
,
next
)
=>
{
const
room
=
event
.
room
;
if
(
client
.
pos
===
NetPlayerType
.
OBSERVER
)
{
// 观战者离开
await
room
.
sendChat
(
`
${
client
.
name
}
#{quit_watch}`
,
ChatColor
.
LIGHTBLUE
);
}
else
{
// 玩家离开
await
room
.
sendChat
(
`
${
client
.
name
}
#{left_game}`
,
ChatColor
.
LIGHTBLUE
);
}
return
next
();
});
}
}
src/room/room.ts
View file @
d06bf381
...
@@ -173,7 +173,7 @@ export class Room {
...
@@ -173,7 +173,7 @@ export class Room {
private
async
cleanPlayers
(
sendDuelEnd
=
false
)
{
private
async
cleanPlayers
(
sendDuelEnd
=
false
)
{
await
Promise
.
all
([
await
Promise
.
all
([
...
this
.
all
Players
.
map
(
async
(
p
)
=>
{
...
this
.
playing
Players
.
map
(
async
(
p
)
=>
{
await
this
.
kick
(
p
,
sendDuelEnd
);
await
this
.
kick
(
p
,
sendDuelEnd
);
if
(
p
.
pos
<
NetPlayerType
.
OBSERVER
)
{
if
(
p
.
pos
<
NetPlayerType
.
OBSERVER
)
{
this
.
players
[
p
.
pos
]
=
undefined
;
this
.
players
[
p
.
pos
]
=
undefined
;
...
@@ -496,6 +496,16 @@ export class Room {
...
@@ -496,6 +496,16 @@ export class Room {
if
(
nextHost
)
{
if
(
nextHost
)
{
nextHost
.
isHost
=
true
;
nextHost
.
isHost
=
true
;
await
nextHost
.
sendTypeChange
();
await
nextHost
.
sendTypeChange
();
// 如果游戏还在准备阶段,重置新房主的准备状态
if
(
this
.
duelStage
===
DuelStage
.
Begin
&&
nextHost
.
deck
)
{
nextHost
.
deck
=
undefined
;
// 发送 PlayerChange NOTREADY 给所有人
await
Promise
.
all
(
this
.
allPlayers
.
map
((
p
)
=>
p
.
send
(
nextHost
.
prepareChangePacket
(
PlayerChangeState
.
NOTREADY
)),
),
);
}
}
}
}
}
...
...
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