mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-03-21 18:04:46 -05:00
Change sleep logik for the waiting period for 1v4 and 1v5 matches
This commit is contained in:
parent
3992dc94c8
commit
7efc03e546
33
dist/app/Console/Commands/ProcessMatchmaking.php
vendored
33
dist/app/Console/Commands/ProcessMatchmaking.php
vendored
|
|
@ -10,11 +10,20 @@
|
|||
use App\Models\Game\Matchmaking\QueuedPlayer;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Log;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ProcessMatchmaking extends Command
|
||||
{
|
||||
/**
|
||||
* How long the matchmakign shoudl wait when only one 1v4 or 1v5 could be made before actually making it.
|
||||
*/
|
||||
const ONE_VS_FOUR_AND_FIVE_WAIT_TIME = 20;
|
||||
|
||||
const ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY = 'matchmaking_attempt_1v4_1v5';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
|
@ -78,9 +87,27 @@ public function handle(): void
|
|||
));
|
||||
|
||||
$playerCount = $this->getTotalPlayersCount($players);
|
||||
if ($playerCount->hunters === 1 && ($playerCount->runners === 4 || $playerCount->runners === 5))
|
||||
sleep(10);
|
||||
$playerCount = $this->getTotalPlayersCount($players);
|
||||
|
||||
// If we only have one Hunter and could make a 1v4 or 1v5 we want to wait a bit before making a match.
|
||||
// because there could be some runners not being fast enough in queue or the matchmaking command running unfortunatly while players are queuing up.
|
||||
if ($playerCount->hunters === 1 && ($playerCount->runners === 4 || $playerCount->runners === 5)) {
|
||||
if (Cache::has(static::ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY)) {
|
||||
/** @var Carbon $firstAttempt */
|
||||
$firstAttempt = Cache::get(static::ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY);
|
||||
if ($firstAttempt->diffInSeconds(Carbon::now()) < static::ONE_VS_FOUR_AND_FIVE_WAIT_TIME){
|
||||
return;
|
||||
}
|
||||
Cache::forget(static::ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY);
|
||||
}
|
||||
else {
|
||||
Cache::set(static::ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY, Carbon::now());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Cache::forget(static::ONE_VS_FOUR_AND_VS_FIVE_FIST_ATTEMPT_CACHE_KEY);
|
||||
}
|
||||
|
||||
$availableMatchConfigs = MatchConfiguration::getAvailableMatchConfigs($playerCount->runners, $playerCount->hunters);
|
||||
|
||||
if($availableMatchConfigs->isEmpty())
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user