From 43dada47053ab02019de4be1f1314891de31e675 Mon Sep 17 00:00:00 2001 From: programarivm Date: Wed, 9 Oct 2024 20:44:20 +0200 Subject: [PATCH] Updated elo --- src/Command/Game/Cli.php | 2 +- src/Command/Game/PlayLanCommand.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Command/Game/Cli.php b/src/Command/Game/Cli.php index 62f226fc..38e4e278 100644 --- a/src/Command/Game/Cli.php +++ b/src/Command/Game/Cli.php @@ -24,7 +24,7 @@ public function __construct(Pool $pool) $this->commands->attach((new HeuristicCommand())->setPool($pool)); $this->commands->attach((new LeaveCommand())->setPool($pool)); $this->commands->attach(new LegalCommand()); - $this->commands->attach(new PlayLanCommand()); + $this->commands->attach((new PlayLanCommand())->setPool($pool)); $this->commands->attach((new PlayRavCommand())->setPool($pool)); $this->commands->attach(new RandomizerCommand()); $this->commands->attach((new ResignCommand())->setPool($pool)); diff --git a/src/Command/Game/PlayLanCommand.php b/src/Command/Game/PlayLanCommand.php index a1d18895..2fe8651b 100644 --- a/src/Command/Game/PlayLanCommand.php +++ b/src/Command/Game/PlayLanCommand.php @@ -3,6 +3,7 @@ namespace ChessServer\Command\Game; use ChessServer\Command\AbstractCommand; +use ChessServer\Command\UpdateEloAsyncTask; use ChessServer\Command\Game\Mode\PlayMode; use ChessServer\Socket\AbstractSocket; @@ -31,8 +32,10 @@ public function run(AbstractSocket $socket, array $argv, int $id) $isValid = $gameMode->getGame()->playLan($params['color'], $params['lan']); if ($isValid) { if (isset($gameMode->getGame()->state()->end)) { - // TODO ... - // Update elo + $this->pool->add(new UpdateEloAsyncTask([ + 'result' => $gameMode->getGame()->state()->end['result'], + 'decoded' => $gameMode->getJwtDecoded(), + ])); } else { $gameMode->updateTimer($params['color']); }