Skip to content

Commit

Permalink
Only show avaialble quick matches that match rank restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Nov 27, 2024
1 parent ea18858 commit 08c5578
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Which backend server would you like to use today? ...
let BACKEND = process.env.OGS_BACKEND || "BETA";
BACKEND = BACKEND.toUpperCase();
//BACKEND = 'PRODUCTION';
//BACKEND = 'LOCAL';
//BACKEND = "PRODUCTION";
//BACKEND = "LOCAL";

import { spawn, execSync } from "child_process";
import fs from "fs";
Expand Down
29 changes: 22 additions & 7 deletions src/views/Play/AvailableQuickMatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ import * as preferences from "@/lib/preferences";
import moment from "moment";
*/

export function AvailableQuickMatches(): JSX.Element {
interface AvailableQuickMatchesProps {
lower_rank_diff: number;
upper_rank_diff: number;
}

export function AvailableQuickMatches({
lower_rank_diff,
upper_rank_diff,
}: AvailableQuickMatchesProps): JSX.Element {
const available = React.useRef<{ [uuid: string]: any }>({});
const refresh = useRefresh();
const user = useUser();
Expand Down Expand Up @@ -58,11 +66,18 @@ export function AvailableQuickMatches(): JSX.Element {
};
}, []);

const available_list = Object.values(available.current).filter(
(entry) =>
entry.player.id !== user.id &&
entry.preferences.size_speed_options[0].speed !== "correspondence",
);
const available_list = Object.values(available.current).filter((entry) => {
return (
(user.anonymous ||
(entry.player.id !== user.id &&
entry.player.bounded_rank >= user.ranking - lower_rank_diff &&
entry.player.bounded_rank <= user.ranking + upper_rank_diff &&
user.ranking >= entry.player.bounded_rank - entry.preferences.lower_rank_diff &&
user.ranking <=
entry.player.bounded_rank + entry.preferences.upper_rank_diff)) &&
entry.preferences.size_speed_options[0].speed !== "correspondence"
);
});
available_list.sort((a, b) => {
const a_speed = a.preferences.size_speed_options[0].speed;
const b_speed = b.preferences.size_speed_options[0].speed;
Expand All @@ -81,7 +96,7 @@ export function AvailableQuickMatches(): JSX.Element {
<h4>
{llm_pgettext(
"Active automatch searches",
"Active quick match searches by other players",
"Active quick match searches by other players within your rank range",
)}
</h4>
<div className="AvailableQuickMatches">
Expand Down
5 changes: 4 additions & 1 deletion src/views/Play/QuickMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,10 @@ export function QuickMatch(): JSX.Element {
</div>
</div>
</div>
<AvailableQuickMatches />
<AvailableQuickMatches
lower_rank_diff={lower_rank_diff}
upper_rank_diff={upper_rank_diff}
/>
</>
);
}

0 comments on commit 08c5578

Please sign in to comment.