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
e899ad8e
Commit
e899ad8e
authored
Jul 21, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ydk
parent
200d016d
Pipeline
#4219
passed with stages
in 3 minutes and 44 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
5 deletions
+75
-5
package.json
package.json
+1
-1
run.ts
run.ts
+8
-4
src/direct.ts
src/direct.ts
+66
-0
No files found.
package.json
View file @
e899ad8e
...
...
@@ -5,7 +5,7 @@
"main"
:
"run.ts"
,
"scripts"
:
{
"build"
:
"tsc"
,
"start"
:
"node build/run.js"
"start"
:
"node build/run.js
| bunyan
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
run.ts
View file @
e899ad8e
...
...
@@ -3,13 +3,17 @@ import { NWFetcher } from "./src/nwfetcher";
import
_
from
"
underscore
"
;
import
{
CNOCGFetcher
}
from
"
./src/cnocg
"
;
import
{
ExtraCards
}
from
"
./src/ExtraCards
"
;
import
{
DirectFetcher
}
from
"
./src/direct
"
;
async
function
main
()
{
const
dbreader
=
new
DBReader
({
name
:
"
Database
"
,
level
:
"
debug
"
});
const
dbreader
=
new
DBReader
({
name
:
"
Database
"
});
await
dbreader
.
init
();
const
cards
=
await
CNOCGFetcher
.
fetchOnce
();
const
missingExtraCards
=
ExtraCards
.
filter
(
c
=>
!
cards
.
some
(
cc
=>
c
.
code
===
cc
.
code
));
await
dbreader
.
run
(
cards
.
concat
(
missingExtraCards
));
//const cards = await CNOCGFetcher.fetchOnce();
//const missingExtraCards = ExtraCards.filter(c => !cards.some(cc => c.code === cc.code));
//await dbreader.run(cards.concat(missingExtraCards));
const
cards
=
await
DirectFetcher
.
fetchOnce
();
//console.log(cards);
await
dbreader
.
run
(
cards
);
process
.
exit
();
}
main
();
src/direct.ts
0 → 100644
View file @
e899ad8e
import
Base
from
"
./base
"
;
import
{
promises
as
fs
}
from
"
fs
"
;
import
{
Card
}
from
"
./dbreader
"
;
export
class
DirectFetcher
extends
Base
{
static
async
fetchOnce
()
{
const
fetcher
=
new
DirectFetcher
({
name
:
"
Temp Direct Fetcher
"
,
level
:
'
debug
'
});
await
fetcher
.
init
();
return
await
fetcher
.
fetch
();
}
cardCodes
:
number
[]
=
[];
private
addCode
(
code
:
number
)
{
const
posToRemove
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
cardCodes
.
length
;
++
i
)
{
const
c
=
this
.
cardCodes
[
i
];
// 完全相同的不加入
if
(
c
===
code
)
{
this
.
log
.
debug
(
`Skipped full dup:
${
code
}
${
c
}
`
);
return
;
}
const
codeDifference
=
code
-
c
;
// 新加入的卡号比某一卡号大,并且 10 以内,则新的卡是那张卡的关联卡,不入。
if
(
codeDifference
>
0
&&
codeDifference
<=
10
)
{
this
.
log
.
debug
(
`Skipped forward-related dup:
${
code
}
${
c
}
`
);
return
;
}
// 新加入的卡号比某一卡号小,并且 10 以内,则把旧的卡删掉。-
if
(
codeDifference
<
0
&&
codeDifference
>=
-
10
)
{
this
.
log
.
debug
(
`Would remove backword-related dup:
${
code
}
${
c
}
`
);
posToRemove
.
push
(
i
);
}
}
posToRemove
.
sort
((
a
,
b
)
=>
b
-
a
);
for
(
const
pos
of
posToRemove
)
{
const
codeRemoved
=
this
.
cardCodes
.
splice
(
pos
,
1
);
this
.
log
.
debug
(
`Removed backword-related dup:
${
codeRemoved
}
`
);
}
this
.
cardCodes
.
push
(
code
);
}
private
async
workWithYdk
(
ydkFile
:
string
)
{
this
.
log
.
info
(
`Reading
${
ydkFile
}
.`
);
const
content
=
await
fs
.
readFile
(
`./packs/
${
ydkFile
}
`
,
'
utf-8
'
);
for
(
let
line
of
content
.
split
(
'
\n
'
))
{
const
match
=
line
.
trim
().
match
(
/^
(\d{5,9})
$/
);
if
(
!
match
)
{
continue
;
}
const
code
=
parseInt
(
match
[
1
]);
this
.
addCode
(
code
);
}
}
async
fetch
():
Promise
<
Card
[]
>
{
this
.
log
.
info
(
`Started reading from ydk cards.`
);
const
ydkFiles
=
await
fs
.
readdir
(
'
./packs
'
);
this
.
log
.
info
(
`
${
ydkFiles
.
length
}
packs found.`
);
for
(
let
file
of
ydkFiles
)
{
await
this
.
workWithYdk
(
file
);
}
const
finalCodes
=
this
.
cardCodes
;
this
.
log
.
info
(
`
${
finalCodes
.
length
}
cards in total.`
);
return
finalCodes
.
map
(
code
=>
new
Card
(
code
));
}
}
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