Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| JoinBattleonScript | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
5 | |
100.00% |
1 / 1 |
| start | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AqwSocketClient\Scripts; |
| 6 | |
| 7 | use AqwSocketClient\Commands\JoinInitialAreaCommand; |
| 8 | use AqwSocketClient\Events\AreaJoinedEvent; |
| 9 | use AqwSocketClient\Interfaces\CommandInterface; |
| 10 | use AqwSocketClient\Interfaces\EventInterface; |
| 11 | use Override; |
| 12 | |
| 13 | final class JoinBattleonScript extends AbstractScript |
| 14 | { |
| 15 | #[Override] |
| 16 | public function start(ClientContext $context): ?CommandInterface |
| 17 | { |
| 18 | return new JoinInitialAreaCommand(); |
| 19 | } |
| 20 | |
| 21 | #[Override] |
| 22 | public function handles(): array |
| 23 | { |
| 24 | return [AreaJoinedEvent::class]; |
| 25 | } |
| 26 | |
| 27 | #[Override] |
| 28 | public function handle(EventInterface $event, ClientContext $context): ?CommandInterface |
| 29 | { |
| 30 | if ($event instanceof AreaJoinedEvent && $event->area->name->value === 'battleon') { |
| 31 | $context->set('area_id', $event->area->identifier); |
| 32 | $this->success(); |
| 33 | } |
| 34 | |
| 35 | return null; |
| 36 | } |
| 37 | } |