Commit 485d2019 authored by nanahira's avatar nanahira

fix ranking

parent 26677bd5
......@@ -4,7 +4,6 @@ import {
Participant,
ParticipantScore,
} from '../../participant/entities/participant.entity';
import * as path from 'path';
export class SingleElimination extends TournamentRuleBase {
totalRoundCount() {
......
......@@ -27,6 +27,7 @@ import { ApiProperty, PartialType } from '@nestjs/swagger';
import { Match } from '../../match/entities/match.entity';
import { TournamentRules } from '../../tournament-rules/rule-map';
import _ from 'lodash';
import { RenameClass } from 'nicot/dist/src/utility/rename-class';
export enum TournamentRule {
SingleElimination = 'SingleElimination',
......@@ -78,7 +79,10 @@ export class Tournament extends DescBase {
@NotChangeable()
@Column('jsonb', { comment: '规则设定', default: {} })
@ApiProperty({ type: PartialType(RuleSettings), required: false })
@ApiProperty({
type: RenameClass(PartialType(RuleSettings), 'RuleSettingsPartial'),
required: false,
})
ruleSettings: RuleSettings;
@EnumColumn(TournamentVisibility, {
......@@ -190,10 +194,11 @@ export class Tournament extends DescBase {
p.score = new ParticipantScore();
Object.assign(p.score, rule.participantScore(p));
});
_.sortBy(
this.participants = _.sortBy(
this.participants,
(p) => -p.score.score,
(p) => -p.score.tieBreaker,
(p) => p.id,
);
this.participants.forEach((p, i) => {
p.score.rank = i + 1;
......
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