mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-10 12:44:47 -05:00
Don't show weapons when looking for match
This commit is contained in:
parent
d423fbd347
commit
ec8437583b
|
|
@ -10,6 +10,7 @@ const infos = rawInfos as Partial<
|
|||
|
||||
export function addInfoFromOldSendouInk(
|
||||
type: "LEAGUE" | "SOLO",
|
||||
showWeapons: boolean,
|
||||
data: LookingLoaderData
|
||||
): LookingLoaderData {
|
||||
return {
|
||||
|
|
@ -27,7 +28,7 @@ export function addInfoFromOldSendouInk(
|
|||
const playerInfos = infos[member.discordId];
|
||||
return {
|
||||
...member,
|
||||
weapons: playerInfos?.weapons?.slice(0, 3),
|
||||
weapons: showWeapons ? playerInfos?.weapons?.slice(0, 3) : undefined,
|
||||
peakXP: type === "SOLO" ? playerInfos?.peakXP : undefined,
|
||||
peakLP: type === "LEAGUE" ? playerInfos?.peakLP : undefined,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -250,77 +250,84 @@ export const loader: LoaderFunction = async ({ context }) => {
|
|||
const { EXPIRED: expiredDate } = groupExpiredDates();
|
||||
|
||||
return json<LookingLoaderData>(
|
||||
addInfoFromOldSendouInk(ownGroup.type === "VERSUS" ? "SOLO" : "LEAGUE", {
|
||||
ownGroup: ownGroupForResponse,
|
||||
type: ownGroup.type,
|
||||
isCaptain: isGroupAdmin({ group: ownGroup, user }),
|
||||
lastActionAtTimestamp: ownGroup.lastActionAt.getTime(),
|
||||
...groupsOfType
|
||||
.filter(
|
||||
(group) =>
|
||||
(lookingForMatch && group.members.length === LFG_GROUP_FULL_SIZE) ||
|
||||
canUniteWithGroup({
|
||||
ownGroupType: ownGroup.type,
|
||||
ownGroupSize: ownGroup.members.length,
|
||||
otherGroupSize: group.members.length,
|
||||
})
|
||||
)
|
||||
.filter((group) => group.id !== ownGroup.id)
|
||||
.filter((group) => group.lastActionAt.getTime() > expiredDate.getTime())
|
||||
.map((group) => {
|
||||
const ranked = () => {
|
||||
if (lookingForMatch && !ownGroup.ranked) return false;
|
||||
addInfoFromOldSendouInk(
|
||||
ownGroup.type === "VERSUS" ? "SOLO" : "LEAGUE",
|
||||
!lookingForMatch,
|
||||
{
|
||||
ownGroup: ownGroupForResponse,
|
||||
type: ownGroup.type,
|
||||
isCaptain: isGroupAdmin({ group: ownGroup, user }),
|
||||
lastActionAtTimestamp: ownGroup.lastActionAt.getTime(),
|
||||
...groupsOfType
|
||||
.filter(
|
||||
(group) =>
|
||||
(lookingForMatch &&
|
||||
group.members.length === LFG_GROUP_FULL_SIZE) ||
|
||||
canUniteWithGroup({
|
||||
ownGroupType: ownGroup.type,
|
||||
ownGroupSize: ownGroup.members.length,
|
||||
otherGroupSize: group.members.length,
|
||||
})
|
||||
)
|
||||
.filter((group) => group.id !== ownGroup.id)
|
||||
.filter(
|
||||
(group) => group.lastActionAt.getTime() > expiredDate.getTime()
|
||||
)
|
||||
.map((group) => {
|
||||
const ranked = () => {
|
||||
if (lookingForMatch && !ownGroup.ranked) return false;
|
||||
|
||||
return group.ranked ?? undefined;
|
||||
};
|
||||
return {
|
||||
id: group.id,
|
||||
// When looking for a match ranked groups are censored
|
||||
// and instead we only reveal their approximate skill level
|
||||
members:
|
||||
ownGroup.ranked && group.ranked && lookingForMatch
|
||||
? undefined
|
||||
: group.members.map((m) => {
|
||||
const { skill, ...rest } = m.user;
|
||||
return group.ranked ?? undefined;
|
||||
};
|
||||
return {
|
||||
id: group.id,
|
||||
// When looking for a match ranked groups are censored
|
||||
// and instead we only reveal their approximate skill level
|
||||
members:
|
||||
ownGroup.ranked && group.ranked && lookingForMatch
|
||||
? undefined
|
||||
: group.members.map((m) => {
|
||||
const { skill, ...rest } = m.user;
|
||||
|
||||
return {
|
||||
...rest,
|
||||
MMR: skillToMMR(skill),
|
||||
};
|
||||
}),
|
||||
ranked: ranked(),
|
||||
teamMMR:
|
||||
lookingForMatch && group.ranked && teamHasSkill(group.members)
|
||||
? {
|
||||
exact: false,
|
||||
value: teamSkillToApproximateMMR(group.members),
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
})
|
||||
.reduce(
|
||||
(
|
||||
acc: Omit<
|
||||
LookingLoaderData,
|
||||
"ownGroup" | "type" | "isCaptain" | "lastActionAtTimestamp"
|
||||
>,
|
||||
group
|
||||
) => {
|
||||
// likesReceived first so that if both received like and
|
||||
// given like then handle this edge case by just displaying the
|
||||
// group as waiting like back
|
||||
if (likesReceived.has(group.id)) {
|
||||
acc.likerGroups.push(group);
|
||||
} else if (likesGiven.has(group.id)) {
|
||||
acc.likedGroups.push(group);
|
||||
} else {
|
||||
acc.neutralGroups.push(group);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{ likedGroups: [], neutralGroups: [], likerGroups: [] }
|
||||
),
|
||||
})
|
||||
return {
|
||||
...rest,
|
||||
MMR: skillToMMR(skill),
|
||||
};
|
||||
}),
|
||||
ranked: ranked(),
|
||||
teamMMR:
|
||||
lookingForMatch && group.ranked && teamHasSkill(group.members)
|
||||
? {
|
||||
exact: false,
|
||||
value: teamSkillToApproximateMMR(group.members),
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
})
|
||||
.reduce(
|
||||
(
|
||||
acc: Omit<
|
||||
LookingLoaderData,
|
||||
"ownGroup" | "type" | "isCaptain" | "lastActionAtTimestamp"
|
||||
>,
|
||||
group
|
||||
) => {
|
||||
// likesReceived first so that if both received like and
|
||||
// given like then handle this edge case by just displaying the
|
||||
// group as waiting like back
|
||||
if (likesReceived.has(group.id)) {
|
||||
acc.likerGroups.push(group);
|
||||
} else if (likesGiven.has(group.id)) {
|
||||
acc.likedGroups.push(group);
|
||||
} else {
|
||||
acc.neutralGroups.push(group);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{ likedGroups: [], neutralGroups: [], likerGroups: [] }
|
||||
),
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user