Update the ELO of the players
Closed this issue · 1 comments
programarivm commented
Given two usernames and a game result after a match, the ChessServer\Command\Data\EloCommand
will calculate the new ELO for both players updating the users
table accordingly.
programarivm commented
After some thought, the ELO update needs to be implemented in the res()
method in ChessServer\Command\Game\Mode\PlayMode
<?php
namespace ChessServer\Command\Game\Mode;
// ...
class PlayMode extends AbstractMode
{
// ...
public function res($params, $cmd)
{
switch (get_class($cmd)) {
case PlayLanCommand::class:
$isValid = $this->game->playLan($params['color'], $params['lan']);
$this->updateTimer($params['color']);
if ($this->game->state()->end) {
// TODO ...
}
return [
$cmd->name => [
... (array) $this->game->state(),
'variant' => $this->game->getVariant(),
// play mode information
'timer' => $this->timer,
'isValid' => $isValid,
],
];
default:
return parent::res($params, $cmd);
}
}
}