Lines
100.00%
9 / 9
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| SupportPlayerCommand | 100.00% | 9 / 9 | 100.00% | 2 / 2 | 7 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 6 | |||||
| toMessage | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Lorekeeper\Client\Command\Combat; | |
| 6 | ||
| 7 | use InvalidArgumentException; | |
| 8 | use Lorekeeper\Client\Command\Command; | |
| 9 | use Lorekeeper\Core\Item\Equipment\CharacterClass\Skill\SkillSlot; | |
| 10 | use Lorekeeper\Core\Player\PlayerSpawnId; | |
| 11 | use Lorekeeper\Server\AreaId; | |
| 12 | use Override; | |
| 13 | ||
| 14 | final readonly class SupportPlayerCommand implements Command | |
| 15 | { | |
| 16 | private string $code; | |
| 17 | ||
| 18 | /** @throws InvalidArgumentException */ | |
| 19 | public function __construct( | |
| 20 | private AreaId $area, | |
| 21 | SkillSlot $skill, | |
| 22 | private PlayerSpawnId $player, | |
| 23 | ) { | |
| 24 | $this->code = match ($skill) { | |
| 25 | SkillSlot::First => 'a1', | |
| 26 | SkillSlot::Second => 'a2', | |
| 27 | SkillSlot::Third => 'a3', | |
| 28 | SkillSlot::Fourth => 'a4', | |
| 29 | SkillSlot::AutoAttack, SkillSlot::Potion => throw new InvalidArgumentException( | |
| 30 | 'Only a class skill can support a player.', | |
| 31 | ), | |
| 32 | }; | |
| 33 | } | |
| 34 | ||
| 35 | #[Override] | |
| 36 | public function toMessage(): string | |
| 37 | { | |
| 38 | return "%xt%zm%gar%{$this->area}%0%{$this->code}>p:{$this->player}%wvz%"; | |
| 39 | } | |
| 40 | } |