Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-deckform-filler
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-deckform-filler
Commits
e945c5c3
Commit
e945c5c3
authored
Oct 24, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize single page
parent
fe9fa2b0
Pipeline
#41242
passed with stages
in 55 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
20 deletions
+44
-20
src/app.service.ts
src/app.service.ts
+44
-20
No files found.
src/app.service.ts
View file @
e945c5c3
...
...
@@ -86,7 +86,31 @@ export class AppService extends ConsoleLogger {
doc
.
addPage
(
newPage
);
};
await
copyFirstPageToBottom
();
const
filterType
=
(
type
:
number
)
=>
ydk
.
main
.
filter
((
id
)
=>
{
if
(
!
cardDataMap
[
id
])
{
throw
new
BlankReturnMessageDto
(
404
,
`Card ID
${
id
}
has invalid data`
,
).
toException
();
}
return
cardDataMap
[
id
].
type
===
type
;
});
let
needExtraPage
=
false
;
if
(
[
1
,
2
,
4
].
some
((
type
)
=>
{
const
filtered
=
filterType
(
type
);
const
grouped
=
Object
.
values
(
_
.
groupBy
(
filtered
,
(
id
)
=>
id
));
return
grouped
.
length
>
20
;
})
)
{
await
copyFirstPageToBottom
();
this
.
log
(
`Added extra page to PDF for deck export due to card type overflow.`
,
);
needExtraPage
=
true
;
}
let
pageCount
=
0
;
...
...
@@ -130,10 +154,10 @@ export class AppService extends ConsoleLogger {
spaces
=
20
,
)
=>
{
const
groupedCards
=
Object
.
values
(
_
.
groupBy
(
cards
,
(
id
)
=>
id
));
const
usePages
=
_
.
chunk
(
groupedCards
,
spaces
);
await
ensurePages
(
usePages
.
length
-
1
);
for
(
let
i
=
0
;
i
<
usePages
.
length
;
++
i
)
{
const
currentPageCards
=
usePages
[
i
];
const
drawCardsOnPage
=
async
(
currentPageCards
:
number
[][],
pageIndex
:
number
,
)
=>
{
for
(
let
j
=
0
;
j
<
currentPageCards
.
length
;
++
j
)
{
const
entry
=
currentPageCards
[
j
];
const
qty
=
entry
.
length
;
...
...
@@ -143,34 +167,32 @@ export class AppService extends ConsoleLogger {
doc
,
qty
.
toString
(),
moveDown
(
cord
.
qty
,
j
),
i
+
1
,
pageIndex
,
);
await
this
.
drawTextService
.
drawTextInBox
(
doc
,
cardData
[
`
${
dto
.
lang
||
'
sc
'
}
_name`
]
||
''
,
moveDown
(
cord
.
name
,
j
),
i
+
1
,
pageIndex
,
);
}
await
this
.
drawTextService
.
drawTextInBox
(
doc
,
_
.
sumBy
(
currentPageCards
,
(
s
)
=>
s
.
length
).
toString
(),
moveDown
(
cord
.
qty
,
spaces
),
i
+
1
,
pageIndex
,
);
};
if
(
needExtraPage
)
{
const
usePages
=
_
.
chunk
(
groupedCards
,
spaces
);
await
ensurePages
(
usePages
.
length
-
1
);
for
(
let
i
=
0
;
i
<
usePages
.
length
;
++
i
)
{
await
drawCardsOnPage
(
usePages
[
i
],
i
+
1
);
}
}
else
{
await
drawCardsOnPage
(
groupedCards
,
0
);
}
};
const
filterType
=
(
type
:
number
)
=>
ydk
.
main
.
filter
((
id
)
=>
{
if
(
!
cardDataMap
[
id
])
{
throw
new
BlankReturnMessageDto
(
404
,
`Card ID
${
id
}
has invalid data`
,
).
toException
();
}
return
cardDataMap
[
id
].
type
===
type
;
});
await
drawCards
(
filterType
(
1
),
Coordinates
.
main
.
monsters
);
this
.
log
(
`Filled monster cards.`
);
await
drawCards
(
filterType
(
2
),
Coordinates
.
main
.
spells
);
...
...
@@ -182,7 +204,9 @@ export class AppService extends ConsoleLogger {
await
drawCards
(
ydk
.
side
,
Coordinates
.
side
,
15
);
this
.
log
(
`Filled side deck cards.`
);
doc
.
removePage
(
0
);
if
(
needExtraPage
)
{
doc
.
removePage
(
0
);
}
const
resBuf
=
Buffer
.
from
(
await
doc
.
save
());
this
.
log
(
`Generated PDF buffer for deck export.`
);
...
...
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