fix: reserve auction points for remaining slots
This commit is contained in:
1 parent
bac29ac933
commit
b0dc857463
3 files changed
+175
-20
No files matched your search
@@ -26,6 +26,7 @@ import { TournamentCodeService } from '../tournament-code/tournament-code.servic
|
||||
import { TournamentResultService } from '../tournament-result/tournament-result.service';
|
||||
|
||||
const AUCTION_MAX_TEAM_SIZE = 5;
|
||||
const AUCTION_MIN_BID_POINTS = 10;
|
||||
const AUCTION_BACKGROUND_ENRICHMENT_CONCURRENCY = 1;
|
||||
const AUCTION_ENRICHMENT_COOLDOWN_MS = 3 * 60 * 60 * 1000;
|
||||
const AUCTION_CHAT_MAX_MESSAGES = 200;
|
||||
@@ -318,6 +319,11 @@ export class AuctionService {
|
||||
throw new BadRequestException('Bid exceeds team points.');
|
||||
}
|
||||
this.assertTeamHasSlot(team);
|
||||
if (params.amount > this.calculateMaxBidForTeam(team)) {
|
||||
throw new BadRequestException(
|
||||
'Bid must reserve minimum points for remaining slots.',
|
||||
);
|
||||
}
|
||||
// 임시 운영용: 클라이언트에서 선택한 팀장 모드를 신뢰하고 실제 로그인 사용자 검증은 건너뛴다.
|
||||
|
||||
await this.recordSnapshot(auction, 'bid', params.bidderUserId);
|
||||
@@ -809,6 +815,16 @@ export class AuctionService {
|
||||
}
|
||||
}
|
||||
|
||||
private calculateMaxBidForTeam(team: AuctionTeam): number {
|
||||
const remainingSlotsAfterCurrentBid = Math.max(
|
||||
0,
|
||||
AUCTION_MAX_TEAM_SIZE - this.countTeamMembersIncludingCaptain(team) - 1,
|
||||
);
|
||||
const reservedPoints =
|
||||
remainingSlotsAfterCurrentBid * AUCTION_MIN_BID_POINTS;
|
||||
return Math.max(0, team.points - reservedPoints);
|
||||
}
|
||||
|
||||
private countTeamMembersIncludingCaptain(team: AuctionTeam): number {
|
||||
const userIds = new Set<string>([team.captainUserId.toString()]);
|
||||
for (const member of team.members) {
|
||||
|
||||
Reference in new issue
Block a user