.
This commit is contained in:
1 parent
5af2c80cd1
commit
f7ee34da4f
78 files changed
+9016
-150
No files matched your search
@@ -35,6 +35,8 @@ interface JoinMatchParams {
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
userId: mongoose.Types.ObjectId;
|
||||
preferredPositions: PositionPreference[];
|
||||
// 특정 RiotAccount(puuid)로 참가하고 싶을 때 지정. 없으면 primary 사용.
|
||||
riotPuuid?: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@@ -119,22 +121,22 @@ export class MatchService {
|
||||
if (match.participants.length >= match.maxParticipants) {
|
||||
throw new BadRequestException('Match is full.');
|
||||
}
|
||||
const alreadyIn = match.participants.some((p) =>
|
||||
p.userId.equals(user._id),
|
||||
);
|
||||
const alreadyIn = match.participants.some((p) => p.userId.equals(user._id));
|
||||
if (alreadyIn) {
|
||||
throw new BadRequestException('User already joined this match.');
|
||||
}
|
||||
|
||||
const primaryRiot = user.riotAccounts.find((a) => a.isPrimary);
|
||||
const primaryTier = this.selectParticipantTier(primaryRiot?.tiers ?? []);
|
||||
const selectedRiot = params.riotPuuid
|
||||
? user.riotAccounts.find((a) => a.puuid === params.riotPuuid)
|
||||
: user.riotAccounts.find((a) => a.isPrimary);
|
||||
const selectedTier = this.selectParticipantTier(selectedRiot?.tiers ?? []);
|
||||
match.participants.push({
|
||||
userId: user._id,
|
||||
puuid: primaryRiot?.puuid,
|
||||
gameName: primaryRiot?.gameName,
|
||||
tagLine: primaryRiot?.tagLine,
|
||||
profileIconId: primaryRiot?.profileIconId,
|
||||
tier: primaryTier,
|
||||
puuid: selectedRiot?.puuid,
|
||||
gameName: selectedRiot?.gameName,
|
||||
tagLine: selectedRiot?.tagLine,
|
||||
profileIconId: selectedRiot?.profileIconId,
|
||||
tier: selectedTier,
|
||||
preferredPositions: params.preferredPositions,
|
||||
joinedAt: new Date(),
|
||||
});
|
||||
@@ -148,12 +150,19 @@ export class MatchService {
|
||||
if (!tier) return undefined;
|
||||
|
||||
return {
|
||||
leagueId: tier.leagueId,
|
||||
queueType: tier.queueType,
|
||||
tier: tier.tier,
|
||||
rank: tier.rank,
|
||||
puuid: tier.puuid,
|
||||
leaguePoints: tier.leaguePoints,
|
||||
wins: tier.wins,
|
||||
losses: tier.losses,
|
||||
veteran: tier.veteran,
|
||||
inactive: tier.inactive,
|
||||
freshBlood: tier.freshBlood,
|
||||
hotStreak: tier.hotStreak,
|
||||
miniSeries: tier.miniSeries,
|
||||
fetchedAt: tier.fetchedAt,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user