.
This commit is contained in:
1 parent
ec2315cc3d
commit
dfcfe9e4ad
3 files changed
+116
-3
No files matched your search
@@ -9,12 +9,15 @@ import { ConnectionService } from '../global/database/connection.service';
|
||||
import {
|
||||
AuctionDocument,
|
||||
AuctionPlayerSnapshot,
|
||||
AuctionTeam,
|
||||
MatchTeamMember,
|
||||
Position,
|
||||
TeamSide,
|
||||
} from '../global/database/schema';
|
||||
import { RiotAccountEnrichmentService } from '../riot/riot-account-enrichment.service';
|
||||
|
||||
const AUCTION_MAX_TEAM_SIZE = 5;
|
||||
|
||||
interface StartAuctionParams {
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
communityId: mongoose.Types.ObjectId;
|
||||
@@ -71,6 +74,14 @@ export class AuctionService {
|
||||
'Both captains must be participants of the match.',
|
||||
);
|
||||
}
|
||||
if (
|
||||
match.participants.length >
|
||||
params.captains.length * AUCTION_MAX_TEAM_SIZE
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
'Auction supports up to 5 members per team including captains.',
|
||||
);
|
||||
}
|
||||
|
||||
const basePlayerUsers = await UserModel.find({
|
||||
_id: {
|
||||
@@ -204,6 +215,7 @@ export class AuctionService {
|
||||
if (params.amount > team.points) {
|
||||
throw new BadRequestException('Bid exceeds team points.');
|
||||
}
|
||||
this.assertTeamHasSlot(team);
|
||||
// 임시 운영용: 클라이언트에서 선택한 팀장 모드를 신뢰하고 실제 로그인 사용자 검증은 건너뛴다.
|
||||
|
||||
auction.currentBid = params.amount;
|
||||
@@ -231,6 +243,7 @@ export class AuctionService {
|
||||
}
|
||||
const team = auction.teams.find((t) => t.side === auction.currentBidder);
|
||||
if (!team) throw new BadRequestException('Winning team not found.');
|
||||
this.assertTeamHasSlot(team);
|
||||
|
||||
const current = auction.order[auction.currentIndex];
|
||||
if (!current) throw new BadRequestException('No current player.');
|
||||
@@ -327,6 +340,20 @@ export class AuctionService {
|
||||
return Math.max(5, remainingSeconds);
|
||||
}
|
||||
|
||||
private assertTeamHasSlot(team: AuctionTeam): void {
|
||||
if (this.countTeamMembersIncludingCaptain(team) >= AUCTION_MAX_TEAM_SIZE) {
|
||||
throw new BadRequestException('Team already has maximum members.');
|
||||
}
|
||||
}
|
||||
|
||||
private countTeamMembersIncludingCaptain(team: AuctionTeam): number {
|
||||
const userIds = new Set<string>([team.captainUserId.toString()]);
|
||||
for (const member of team.members) {
|
||||
userIds.add(member.userId.toString());
|
||||
}
|
||||
return userIds.size;
|
||||
}
|
||||
|
||||
private async syncMatchTeamsFromAuction(
|
||||
auction: AuctionDocument,
|
||||
): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user