From 98775d1dc733f41c4edcf3a9667a93052ae863d5 Mon Sep 17 00:00:00 2001 From: Vari Date: Sat, 14 Jun 2025 19:15:52 +0200 Subject: [PATCH] Optimize matchmaking changes --- .../Game/Matchmaking/MatchConfiguration.php | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/dist/app/Models/Game/Matchmaking/MatchConfiguration.php b/dist/app/Models/Game/Matchmaking/MatchConfiguration.php index e275f71..2220191 100644 --- a/dist/app/Models/Game/Matchmaking/MatchConfiguration.php +++ b/dist/app/Models/Game/Matchmaking/MatchConfiguration.php @@ -38,28 +38,11 @@ class MatchConfiguration extends Model */ public static function getAvailableMatchConfigs(int $runnerCount, int $hunterCount): Collection { - $availableMatchConfigs = null - - if($hunterCount == 1 and $runnerCount >= 6) { - $availableMatchConfigs = MatchConfiguration::where('runners', '>=', 6) - ->where('hunters', '=', $hunterCount) - ->where('enabled', '=', true) - ->get(); - } elseif ($hunterCount == 1 and $runnerCount >= 4) { - $availableMatchConfigs = MatchConfiguration::where('runners', '=', $runnerCount) - ->where('hunters', '=', $hunterCount) - ->where('enabled', '=', true) - ->get(); - } - - if ($availableMatchConfigs === null or $availableMatchConfigs->isEmpty()) - return MatchConfiguration::where('runners', '<=', $runnerCount) + $scavCompareMethod = $runnerCount >= 6 ? '>=' : ($runnerCount >= 4 ? '=' : '<='); + return MatchConfiguration::where('runners', $scavCompareMethod , min($runnerCount, 6)) ->where('hunters', '<=', $hunterCount) - ->where('enabled', '=', true) + ->whereEnabled(true) ->get(); - } else { - return $availableMatchConfigs - } } public static function selectRandomConfigByWeight(Collection &$collection): MatchConfiguration|null