mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-04-26 10:15:28 -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 App\Models\Game\Matchmaking\QueuedPlayer;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Log;
|
use Log;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class ProcessMatchmaking extends Command
|
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.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
|
|
@ -78,9 +87,27 @@ public function handle(): void
|
||||||
));
|
));
|
||||||
|
|
||||||
$playerCount = $this->getTotalPlayersCount($players);
|
$playerCount = $this->getTotalPlayersCount($players);
|
||||||
if ($playerCount->hunters === 1 && ($playerCount->runners === 4 || $playerCount->runners === 5))
|
|
||||||
sleep(10);
|
// If we only have one Hunter and could make a 1v4 or 1v5 we want to wait a bit before making a match.
|
||||||
$playerCount = $this->getTotalPlayersCount($players);
|
// 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);
|
$availableMatchConfigs = MatchConfiguration::getAvailableMatchConfigs($playerCount->runners, $playerCount->hunters);
|
||||||
|
|
||||||
if($availableMatchConfigs->isEmpty())
|
if($availableMatchConfigs->isEmpty())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user