update api

This commit is contained in:
openlegends 2024-03-18 15:03:24 +02:00
parent 31667e3ba3
commit 3c2a908334
2 changed files with 39 additions and 12 deletions

View File

@ -8,6 +8,8 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action
{ {
private \OpenLegends\Engine\Abstract\Card $_card; private \OpenLegends\Engine\Abstract\Card $_card;
private int $_power = 0;
private int $_breakthrough = 0; private int $_breakthrough = 0;
public function __construct( public function __construct(
@ -18,10 +20,9 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action
public function card( public function card(
\OpenLegends\Engine\Abstract\Card &$card, \OpenLegends\Engine\Abstract\Card &$card,
?int $power = null
): void ): void
{ {
$damage = $power ? $power : $this->_card->getPower(); $damage = $this->getPower() ? $this->getPower() : $this->_card->getPower();
if ($damage) if ($damage)
{ {
@ -38,8 +39,10 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action
if ($health < 0 && $this->_card->getBreakthrough()) if ($health < 0 && $this->_card->getBreakthrough())
{ {
$this->_breakthrough = abs( $this->setBreakthrough(
abs(
$health $health
)
); );
} }
@ -62,10 +65,9 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action
public function player( public function player(
\OpenLegends\Engine\Abstract\Player &$player, \OpenLegends\Engine\Abstract\Player &$player,
?int $power = null
): void ): void
{ {
$damage = $power ? $power : $this->_card->getPower(); $damage = $this->getPower() ? $this->getPower() : $this->_card->getPower();
if ($damage) if ($damage)
{ {
@ -85,8 +87,23 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action
} }
} }
public function getPower(): int
{
return $this->_power;
}
public function setPower(int $value): void
{
$this->_power = $value;
}
public function getBreakthrough(): int public function getBreakthrough(): int
{ {
return $this->_breakthrough; return $this->_breakthrough;
} }
public function setBreakthrough(int $value): void
{
$this->_breakthrough = $value;
}
} }

View File

@ -8,6 +8,8 @@ class Heal extends \OpenLegends\Engine\Abstract\Card\Action
{ {
private \OpenLegends\Engine\Abstract\Card $_card; private \OpenLegends\Engine\Abstract\Card $_card;
private int $_power = 0;
public function __construct( public function __construct(
\OpenLegends\Engine\Abstract\Card $card \OpenLegends\Engine\Abstract\Card $card
) { ) {
@ -15,22 +17,30 @@ class Heal extends \OpenLegends\Engine\Abstract\Card\Action
} }
public function card( public function card(
\OpenLegends\Engine\Abstract\Card &$card, \OpenLegends\Engine\Abstract\Card &$card
?int $power = null
): void ): void
{ {
$card->setHealth( $card->setHealth(
$card->getHealth() + ($power ? $power : $this->_card->getPower()) $card->getHealth() + ($this->getPower() ? $this->getPower() : $this->_card->getPower())
); );
} }
public function player( public function player(
\OpenLegends\Engine\Abstract\Player &$player, \OpenLegends\Engine\Abstract\Player &$player
?int $power = null
): void ): void
{ {
$player->setHealth( $player->setHealth(
$player->getHealth() + ($power ? $power : $this->_card->getPower()) $player->getHealth() + ($this->getPower() ? $this->getPower() : $this->_card->getPower())
); );
} }
public function getPower(): int
{
return $this->_power;
}
public function setPower(int $value): void
{
$this->_power = $value;
}
} }