From 2fc9ad0ea5dbe5a654730f04167203f261546ffa Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 9 Dec 2024 17:11:30 -0700 Subject: [PATCH] Add support for pro ranks in rank range, add debugging info for bot filtering --- src/lib/bots.ts | 9 ++++++--- src/views/Play/QuickMatch.tsx | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/bots.ts b/src/lib/bots.ts index 3466a9139d..bbb3f1d506 100644 --- a/src/lib/bots.ts +++ b/src/lib/bots.ts @@ -159,7 +159,9 @@ 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); @@ -167,8 +169,9 @@ export function getAcceptableTimeSetting( } 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"]; } diff --git a/src/views/Play/QuickMatch.tsx b/src/views/Play/QuickMatch.tsx index 41e4d4105f..1d2836ee74 100644 --- a/src/views/Play/QuickMatch.tsx +++ b/src/views/Play/QuickMatch.tsx @@ -193,6 +193,8 @@ const select_styles = { }), }; +(window as any)["processed_bot_list"] = []; + export function QuickMatch(): JSX.Element { const user = useUser(); const refresh = useRefresh(); @@ -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, @@ -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);