Skip to content

Commit

Permalink
Add support for pro ranks in rank range, add debugging info for bot f…
Browse files Browse the repository at this point in the history
…iltering
  • Loading branch information
anoek committed Dec 10, 2024
1 parent 3055e67 commit 2fc9ad0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/bots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,19 @@ export function getAcceptableTimeSetting(

/* Check allowed rank */
function rankNumber(rank: string) {
if (rank.endsWith("d") || rank.endsWith("D")) {
if (rank.endsWith("p") || rank.endsWith("p")) {
return parseInt(rank) + 45;
} else if (rank.endsWith("d") || rank.endsWith("D")) {
return parseInt(rank) + 30;
} else {
return 30 - parseInt(rank);
}
}

if (
options.rank < rankNumber(bot.config?.allowed_rank_range[0]) ||
options.rank > rankNumber(bot.config?.allowed_rank_range[1])
bot.config?.allowed_rank_range &&
(options.rank < rankNumber(bot.config?.allowed_rank_range[0]) ||
options.rank > rankNumber(bot.config?.allowed_rank_range[1]))
) {
return [null, "Rank not accepted"];
}
Expand Down
4 changes: 4 additions & 0 deletions src/views/Play/QuickMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ const select_styles = {
}),
};

(window as any)["processed_bot_list"] = [];

export function QuickMatch(): JSX.Element {
const user = useUser();
const refresh = useRefresh();
Expand Down Expand Up @@ -593,6 +595,7 @@ export function QuickMatch(): JSX.Element {
let available_bots = bots_list().filter((b) => b.id > 0);

if (game_clock !== "multiple") {
(window as any)["processed_bot_list"] = [];
available_bots = available_bots.filter((b) => {
const settings = {
rank: user.ranking,
Expand All @@ -605,6 +608,7 @@ export function QuickMatch(): JSX.Element {
[time_control_system]: SPEED_OPTIONS[board_size][game_speed][time_control_system],
};
const [options, _message] = getAcceptableTimeSetting(b, settings);
(window as any)["processed_bot_list"].push([b, options, _message]);
/*
if (!options) {
console.debug(b.username, message, settings);
Expand Down

0 comments on commit 2fc9ad0

Please sign in to comment.