feat: catalog curated abilities and definitions
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BattleForge\Domain;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final readonly class AbilityDefinition
|
||||
{
|
||||
public const TARGET_SELF = 'self';
|
||||
public const TARGET_ALLY = 'ally';
|
||||
public const TARGET_ENEMY = 'enemy';
|
||||
public const TARGET_TILE = 'tile';
|
||||
|
||||
public const EFFECT_RESTORE_HEALTH = 'restore_health';
|
||||
public const EFFECT_DEAL_DAMAGE = 'deal_damage';
|
||||
public const EFFECT_APPLY_BUFF = 'apply_buff';
|
||||
|
||||
/** @var list<string> */
|
||||
private const TARGETS = [self::TARGET_SELF, self::TARGET_ALLY, self::TARGET_ENEMY, self::TARGET_TILE];
|
||||
|
||||
/** @var list<string> */
|
||||
private const EFFECTS = [self::EFFECT_RESTORE_HEALTH, self::EFFECT_DEAL_DAMAGE, self::EFFECT_APPLY_BUFF];
|
||||
|
||||
public function __construct(
|
||||
public AbilityId $id,
|
||||
public string $label,
|
||||
public int $range,
|
||||
public int $areaRadius,
|
||||
public string $target,
|
||||
public string $effect,
|
||||
public int $effectValue,
|
||||
) {
|
||||
if ($this->range < 0) {
|
||||
throw new InvalidArgumentException('Ability range cannot be negative.');
|
||||
}
|
||||
|
||||
if ($this->areaRadius < 0) {
|
||||
throw new InvalidArgumentException('Ability area radius cannot be negative.');
|
||||
}
|
||||
|
||||
if (!in_array($this->target, self::TARGETS, true)) {
|
||||
throw new InvalidArgumentException("Unknown ability target: {$this->target}.");
|
||||
}
|
||||
|
||||
if (!in_array($this->effect, self::EFFECTS, true)) {
|
||||
throw new InvalidArgumentException("Unknown ability effect: {$this->effect}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user