feat: add double elimination match mode
This commit is contained in:
1 parent
b9aaf55193
commit
e12f182e7f
19 files changed
+3415
-58
No files matched your search
@@ -25,8 +25,11 @@ import type {
|
||||
} from '../global/database/schema';
|
||||
import {
|
||||
AddParticipantDto,
|
||||
ApplyDoubleEliminationWalkoverDto,
|
||||
CancelDoubleEliminationActionDto,
|
||||
CreateMatchDto,
|
||||
JoinMatchDto,
|
||||
SwapDoubleEliminationSeedsDto,
|
||||
UpdateMatchDto,
|
||||
UpdateParticipantDto,
|
||||
} from './dto/create-match.dto';
|
||||
@@ -58,6 +61,8 @@ export class MatchController {
|
||||
gameCount: body.gameCount,
|
||||
gameMode: body.gameMode ?? 'pair',
|
||||
roundRobinMaxRounds: body.roundRobinMaxRounds,
|
||||
doubleEliminationResetFinalEnabled:
|
||||
body.doubleEliminationResetFinalEnabled,
|
||||
prizes: body.prizes ?? [],
|
||||
notices: body.notices ?? [],
|
||||
schedule: body.schedule ?? [],
|
||||
@@ -121,6 +126,116 @@ export class MatchController {
|
||||
return this.matchService.update({ matchId, communityId, patch: body });
|
||||
}
|
||||
|
||||
@Post(':matchId/double-elimination/seeds/reshuffle')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async reshuffleDoubleEliminationSeeds(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.reshuffleDoubleEliminationSeeds({
|
||||
matchId,
|
||||
communityId,
|
||||
actorUserId: currentUser._id,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
@Post(':matchId/double-elimination/seeds/swap')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async swapDoubleEliminationSeeds(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Body() body: SwapDoubleEliminationSeedsDto,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.swapDoubleEliminationSeeds({
|
||||
matchId,
|
||||
communityId,
|
||||
actorUserId: currentUser._id,
|
||||
leftSeedNumber: body.leftSeedNumber,
|
||||
rightSeedNumber: body.rightSeedNumber,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
@Post(':matchId/double-elimination/bracket-matches/:bracketMatchId/walkover')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async applyDoubleEliminationWalkover(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Param('bracketMatchId') bracketMatchId: string,
|
||||
@Body() body: ApplyDoubleEliminationWalkoverDto,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.applyDoubleEliminationWalkover({
|
||||
matchId,
|
||||
communityId,
|
||||
actorUserId: currentUser._id,
|
||||
bracketMatchId,
|
||||
winnerTeamIndex: body.winnerTeamIndex,
|
||||
reason: body.reason,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
@Post(
|
||||
':matchId/double-elimination/bracket-matches/:bracketMatchId/walkover/cancel',
|
||||
)
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async cancelDoubleEliminationWalkover(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Param('bracketMatchId') bracketMatchId: string,
|
||||
@Body() body: CancelDoubleEliminationActionDto,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.cancelDoubleEliminationWalkover({
|
||||
matchId,
|
||||
communityId,
|
||||
actorUserId: currentUser._id,
|
||||
bracketMatchId,
|
||||
reason: body.reason,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
@Post(
|
||||
':matchId/double-elimination/bracket-matches/:bracketMatchId/result/cancel',
|
||||
)
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
public async cancelDoubleEliminationRiotResult(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
@Param('bracketMatchId') bracketMatchId: string,
|
||||
@Body() body: CancelDoubleEliminationActionDto,
|
||||
) {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.cancelDoubleEliminationRiotResult({
|
||||
matchId,
|
||||
communityId,
|
||||
actorUserId: currentUser._id,
|
||||
bracketMatchId,
|
||||
reason: body.reason,
|
||||
});
|
||||
return this.matchService.serialize(match);
|
||||
}
|
||||
|
||||
@Delete(':matchId')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
|
||||
Reference in new issue
Block a user