Reshow ranked team MMR's

This commit is contained in:
Kalle
2022-02-21 21:40:44 +02:00
parent 789d77abbd
commit f317b9cb1f
2 changed files with 17 additions and 3 deletions

View File

@@ -47,6 +47,19 @@ function toTwoDecimals(value: number) {
return Number(value.toFixed(2));
}
export function teamHasSkill(teamSkills: TeamSkill[]) {
let hasSkill = false;
for (const { user } of teamSkills) {
if (user.skill.length > 0) {
hasSkill = true;
break;
}
}
return hasSkill;
}
interface AdjustSkill {
mu: number;
sigma: number;

View File

@@ -17,6 +17,7 @@ import { Tab } from "~/components/Tab";
import { LFG_GROUP_FULL_SIZE } from "~/constants";
import {
skillToMMR,
teamHasSkill,
teamSkillToApproximateMMR,
teamSkillToExactMMR,
} from "~/core/mmr/utils";
@@ -223,7 +224,7 @@ export const loader: LoaderFunction = async ({ context }) => {
new Set<string>()
);
const isRanked = groupsOfType.every((g) => g.ranked);
const isRanked = groupsOfType.some((g) => g.ranked);
const ownGroupWithMembers = groupsOfType.find((g) => g.id === ownGroup.id);
invariant(ownGroupWithMembers, "ownGroupWithMembers is undefined");
const ownGroupForResponse: LookingLoaderDataGroup = {
@@ -238,7 +239,7 @@ export const loader: LoaderFunction = async ({ context }) => {
}),
ranked: ownGroup.ranked ?? undefined,
teamMMR:
lookingForMatch && isRanked
lookingForMatch && isRanked && teamHasSkill(ownGroupWithMembers.members)
? {
exact: true,
value: teamSkillToExactMMR(ownGroupWithMembers.members),
@@ -289,7 +290,7 @@ export const loader: LoaderFunction = async ({ context }) => {
}),
ranked: ranked(),
teamMMR:
lookingForMatch && isRanked
lookingForMatch && group.ranked && teamHasSkill(group.members)
? {
exact: false,
value: teamSkillToApproximateMMR(group.members),