Added check for 1v5 and 1v6 exact conditions

This commit is contained in:
PMahhov 2025-06-13 20:46:04 +02:00
parent d27ffc3271
commit 56f4c39ce2

View File

@ -38,10 +38,28 @@ class MatchConfiguration extends Model
*/
public static function getAvailableMatchConfigs(int $runnerCount, int $hunterCount): Collection
{
return MatchConfiguration::where('runners', '<=', $runnerCount)
->where('hunters', '<=', $hunterCount)
->where('enabled', '=', true)
->get();
$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)
->where('hunters', '<=', $hunterCount)
->where('enabled', '=', true)
->get();
} else {
return $availableMatchConfigs
}
}
public static function selectRandomConfigByWeight(Collection &$collection): MatchConfiguration|null