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
12308caa
Commit
12308caa
authored
Feb 14, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timer
parent
c5815aaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
73 deletions
+48
-73
src/room/room.ts
src/room/room.ts
+48
-73
No files found.
src/room/room.ts
View file @
12308caa
...
@@ -934,7 +934,6 @@ export class Room {
...
@@ -934,7 +934,6 @@ export class Room {
phase
=
undefined
;
phase
=
undefined
;
private
timerState
=
new
TimerState
();
private
timerState
=
new
TimerState
();
private
lastResponseRequestMsgType
=
0
;
private
lastResponseRequestMsgType
=
0
;
private
pendingResponseRequestMsgType
=
0
;
private
get
hasTimeLimit
()
{
private
get
hasTimeLimit
()
{
return
this
.
hostinfo
.
time_limit
>
0
;
return
this
.
hostinfo
.
time_limit
>
0
;
}
}
...
@@ -945,7 +944,6 @@ export class Room {
...
@@ -945,7 +944,6 @@ export class Room {
:
0
;
:
0
;
this
.
timerState
.
reset
(
initialTime
);
this
.
timerState
.
reset
(
initialTime
);
this
.
lastResponseRequestMsgType
=
0
;
this
.
lastResponseRequestMsgType
=
0
;
this
.
pendingResponseRequestMsgType
=
0
;
}
}
private
clearResponseTimer
(
settleElapsed
=
false
)
{
private
clearResponseTimer
(
settleElapsed
=
false
)
{
...
@@ -960,9 +958,6 @@ export class Room {
...
@@ -960,9 +958,6 @@ export class Room {
)
{
)
{
this
.
timerState
.
leftMs
[
options
.
timedOutPlayer
]
=
0
;
this
.
timerState
.
leftMs
[
options
.
timedOutPlayer
]
=
0
;
}
}
this
.
pendingResponse
=
undefined
;
this
.
pendingResponsePos
=
undefined
;
this
.
pendingResponseRequestMsgType
=
0
;
this
.
responsePos
=
undefined
;
this
.
responsePos
=
undefined
;
}
}
...
@@ -1334,6 +1329,20 @@ export class Room {
...
@@ -1334,6 +1329,20 @@ export class Room {
]);
]);
}
}
private
async
sendWaitingToNonOperator
(
ingameDuelPos
:
number
)
{
const
operatingPlayer
=
this
.
getOperatingPlayer
(
ingameDuelPos
);
const
noOps
=
this
.
playingPlayers
.
filter
((
p
)
=>
p
!==
operatingPlayer
);
await
Promise
.
all
(
noOps
.
map
((
p
)
=>
p
.
send
(
new
YGOProStocGameMsg
().
fromPartial
({
msg
:
new
YGOProMsgWaiting
(),
}),
),
),
);
}
private
async
routeGameMsg
(
message
:
YGOProMsgBase
)
{
private
async
routeGameMsg
(
message
:
YGOProMsgBase
)
{
if
(
!
message
)
{
if
(
!
message
)
{
return
;
return
;
...
@@ -1370,10 +1379,37 @@ export class Room {
...
@@ -1370,10 +1379,37 @@ export class Room {
}
}
}),
}),
);
);
if
(
isUpdateMessage
(
message
)
||
shouldRefreshFirst
)
{
if
(
!
isUpdateMessage
(
message
)
&&
!
shouldRefreshFirst
)
{
await
this
.
refreshForMessage
(
message
);
}
if
(
message
instanceof
YGOProMsgResponseBase
)
{
this
.
lastResponseRequestMsgType
=
getMessageIdentifier
(
message
);
this
.
responsePos
=
this
.
getIngameDuelPosByDuelPos
(
message
.
responsePlayer
(),
);
await
this
.
sendWaitingToNonOperator
(
message
.
responsePlayer
());
await
this
.
setResponseTimer
(
this
.
responsePos
);
return
;
return
;
}
}
await
this
.
refreshForMessage
(
message
);
if
(
message
instanceof
YGOProMsgRetry
&&
this
.
responsePos
!=
null
)
{
if
(
this
.
lastDuelRecord
.
responses
.
length
>
0
)
{
this
.
lastDuelRecord
.
responses
.
pop
();
}
this
.
lastResponseRequestMsgType
=
OcgcoreCommonConstants
.
MSG_RETRY
;
await
this
.
sendWaitingToNonOperator
(
this
.
getIngameDuelPosByDuelPos
(
this
.
responsePos
),
);
await
this
.
setResponseTimer
(
this
.
responsePos
);
return
;
}
if
(
this
.
responsePos
!=
null
&&
this
.
lastResponseRequestMsgType
===
0
&&
!
(
message
instanceof
YGOProMsgResponseBase
)
)
{
this
.
responsePos
=
undefined
;
}
}
}
private
async
handleGameMsg
(
message
:
YGOProMsgBase
,
route
=
false
)
{
private
async
handleGameMsg
(
message
:
YGOProMsgBase
,
route
=
false
)
{
...
@@ -1422,61 +1458,6 @@ export class Room {
...
@@ -1422,61 +1458,6 @@ export class Room {
}
}
return
next
();
return
next
();
})
})
.
middleware
(
YGOProMsgBase
,
async
(
message
,
next
)
=>
{
if
(
this
.
pendingResponse
)
{
const
resp
=
this
.
pendingResponse
;
const
responsePos
=
this
.
pendingResponsePos
;
this
.
pendingResponse
=
undefined
;
this
.
pendingResponsePos
=
undefined
;
this
.
pendingResponseRequestMsgType
=
0
;
if
(
message
instanceof
YGOProMsgRetry
)
{
if
(
responsePos
!=
null
)
{
this
.
responsePos
=
responsePos
;
this
.
lastResponseRequestMsgType
=
OcgcoreCommonConstants
.
MSG_RETRY
;
await
this
.
setResponseTimer
(
responsePos
);
}
}
else
{
this
.
lastDuelRecord
.
responses
.
push
(
resp
);
}
}
return
next
();
},
true
,
)
.
middleware
(
YGOProMsgResponseBase
,
async
(
message
,
next
)
=>
{
const
op
=
this
.
getOperatingPlayer
(
message
.
responsePlayer
());
const
noOps
=
this
.
playingPlayers
.
filter
((
p
)
=>
p
!==
op
);
await
Promise
.
all
(
noOps
.
map
((
p
)
=>
p
.
send
(
new
YGOProStocGameMsg
().
fromPartial
({
msg
:
new
YGOProMsgWaiting
(),
}),
),
),
);
return
next
();
},
true
,
)
.
middleware
(
YGOProMsgResponseBase
,
async
(
message
,
next
)
=>
{
this
.
lastResponseRequestMsgType
=
getMessageIdentifier
(
message
);
this
.
responsePos
=
this
.
getIngameDuelPosByDuelPos
(
message
.
responsePlayer
(),
);
await
this
.
setResponseTimer
(
this
.
responsePos
);
return
next
();
},
true
,
)
.
middleware
(
YGOProMsgRetry
,
async
(
message
,
next
)
=>
{
.
middleware
(
YGOProMsgRetry
,
async
(
message
,
next
)
=>
{
if
(
this
.
responsePos
!=
null
)
{
if
(
this
.
responsePos
!=
null
)
{
const
op
=
this
.
getOperatingPlayer
(
const
op
=
this
.
getOperatingPlayer
(
...
@@ -1491,8 +1472,6 @@ export class Room {
...
@@ -1491,8 +1472,6 @@ export class Room {
return
next
();
return
next
();
});
});
private
pendingResponse
?:
Buffer
;
private
pendingResponsePos
?:
number
;
private
responsePos
?:
number
;
private
responsePos
?:
number
;
private
async
advance
()
{
private
async
advance
()
{
...
@@ -1591,18 +1570,14 @@ export class Room {
...
@@ -1591,18 +1570,14 @@ export class Room {
return
;
return
;
}
}
const
responsePos
=
this
.
responsePos
;
const
responsePos
=
this
.
responsePos
;
this
.
pendingResponsePos
=
responsePos
;
const
responseRequestMsgType
=
this
.
lastResponseRequestMsgType
;
this
.
pendingResponseRequestMsgType
=
this
.
lastResponseRequestMsgType
;
const
response
=
Buffer
.
from
(
msg
.
response
)
;
this
.
pendingResponse
=
Buffer
.
from
(
msg
.
response
);
this
.
lastDuelRecord
.
responses
.
push
(
response
);
if
(
this
.
hasTimeLimit
)
{
if
(
this
.
hasTimeLimit
)
{
this
.
clearResponseTimer
(
true
);
this
.
clearResponseTimer
(
true
);
this
.
increaseResponseTime
(
this
.
increaseResponseTime
(
responsePos
,
responseRequestMsgType
,
response
);
responsePos
,
this
.
pendingResponseRequestMsgType
,
this
.
pendingResponse
,
);
}
}
this
.
responsePos
=
undefined
;
this
.
lastResponseRequestMsgType
=
0
;
await
this
.
ocgcore
.
setResponse
(
msg
.
response
);
await
this
.
ocgcore
.
setResponse
(
msg
.
response
);
return
this
.
advance
();
return
this
.
advance
();
}
}
...
...
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