Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| JoinAreaCommand | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| pack | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AqwSocketClient\Commands; |
| 6 | |
| 7 | use AqwSocketClient\Interfaces\CommandInterface; |
| 8 | use AqwSocketClient\Objects\Identifiers\RoomIdentifier; |
| 9 | use AqwSocketClient\Objects\Names\AreaName; |
| 10 | use AqwSocketClient\Objects\Names\PlayerName; |
| 11 | use AqwSocketClient\Packet; |
| 12 | use Override; |
| 13 | |
| 14 | /** |
| 15 | * Represents a command to instruct the client to join a specific map or area |
| 16 | * within the game world. |
| 17 | * |
| 18 | * This command is sent to the server to initiate a map change or movement. |
| 19 | * |
| 20 | * @see AqwSocketClient\Interfaces\CommandInterface |
| 21 | */ |
| 22 | final class JoinAreaCommand implements CommandInterface |
| 23 | { |
| 24 | public function __construct( |
| 25 | public readonly PlayerName $playerName, |
| 26 | public readonly AreaName $areaName, |
| 27 | public readonly ?RoomIdentifier $room = null, |
| 28 | ) {} |
| 29 | |
| 30 | #[Override] |
| 31 | public function pack(): Packet |
| 32 | { |
| 33 | return Packet::packetify( |
| 34 | $this->room === null |
| 35 | ? "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->areaName}%" |
| 36 | : "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->areaName}-{$this->room}%", |
| 37 | ); |
| 38 | } |
| 39 | } |