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
24229c19
Commit
24229c19
authored
Feb 20, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reuse cardreader
parent
8e668218
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
16 deletions
+59
-16
package-lock.json
package-lock.json
+4
-4
package.json
package.json
+1
-1
src/room/room-event/room-check-deck.ts
src/room/room-event/room-check-deck.ts
+2
-2
src/room/room.ts
src/room/room.ts
+4
-4
src/room/ygopro-resource-loader.ts
src/room/ygopro-resource-loader.ts
+37
-3
src/utility/check-deck.ts
src/utility/check-deck.ts
+2
-2
src/utility/index.ts
src/utility/index.ts
+1
-0
src/utility/read-card-with-reader.ts
src/utility/read-card-with-reader.ts
+8
-0
No files found.
package-lock.json
View file @
24229c19
...
...
@@ -18,7 +18,7 @@
"https-proxy-agent"
:
"^7.0.6"
,
"ipaddr.js"
:
"^2.3.0"
,
"koishi"
:
"^4.18.10"
,
"koishipro-core.js"
:
"^1.3.
5
"
,
"koishipro-core.js"
:
"^1.3.
7
"
,
"nfkit"
:
"^1.0.35"
,
"p-queue"
:
"6.6.2"
,
"pg"
:
"^8.18.0"
,
...
...
@@ -6050,9 +6050,9 @@
}
},
"node_modules/koishipro-core.js"
:
{
"version"
:
"1.3.
5
"
,
"resolved"
:
"https://registry.npmjs.org/koishipro-core.js/-/koishipro-core.js-1.3.
5
.tgz"
,
"integrity"
:
"sha512-
hPoDdBN/+9DCyArdbDUxqVDVJ5zBJciYcYYB5epXOili1aVh9DXMfqXpFfw0jRh5oHM0dG5eWQBUpLXte87m8g
=="
,
"version"
:
"1.3.
7
"
,
"resolved"
:
"https://registry.npmjs.org/koishipro-core.js/-/koishipro-core.js-1.3.
7
.tgz"
,
"integrity"
:
"sha512-
prR7RRREW0jmKQWIaAfFAparzYrZeKo8+MJs4g2zGOryMH0JU5ZQtKO82ExEIAbCV1QRoVN7Hs0ToRVBy8/PTQ
=="
,
"license"
:
"MIT"
,
"dependencies"
:
{
"@types/emscripten"
:
"^1.41.5"
,
...
...
package.json
View file @
24229c19
...
...
@@ -71,7 +71,7 @@
"
https-proxy-agent
"
:
"
^7.0.6
"
,
"
ipaddr.js
"
:
"
^2.3.0
"
,
"
koishi
"
:
"
^4.18.10
"
,
"
koishipro-core.js
"
:
"
^1.3.
5
"
,
"
koishipro-core.js
"
:
"
^1.3.
7
"
,
"
nfkit
"
:
"
^1.0.35
"
,
"
p-queue
"
:
"
6.6.2
"
,
"
pg
"
:
"
^8.18.0
"
,
...
...
src/room/room-event/room-check-deck.ts
View file @
24229c19
...
...
@@ -3,7 +3,7 @@ import { Client } from '../../client';
import
{
ValueContainer
}
from
'
../../utility/value-container
'
;
import
{
Room
}
from
'
../room
'
;
import
{
YGOProLFListError
}
from
'
ygopro-lflist-encode
'
;
import
{
CardReader
Finalized
}
from
'
koishipro-core.js
'
;
import
{
CardReader
}
from
'
koishipro-core.js
'
;
export
class
RoomCheckDeck
extends
ValueContainer
<
YGOProLFListError
|
undefined
...
...
@@ -12,7 +12,7 @@ export class RoomCheckDeck extends ValueContainer<
public
room
:
Room
,
public
client
:
Client
,
public
deck
:
YGOProDeck
,
public
cardReader
:
CardReader
Finalized
,
public
cardReader
:
CardReader
,
)
{
super
(
undefined
);
}
...
...
src/room/room.ts
View file @
24229c19
...
...
@@ -56,7 +56,7 @@ import {
}
from
'
ygopro-msg-encode
'
;
import
{
DefaultHostInfoProvider
}
from
'
./default-hostinfo-provder
'
;
import
{
CardReader
Finalized
,
CardReader
,
OcgcoreMessageType
,
_OcgcoreConstants
,
}
from
'
koishipro-core.js
'
;
...
...
@@ -108,7 +108,7 @@ import { OnRoomSelectTp } from './room-event/on-room-select-tp';
import
{
RoomCheckDeck
}
from
'
./room-event/room-check-deck
'
;
import
cryptoRandomString
from
'
crypto-random-string
'
;
import
{
RoomCurrentFieldInfo
,
RoomInfo
}
from
'
./room-info
'
;
import
{
KoishiFragment
}
from
'
../utility
'
;
import
{
KoishiFragment
,
readCardWithReader
}
from
'
../utility
'
;
const
{
OcgcoreScriptConstants
}
=
_OcgcoreConstants
;
...
...
@@ -165,7 +165,7 @@ export class Room {
private
get
resourceLoader
()
{
return
this
.
ctx
.
get
(()
=>
YGOProResourceLoader
);
}
private
_cardReader
?:
CardReader
Finalized
;
private
_cardReader
?:
CardReader
;
private
cardReaderLock
=
new
BetterLock
();
private
async
getCardReader
()
{
return
this
.
cardReaderLock
.
acquire
(
async
()
=>
{
...
...
@@ -825,7 +825,7 @@ export class Room {
// we have to distinguish main and extra deck cards
const
cardReader
=
await
this
.
getCardReader
();
for
(
const
card
of
msg
.
deck
.
main
)
{
const
cardEntry
=
cardReader
.
apply
(
card
);
const
cardEntry
=
readCardWithReader
(
cardReader
,
card
);
if
(
cardEntry
?.
type
&&
cardEntry
.
type
&
OcgcoreCommonConstants
.
TYPES_EXTRA_DECK
...
...
src/room/ygopro-resource-loader.ts
View file @
24229c19
import
{
Context
}
from
'
../app
'
;
import
{
DirCardReader
,
searchYGOProResource
}
from
'
koishipro-core.js
'
;
import
{
searchYGOProResource
,
SqljsCardReader
}
from
'
koishipro-core.js
'
;
import
{
YGOProLFList
}
from
'
ygopro-lflist-encode
'
;
import
path
from
'
node:path
'
;
import
{
YGOProCdb
}
from
'
ygopro-cdb-encode
'
;
export
class
YGOProResourceLoader
{
constructor
(
private
ctx
:
Context
)
{}
...
...
@@ -16,10 +17,43 @@ export class YGOProResourceLoader {
private
logger
=
this
.
ctx
.
createLogger
(
this
.
constructor
.
name
);
private
_cardReader
=
DirCardReader
(
this
.
ctx
.
SQL
,
...
this
.
ygoproPaths
);
private
cardReader
=
this
.
mergeDatabase
().
then
((
db
)
=>
SqljsCardReader
(
db
)
);
async
getCardReader
()
{
return
this
.
_cardReader
;
return
this
.
cardReader
;
}
private
async
mergeDatabase
()
{
const
db
=
new
YGOProCdb
(
this
.
ctx
.
SQL
);
let
dbCount
=
0
;
for
await
(
const
file
of
searchYGOProResource
(...
this
.
ygoproPaths
))
{
const
filename
=
path
.
basename
(
file
.
path
);
if
(
!
filename
?.
endsWith
(
'
.cdb
'
))
{
continue
;
}
try
{
const
currentDb
=
new
this
.
ctx
.
SQL
.
Database
(
await
file
.
read
());
try
{
const
currentCdb
=
new
YGOProCdb
(
currentDb
);
const
cards
=
currentCdb
.
find
();
for
(
const
card
of
cards
)
{
if
(
!
db
.
findById
(
card
.
code
))
{
db
.
addCard
(
card
);
}
}
++
dbCount
;
}
finally
{
currentDb
.
close
();
}
}
catch
(
e
)
{
this
.
logger
.
warn
(
`Failed to read
${
file
.
path
}
:
${
e
}
`
);
continue
;
}
}
this
.
logger
.
info
(
`Merged database from
${
dbCount
}
databases with
${
db
.
find
().
length
}
cards`
,
);
return
db
;
}
async
*
getLFLists
()
{
...
...
src/utility/check-deck.ts
View file @
24229c19
...
...
@@ -6,6 +6,7 @@ import {
YGOProLFListItem
,
}
from
'
ygopro-lflist-encode
'
;
import
{
OcgcoreCommonConstants
}
from
'
ygopro-msg-encode
'
;
import
{
readCardWithReader
}
from
'
./read-card-with-reader
'
;
// Constants from ygopro
const
{
TYPES_EXTRA_DECK
,
TYPE_TOKEN
}
=
OcgcoreCommonConstants
;
...
...
@@ -101,8 +102,7 @@ export const checkDeck = (
code
:
number
,
location
:
'
main
'
|
'
extra
'
|
'
side
'
,
):
YGOProLFListError
|
null
=>
{
const
cardData
=
typeof
reader
===
'
function
'
?
reader
(
code
)
:
reader
.
apply
(
code
);
const
cardData
=
readCardWithReader
(
reader
,
code
);
if
(
!
cardData
)
{
return
new
YGOProLFListError
(
YGOProLFListErrorReason
.
UNKNOWNCARD
,
code
);
...
...
src/utility/index.ts
View file @
24229c19
...
...
@@ -3,3 +3,4 @@ export * from './base-time.entity';
export
*
from
'
./bigint-transformer
'
;
export
*
from
'
./decorators
'
;
export
*
from
'
./koishi-chat
'
;
export
*
from
'
./read-card-with-reader
'
;
src/utility/read-card-with-reader.ts
0 → 100644
View file @
24229c19
import
{
CardReader
}
from
'
koishipro-core.js
'
;
import
{
CardDataEntry
}
from
'
ygopro-cdb-encode
'
;
export
const
readCardWithReader
=
(
reader
:
CardReader
,
cardId
:
number
,
):
Partial
<
CardDataEntry
>
|
null
|
undefined
=>
typeof
reader
===
'
function
'
?
reader
(
cardId
)
:
reader
.
apply
(
cardId
);
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