Commit 64cd40bb authored by nanahira's avatar nanahira

lint

parent 7eb92860
......@@ -25,7 +25,7 @@ import { HttpModule } from '@nestjs/axios';
...MycardAuthModule.registerAsync({
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
accountUrl: config.get('ACCOUNT_ENDPOINT')
accountUrl: config.get('ACCOUNT_ENDPOINT'),
}),
}),
global: true,
......
......@@ -63,18 +63,23 @@ export class TournamentRuleBase {
if (!winnerId) {
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;
map.set(pid, score);
}
} else {
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;
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;
map.set(loserId, loseScore);
}
......@@ -85,7 +90,9 @@ export class TournamentRuleBase {
}
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> {
......
......@@ -141,10 +141,12 @@ export class Swiss extends TournamentRuleBase {
participantScoreAfter(participant: Participant): Partial<ParticipantScore> {
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 {
tieBreaker: _.sumBy(opponents, (p) => p.score.score),
...(participant.quit ? { score: -1 } : {})
...(participant.quit ? { score: -1 } : {}),
};
}
}
......@@ -248,8 +248,10 @@ export class Tournament extends DescBase {
p.score = new ParticipantScore();
Object.assign(p.score, rule.participantScore(p));
});
const editScores = this.participants.map((p) => rule.participantScoreAfter(p));
this.participants.forEach((p, i) => Object.assign(p.score, editScores[i]))
const editScores = this.participants.map((p) =>
rule.participantScoreAfter(p),
);
this.participants.forEach((p, i) => Object.assign(p.score, editScores[i]));
this.participants = _.sortBy(
this.participants,
(p) => -p.score.score,
......
......@@ -67,7 +67,11 @@ export class TournamentService extends CrudService(Tournament, {
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) =>
Tournament.extraQueryForUser(user, qb, this.entityAliasName),
);
......@@ -75,7 +79,7 @@ export class TournamentService extends CrudService(Tournament, {
result.data.participants?.forEach((p) =>
this.participantService.wipeDeckbuf(user, p, result.data),
);
if(result.data.status === TournamentStatus.Ready && !noAnalytics) {
if (result.data.status === TournamentStatus.Ready && !noAnalytics) {
result.data.analytics();
}
}
......@@ -314,9 +318,7 @@ export class TournamentService extends CrudService(Tournament, {
).toException();
}
participants = sortAfterSwiss(
participants
.filter((p) => !p.quit)
.slice(0, dto.swissMaxPlayers),
participants.filter((p) => !p.quit).slice(0, dto.swissMaxPlayers),
);
}
} else if (dto.ygobbsCompt) {
......
......@@ -9,7 +9,10 @@ export const multerToParticipant = (
const participant = new Participant();
participant.quit = false;
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.tournamentId = tournamentId;
participant.deckbuf = Buffer.from(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment