mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-04-26 02:00:32 -05:00
Merge pull request #57 from Deathgarden-Rebirth/no_scav_left_behind
Force 1v5 and 1v6 matches with exact playercount in queue
This commit is contained in:
commit
258ac3776c
|
|
@ -83,7 +83,7 @@ public function handle(): void
|
|||
if($availableMatchConfigs->isEmpty())
|
||||
return;
|
||||
|
||||
$selectedConfig = MatchConfiguration::selectRandomConfigByWeight($availableMatchConfigs);
|
||||
$selectedConfig = MatchConfiguration::selectMatchConfig($availableMatchConfigs, $playerCount->runners, $playerCount->hunters);
|
||||
|
||||
// Should never happen, but just to be careful
|
||||
if($selectedConfig === null)
|
||||
|
|
|
|||
|
|
@ -368,7 +368,8 @@ protected function removeUserFromGame(User $user, Game $game)
|
|||
{
|
||||
$game->players()->detach($user);
|
||||
|
||||
if($game->players->count() !== 0)
|
||||
// Delete the game if the creator deletes themselfes sice we had one case where the matchmaking broke due to a game being stuck like this.
|
||||
if($game->players->count() !== 0 && $game->creator_user_id !== $user->id)
|
||||
return;
|
||||
|
||||
$game->delete();
|
||||
|
|
|
|||
|
|
@ -44,8 +44,24 @@ public static function getAvailableMatchConfigs(int $runnerCount, int $hunterCou
|
|||
->get();
|
||||
}
|
||||
|
||||
public static function selectRandomConfigByWeight(Collection &$collection): MatchConfiguration|null
|
||||
public static function selectMatchConfig(Collection &$collection, int $runnerCount, int $hunterCount): MatchConfiguration|null
|
||||
{
|
||||
$filteredConfigs = new Collection();
|
||||
|
||||
if ($hunterCount === 1 && $runnerCount >= 6){
|
||||
$filteredConfigs = $collection->filter(function (MatchConfiguration $config) use ($runnerCount, $hunterCount) {
|
||||
return $config->runners >= 6 && $config->hunters === $hunterCount;
|
||||
});
|
||||
}
|
||||
else if ($hunterCount === 1 && $runnerCount >= 4){
|
||||
$filteredConfigs = $collection->filter(function (MatchConfiguration $config) use ($runnerCount, $hunterCount) {
|
||||
return $config->runners === $runnerCount && $config->hunters === $hunterCount;
|
||||
});
|
||||
}
|
||||
|
||||
if ($filteredConfigs->isNotEmpty())
|
||||
$collection = $filteredConfigs;
|
||||
|
||||
$weightSum = $collection->sum('weight');
|
||||
$random = random_int(1, $weightSum);
|
||||
$selectWalk = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user