Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tabulator-another
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
tabulator-another
Commits
64cd40bb
Commit
64cd40bb
authored
Jul 29, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint
parent
7eb92860
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
15 deletions
+31
-15
src/app.module.ts
src/app.module.ts
+1
-1
src/tournament-rules/base.ts
src/tournament-rules/base.ts
+11
-4
src/tournament-rules/rules/swiss.ts
src/tournament-rules/rules/swiss.ts
+4
-2
src/tournament/entities/Tournament.entity.ts
src/tournament/entities/Tournament.entity.ts
+4
-2
src/tournament/tournament.service.ts
src/tournament/tournament.service.ts
+7
-5
src/utility/multer-to-participant.ts
src/utility/multer-to-participant.ts
+4
-1
No files found.
src/app.module.ts
View file @
64cd40bb
...
@@ -25,7 +25,7 @@ import { HttpModule } from '@nestjs/axios';
...
@@ -25,7 +25,7 @@ import { HttpModule } from '@nestjs/axios';
...
MycardAuthModule
.
registerAsync
({
...
MycardAuthModule
.
registerAsync
({
inject
:
[
ConfigService
],
inject
:
[
ConfigService
],
useFactory
:
async
(
config
:
ConfigService
)
=>
({
useFactory
:
async
(
config
:
ConfigService
)
=>
({
accountUrl
:
config
.
get
(
'
ACCOUNT_ENDPOINT
'
)
accountUrl
:
config
.
get
(
'
ACCOUNT_ENDPOINT
'
)
,
}),
}),
}),
}),
global
:
true
,
global
:
true
,
...
...
src/tournament-rules/base.ts
View file @
64cd40bb
...
@@ -63,18 +63,23 @@ export class TournamentRuleBase {
...
@@ -63,18 +63,23 @@ export class TournamentRuleBase {
if
(
!
winnerId
)
{
if
(
!
winnerId
)
{
for
(
const
pid
of
[
player1Id
,
player2Id
])
{
for
(
const
pid
of
[
player1Id
,
player2Id
])
{
const
score
=
map
.
get
(
pid
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
;
const
score
=
map
.
get
(
pid
)
??
({
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
);
score
.
draw
+=
1
;
score
.
draw
+=
1
;
map
.
set
(
pid
,
score
);
map
.
set
(
pid
,
score
);
}
}
}
else
{
}
else
{
const
loserId
=
winnerId
===
player1Id
?
player2Id
:
player1Id
;
const
loserId
=
winnerId
===
player1Id
?
player2Id
:
player1Id
;
const
winScore
=
map
.
get
(
winnerId
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
;
const
winScore
=
map
.
get
(
winnerId
)
??
({
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
);
winScore
.
win
+=
1
;
winScore
.
win
+=
1
;
map
.
set
(
winnerId
,
winScore
);
map
.
set
(
winnerId
,
winScore
);
const
loseScore
=
map
.
get
(
loserId
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
;
const
loseScore
=
map
.
get
(
loserId
)
??
({
win
:
0
,
lose
:
0
,
draw
:
0
}
as
ParticipantScore
);
loseScore
.
lose
+=
1
;
loseScore
.
lose
+=
1
;
map
.
set
(
loserId
,
loseScore
);
map
.
set
(
loserId
,
loseScore
);
}
}
...
@@ -85,7 +90,9 @@ export class TournamentRuleBase {
...
@@ -85,7 +90,9 @@ export class TournamentRuleBase {
}
}
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
participantScore
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
return
this
.
getScoreMap
().
get
(
participant
.
id
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
};
return
(
this
.
getScoreMap
().
get
(
participant
.
id
)
??
{
win
:
0
,
lose
:
0
,
draw
:
0
}
);
}
}
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
...
...
src/tournament-rules/rules/swiss.ts
View file @
64cd40bb
...
@@ -141,10 +141,12 @@ export class Swiss extends TournamentRuleBase {
...
@@ -141,10 +141,12 @@ export class Swiss extends TournamentRuleBase {
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
participantScoreAfter
(
participant
:
Participant
):
Partial
<
ParticipantScore
>
{
const
opponentIds
=
this
.
getOpponentMap
().
get
(
participant
.
id
)
??
new
Set
();
const
opponentIds
=
this
.
getOpponentMap
().
get
(
participant
.
id
)
??
new
Set
();
const
opponents
=
Array
.
from
(
opponentIds
).
map
((
id
)
=>
this
.
participantMap
.
get
(
id
));
const
opponents
=
Array
.
from
(
opponentIds
).
map
((
id
)
=>
this
.
participantMap
.
get
(
id
),
);
return
{
return
{
tieBreaker
:
_
.
sumBy
(
opponents
,
(
p
)
=>
p
.
score
.
score
),
tieBreaker
:
_
.
sumBy
(
opponents
,
(
p
)
=>
p
.
score
.
score
),
...(
participant
.
quit
?
{
score
:
-
1
}
:
{})
...(
participant
.
quit
?
{
score
:
-
1
}
:
{})
,
};
};
}
}
}
}
src/tournament/entities/Tournament.entity.ts
View file @
64cd40bb
...
@@ -248,8 +248,10 @@ export class Tournament extends DescBase {
...
@@ -248,8 +248,10 @@ export class Tournament extends DescBase {
p
.
score
=
new
ParticipantScore
();
p
.
score
=
new
ParticipantScore
();
Object
.
assign
(
p
.
score
,
rule
.
participantScore
(
p
));
Object
.
assign
(
p
.
score
,
rule
.
participantScore
(
p
));
});
});
const
editScores
=
this
.
participants
.
map
((
p
)
=>
rule
.
participantScoreAfter
(
p
));
const
editScores
=
this
.
participants
.
map
((
p
)
=>
this
.
participants
.
forEach
((
p
,
i
)
=>
Object
.
assign
(
p
.
score
,
editScores
[
i
]))
rule
.
participantScoreAfter
(
p
),
);
this
.
participants
.
forEach
((
p
,
i
)
=>
Object
.
assign
(
p
.
score
,
editScores
[
i
]));
this
.
participants
=
_
.
sortBy
(
this
.
participants
=
_
.
sortBy
(
this
.
participants
,
this
.
participants
,
(
p
)
=>
-
p
.
score
.
score
,
(
p
)
=>
-
p
.
score
.
score
,
...
...
src/tournament/tournament.service.ts
View file @
64cd40bb
...
@@ -67,7 +67,11 @@ export class TournamentService extends CrudService(Tournament, {
...
@@ -67,7 +67,11 @@ export class TournamentService extends CrudService(Tournament, {
private
cmptApiToken
=
this
.
config
.
get
<
string
>
(
'
CMPT_API_TOKEN
'
,
''
);
private
cmptApiToken
=
this
.
config
.
get
<
string
>
(
'
CMPT_API_TOKEN
'
,
''
);
async
getTournament
(
id
:
number
,
user
:
MycardUser
|
number
,
noAnalytics
=
false
)
{
async
getTournament
(
id
:
number
,
user
:
MycardUser
|
number
,
noAnalytics
=
false
,
)
{
const
result
=
await
this
.
findOne
(
id
,
(
qb
)
=>
const
result
=
await
this
.
findOne
(
id
,
(
qb
)
=>
Tournament
.
extraQueryForUser
(
user
,
qb
,
this
.
entityAliasName
),
Tournament
.
extraQueryForUser
(
user
,
qb
,
this
.
entityAliasName
),
);
);
...
@@ -75,7 +79,7 @@ export class TournamentService extends CrudService(Tournament, {
...
@@ -75,7 +79,7 @@ export class TournamentService extends CrudService(Tournament, {
result
.
data
.
participants
?.
forEach
((
p
)
=>
result
.
data
.
participants
?.
forEach
((
p
)
=>
this
.
participantService
.
wipeDeckbuf
(
user
,
p
,
result
.
data
),
this
.
participantService
.
wipeDeckbuf
(
user
,
p
,
result
.
data
),
);
);
if
(
result
.
data
.
status
===
TournamentStatus
.
Ready
&&
!
noAnalytics
)
{
if
(
result
.
data
.
status
===
TournamentStatus
.
Ready
&&
!
noAnalytics
)
{
result
.
data
.
analytics
();
result
.
data
.
analytics
();
}
}
}
}
...
@@ -314,9 +318,7 @@ export class TournamentService extends CrudService(Tournament, {
...
@@ -314,9 +318,7 @@ export class TournamentService extends CrudService(Tournament, {
).
toException
();
).
toException
();
}
}
participants
=
sortAfterSwiss
(
participants
=
sortAfterSwiss
(
participants
participants
.
filter
((
p
)
=>
!
p
.
quit
).
slice
(
0
,
dto
.
swissMaxPlayers
),
.
filter
((
p
)
=>
!
p
.
quit
)
.
slice
(
0
,
dto
.
swissMaxPlayers
),
);
);
}
}
}
else
if
(
dto
.
ygobbsCompt
)
{
}
else
if
(
dto
.
ygobbsCompt
)
{
...
...
src/utility/multer-to-participant.ts
View file @
64cd40bb
...
@@ -9,7 +9,10 @@ export const multerToParticipant = (
...
@@ -9,7 +9,10 @@ export const multerToParticipant = (
const
participant
=
new
Participant
();
const
participant
=
new
Participant
();
participant
.
quit
=
false
;
participant
.
quit
=
false
;
participant
.
seq
=
1000
;
participant
.
seq
=
1000
;
const
rawName
=
iconv
.
decode
(
Buffer
.
from
(
multerFile
.
originalname
,
'
binary
'
),
'
utf-8
'
);
const
rawName
=
iconv
.
decode
(
Buffer
.
from
(
multerFile
.
originalname
,
'
binary
'
),
'
utf-8
'
,
);
participant
.
name
=
rawName
.
replace
(
/
(\.
ydk
)
+$/i
,
''
);
participant
.
name
=
rawName
.
replace
(
/
(\.
ydk
)
+$/i
,
''
);
participant
.
tournamentId
=
tournamentId
;
participant
.
tournamentId
=
tournamentId
;
participant
.
deckbuf
=
Buffer
.
from
(
participant
.
deckbuf
=
Buffer
.
from
(
...
...
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