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
3874f4a5
Commit
3874f4a5
authored
Feb 13, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just before duel start
parent
76b99077
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
166 additions
and
52 deletions
+166
-52
src/room/duel-record.ts
src/room/duel-record.ts
+3
-0
src/room/room-event-register.ts
src/room/room-event-register.ts
+14
-1
src/room/room.ts
src/room/room.ts
+139
-48
src/utility/decorators.ts
src/utility/decorators.ts
+8
-2
src/utility/metadata.ts
src/utility/metadata.ts
+2
-1
No files found.
src/room/duel-record.ts
View file @
3874f4a5
...
...
@@ -14,6 +14,7 @@ export class DuelRecord {
public
seed
:
number
[],
public
players
:
{
name
:
string
;
deck
:
YGOProDeck
}[],
)
{}
date
=
new
Date
();
winPosition
?:
number
;
responses
:
Buffer
[]
=
[];
...
...
@@ -29,6 +30,8 @@ export class DuelRecord {
header
.
flag
|=
REPLAY_TAG
;
}
header
.
seedSequence
=
this
.
seed
;
// Set start_time (stored in hash field) as Unix timestamp in seconds
header
.
hash
=
Math
.
floor
(
this
.
date
.
getTime
()
/
1000
);
// Build YGOProYrp object
// Note: players array is already swapped
...
...
src/room/room-event-register.ts
View file @
3874f4a5
import
'
reflect-metadata
'
;
import
{
Context
}
from
'
../app
'
;
import
{
getSpecificFields
}
from
'
../utility/metadata
'
;
import
{
RoomMethodOptions
}
from
'
../utility/decorators
'
;
import
{
Room
}
from
'
./room
'
;
import
{
Client
}
from
'
../client/client
'
;
import
{
YGOProCtosBase
}
from
'
ygopro-msg-encode
'
;
import
{
RoomManager
}
from
'
./room-manager
'
;
import
{
makeArray
}
from
'
nfkit
'
;
export
class
RoomEventRegister
{
private
logger
=
this
.
ctx
.
createLogger
(
'
RoomEventRegister
'
);
...
...
@@ -15,7 +17,7 @@ export class RoomEventRegister {
private
registerRoomEvents
()
{
const
roomMethods
=
getSpecificFields
(
'
roomMethod
'
,
Room
);
for
(
const
{
key
:
method
}
of
roomMethods
)
{
for
(
const
{
key
:
method
,
metadata
}
of
roomMethods
)
{
// 获取方法的参数类型
const
paramTypes
:
any
[]
=
Reflect
.
getMetadata
(
'
design:paramtypes
'
,
Room
.
prototype
,
method
)
||
[];
...
...
@@ -48,6 +50,9 @@ export class RoomEventRegister {
continue
;
}
// 获取方法选项
const
options
:
RoomMethodOptions
=
metadata
;
// 注册 middleware
this
.
ctx
.
middleware
(
ctosParamType
,
async
(
msg
,
client
,
next
)
=>
{
// 如果 client 没有关联的 room,直接跳过
...
...
@@ -62,6 +67,14 @@ export class RoomEventRegister {
return
next
();
}
// 检查 DuelStage 限制
if
(
options
?.
allowInDuelStages
)
{
const
allowedStages
=
makeArray
(
options
.
allowInDuelStages
);
if
(
!
allowedStages
.
includes
(
room
.
duelStage
))
{
return
next
();
}
}
// 构造参数数组
const
args
=
new
Array
(
paramTypes
.
length
);
for
(
let
i
=
0
;
i
<
paramTypes
.
length
;
i
++
)
{
...
...
src/room/room.ts
View file @
3874f4a5
This diff is collapsed.
Click to expand it.
src/utility/decorators.ts
View file @
3874f4a5
import
{
Metadata
}
from
'
./metadata
'
;
import
{
DuelStage
}
from
'
../room/duel-stage
'
;
import
{
MayBeArray
}
from
'
nfkit
'
;
export
const
RoomMethod
=
():
MethodDecorator
=>
Metadata
.
set
(
'
roomMethod
'
,
true
,
'
roomMethodKeys
'
);
export
interface
RoomMethodOptions
{
allowInDuelStages
?:
MayBeArray
<
DuelStage
>
;
}
export
const
RoomMethod
=
(
options
:
RoomMethodOptions
=
{}):
MethodDecorator
=>
Metadata
.
set
(
'
roomMethod
'
,
options
,
'
roomMethodKeys
'
);
src/utility/metadata.ts
View file @
3874f4a5
import
{
MetadataSetter
,
Reflector
}
from
'
typed-reflector
'
;
import
type
{
RoomMethodOptions
}
from
'
./decorators
'
;
interface
MetadataMap
{
roomMethod
:
boolean
;
roomMethod
:
RoomMethodOptions
;
}
type
MetadataArrayMap
=
{
...
...
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