Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-cn-database-generator
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
MyCard
ygopro-cn-database-generator
Commits
e6e38cd6
Commit
e6e38cd6
authored
Jun 21, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update CN generation
parent
5072e052
Pipeline
#37909
passed with stages
in 5 minutes and 10 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
18 deletions
+45
-18
.gitlab-ci.yml
.gitlab-ci.yml
+8
-0
run.ts
run.ts
+6
-1
src/dbreader.ts
src/dbreader.ts
+15
-13
src/direct.ts
src/direct.ts
+14
-2
src/utility.ts
src/utility.ts
+2
-2
No files found.
.gitlab-ci.yml
View file @
e6e38cd6
...
@@ -99,6 +99,14 @@ upload_to_minio:
...
@@ -99,6 +99,14 @@ upload_to_minio:
deploy_server_env408
:
deploy_server_env408
:
extends
:
.deploy_server
extends
:
.deploy_server
deploy_server_cn
:
extends
:
.deploy_server
dependencies
:
-
zh-CN
variables
:
OUTPUT_ENV
:
cn-zh-CN
SERVER_IDENTIFIER
:
'
cn'
deploy_server_env706
:
deploy_server_env706
:
extends
:
.deploy_server
extends
:
.deploy_server
dependencies
:
dependencies
:
...
...
run.ts
View file @
e6e38cd6
...
@@ -5,6 +5,8 @@ import { CNOCGFetcher } from "./src/cnocg";
...
@@ -5,6 +5,8 @@ import { CNOCGFetcher } from "./src/cnocg";
import
{
ExtraCards
}
from
"
./src/ExtraCards
"
;
import
{
ExtraCards
}
from
"
./src/ExtraCards
"
;
import
{
DirectFetcher
}
from
"
./src/direct
"
;
import
{
DirectFetcher
}
from
"
./src/direct
"
;
import
Logger
from
"
bunyan
"
;
import
Logger
from
"
bunyan
"
;
import
{
readLFList
}
from
"
./src/utility
"
;
import
fs
from
'
fs
'
;
async
function
main
()
{
async
function
main
()
{
const
dbreader
=
new
DBReader
({
const
dbreader
=
new
DBReader
({
...
@@ -16,7 +18,10 @@ async function main() {
...
@@ -16,7 +18,10 @@ async function main() {
//const missingExtraCards = ExtraCards.filter(c => !cards.some(cc => c.code === cc.code));
//const missingExtraCards = ExtraCards.filter(c => !cards.some(cc => c.code === cc.code));
//await dbreader.run(cards.concat(missingExtraCards));
//await dbreader.run(cards.concat(missingExtraCards));
const
cards
=
await
DirectFetcher
.
fetchOnce
();
const
cards
=
await
DirectFetcher
.
fetchOnce
();
await
dbreader
.
run
(
cards
);
const
lflist
=
await
readLFList
(
await
fs
.
promises
.
readFile
(
"
./lflist/lflist.conf
"
,
"
utf-8
"
));
await
dbreader
.
run
(
cards
,
{
extraBanlists
:
lflist
,
});
process
.
exit
();
process
.
exit
();
}
}
main
();
main
();
src/dbreader.ts
View file @
e6e38cd6
...
@@ -198,17 +198,17 @@ export class DBReader extends Base {
...
@@ -198,17 +198,17 @@ export class DBReader extends Base {
}
}
async
generateBanlist
(
codes
:
number
[],
extraBanlists
:
Banlist
[]
=
[])
{
async
generateBanlist
(
codes
:
number
[],
extraBanlists
:
Banlist
[]
=
[])
{
const
otherCodes
=
await
this
.
getOtherCardCodes
(
codes
);
const
otherCodes
=
await
this
.
getOtherCardCodes
(
codes
);
const
banlistString
=
await
generateBanlistFromCode
([
const
generatedBanlist
:
Banlist
=
{
mergeBanlists
([
...
extraBanlists
,
{
name
:
moment
().
format
(
'
YYYY.MM
'
)
+
'
'
+
this
.
config
.
descSymbol
,
name
:
moment
().
format
(
'
YYYY.MM
'
)
+
'
'
+
this
.
config
.
descSymbol
,
list
:
[
list
:
[
otherCodes
otherCodes
]
]
}
};
]),
const
banlistString
=
await
generateBanlistFromCode
(
]);
extraBanlists
?.
length
?
extraBanlists
.
map
(
l
=>
mergeBanlists
([
generatedBanlist
,
l
],
extraBanlists
.
length
===
1
?
generatedBanlist
.
name
:
l
.
name
))
:
[
generatedBanlist
]
);
await
fs
.
writeFile
(
`
${
this
.
config
.
outputPath
}
/expansions/lflist.conf`
,
banlistString
);
await
fs
.
writeFile
(
`
${
this
.
config
.
outputPath
}
/expansions/lflist.conf`
,
banlistString
);
}
}
async
generatePatch
(
codes
:
number
[])
{
async
generatePatch
(
codes
:
number
[])
{
...
@@ -259,8 +259,10 @@ export class DBReader extends Base {
...
@@ -259,8 +259,10 @@ export class DBReader extends Base {
this
.
log
.
info
(
`Database created.`
);
this
.
log
.
info
(
`Database created.`
);
await
this
.
generateBanlist
(
allCodes
,
options
.
extraBanlists
||
[]);
await
this
.
generateBanlist
(
allCodes
,
options
.
extraBanlists
||
[]);
this
.
log
.
info
(
`LFList created.`
);
this
.
log
.
info
(
`LFList created.`
);
if
(
this
.
config
.
fileSymbol
===
'
cn
'
)
{
await
this
.
generatePatch
(
allCodes
);
await
this
.
generatePatch
(
allCodes
);
this
.
log
.
info
(
`Patch created.`
);
this
.
log
.
info
(
`Patch created.`
);
}
await
this
.
generateDecks
(
cards
);
await
this
.
generateDecks
(
cards
);
this
.
log
.
info
(
`Decks generated.`
);
this
.
log
.
info
(
`Decks generated.`
);
}
}
...
...
src/direct.ts
View file @
e6e38cd6
import
Base
from
"
./base
"
;
import
Base
from
"
./base
"
;
import
{
promises
as
fs
}
from
"
fs
"
;
import
{
promises
as
fs
}
from
"
fs
"
;
import
{
Card
}
from
"
./dbreader
"
;
import
{
Card
,
DBReader
}
from
"
./dbreader
"
;
import
{
CNOCGFetcher
}
from
"
./cnocg
"
;
import
{
CNOCGFetcher
}
from
"
./cnocg
"
;
export
class
DirectFetcher
extends
Base
{
export
class
DirectFetcher
extends
Base
{
static
async
fetchOnce
()
{
static
async
fetchOnce
()
{
const
fetcher
=
new
DirectFetcher
({
name
:
"
Temp Direct Fetcher
"
,
level
:
'
info
'
});
const
fetcher
=
new
DirectFetcher
({
name
:
"
Temp Direct Fetcher
"
,
level
:
'
debug
'
});
await
fetcher
.
init
();
await
fetcher
.
init
();
return
await
fetcher
.
fetch
();
return
await
fetcher
.
fetch
();
}
}
...
@@ -53,6 +53,17 @@ export class DirectFetcher extends Base {
...
@@ -53,6 +53,17 @@ export class DirectFetcher extends Base {
this
.
addCode
(
code
);
this
.
addCode
(
code
);
}
}
}
}
private
async
workWithExisting
()
{
const
cnDb
=
await
new
DBReader
({
name
:
'
Existing Reader
'
,
level
:
'
info
'
}).
openDatabase
(
this
.
config
.
cnDatabasePath
);
this
.
log
.
info
(
`Reading existing YGOPro database.`
);
const
cnDbData
=
await
cnDb
.
all
<
{
id
:
number
}[]
>
(
"
SELECT id FROM datas where (ot & 0x8) > 0 and (type & 0x4000) = 0
"
);
this
.
log
.
info
(
`
${
cnDbData
.
length
}
existing cards found.`
);
for
(
const
row
of
cnDbData
)
{
this
.
addCode
(
row
.
id
);
}
}
async
fetch
():
Promise
<
Card
[]
>
{
async
fetch
():
Promise
<
Card
[]
>
{
//this.log.info(`Started fetching from CNOCG.`);
//this.log.info(`Started fetching from CNOCG.`);
this
.
cardCodes
=
[];
this
.
cardCodes
=
[];
...
@@ -62,6 +73,7 @@ export class DirectFetcher extends Base {
...
@@ -62,6 +73,7 @@ export class DirectFetcher extends Base {
for
(
let
file
of
ydkFiles
)
{
for
(
let
file
of
ydkFiles
)
{
await
this
.
workWithYdk
(
file
);
await
this
.
workWithYdk
(
file
);
}
}
await
this
.
workWithExisting
();
const
finalCodes
=
this
.
cardCodes
;
const
finalCodes
=
this
.
cardCodes
;
this
.
log
.
info
(
`
${
finalCodes
.
length
}
cards in total.`
);
this
.
log
.
info
(
`
${
finalCodes
.
length
}
cards in total.`
);
return
finalCodes
.
map
(
code
=>
new
Card
(
code
));
return
finalCodes
.
map
(
code
=>
new
Card
(
code
));
...
...
src/utility.ts
View file @
e6e38cd6
...
@@ -47,8 +47,8 @@ export async function readLFList(content: string): Promise<Banlist[]> {
...
@@ -47,8 +47,8 @@ export async function readLFList(content: string): Promise<Banlist[]> {
return
ret
;
return
ret
;
}
}
export
function
mergeBanlists
(
lists
:
Banlist
[]):
Banlist
{
export
function
mergeBanlists
(
lists
:
Banlist
[]
,
name
?:
string
):
Banlist
{
const
ret
:
Banlist
=
{
name
:
lists
[
0
].
name
,
list
:
[]
};
const
ret
:
Banlist
=
{
name
:
name
||
lists
[
0
].
name
,
list
:
[]
};
const
existingCodes
=
new
Set
<
number
>
();
const
existingCodes
=
new
Set
<
number
>
();
for
(
let
status
=
0
;
status
<
3
;
++
status
)
{
for
(
let
status
=
0
;
status
<
3
;
++
status
)
{
for
(
let
list
of
lists
)
{
for
(
let
list
of
lists
)
{
...
...
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