-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #429 from chesslablab/issue/427-implement-the-asci…
…i-command Implemented the /ascii command
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace ChessServer\Command\Game\Sync; | ||
|
||
use ChessServer\Command\AbstractSyncCommand; | ||
use ChessServer\Socket\AbstractSocket; | ||
|
||
class AsciiCommand extends AbstractSyncCommand | ||
{ | ||
public function __construct() | ||
{ | ||
$this->name = '/ascii'; | ||
$this->description = 'Returns an ASCII representation of the board.'; | ||
} | ||
|
||
public function validate(array $argv) | ||
{ | ||
return count($argv) - 1 === 0; | ||
} | ||
|
||
public function run(AbstractSocket $socket, array $argv, int $id) | ||
{ | ||
$gameMode = $socket->getGameModeStorage()->getById($id); | ||
|
||
return $socket->getClientStorage()->send([$id], [ | ||
$this->name => $gameMode->getGame()->getBoard()->toString(), | ||
]); | ||
} | ||
} |