From 3c2a908334ad7732ffd8417ca15267702c47da65 Mon Sep 17 00:00:00 2001 From: openlegends Date: Mon, 18 Mar 2024 15:03:24 +0200 Subject: [PATCH] update api --- src/Test/Card/Action/Attack.php | 29 +++++++++++++++++++++++------ src/Test/Card/Action/Heal.php | 22 ++++++++++++++++------ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Test/Card/Action/Attack.php b/src/Test/Card/Action/Attack.php index 6e28324..2ec95bc 100644 --- a/src/Test/Card/Action/Attack.php +++ b/src/Test/Card/Action/Attack.php @@ -8,6 +8,8 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action { private \OpenLegends\Engine\Abstract\Card $_card; + private int $_power = 0; + private int $_breakthrough = 0; public function __construct( @@ -18,10 +20,9 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action public function card( \OpenLegends\Engine\Abstract\Card &$card, - ?int $power = null ): void { - $damage = $power ? $power : $this->_card->getPower(); + $damage = $this->getPower() ? $this->getPower() : $this->_card->getPower(); if ($damage) { @@ -38,8 +39,10 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action if ($health < 0 && $this->_card->getBreakthrough()) { - $this->_breakthrough = abs( - $health + $this->setBreakthrough( + abs( + $health + ) ); } @@ -62,10 +65,9 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action public function player( \OpenLegends\Engine\Abstract\Player &$player, - ?int $power = null ): void { - $damage = $power ? $power : $this->_card->getPower(); + $damage = $this->getPower() ? $this->getPower() : $this->_card->getPower(); 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 { return $this->_breakthrough; } + + public function setBreakthrough(int $value): void + { + $this->_breakthrough = $value; + } } \ No newline at end of file diff --git a/src/Test/Card/Action/Heal.php b/src/Test/Card/Action/Heal.php index 65fcd86..1279edb 100644 --- a/src/Test/Card/Action/Heal.php +++ b/src/Test/Card/Action/Heal.php @@ -8,6 +8,8 @@ class Heal extends \OpenLegends\Engine\Abstract\Card\Action { private \OpenLegends\Engine\Abstract\Card $_card; + private int $_power = 0; + public function __construct( \OpenLegends\Engine\Abstract\Card $card ) { @@ -15,22 +17,30 @@ class Heal extends \OpenLegends\Engine\Abstract\Card\Action } public function card( - \OpenLegends\Engine\Abstract\Card &$card, - ?int $power = null + \OpenLegends\Engine\Abstract\Card &$card ): void { $card->setHealth( - $card->getHealth() + ($power ? $power : $this->_card->getPower()) + $card->getHealth() + ($this->getPower() ? $this->getPower() : $this->_card->getPower()) ); } public function player( - \OpenLegends\Engine\Abstract\Player &$player, - ?int $power = null + \OpenLegends\Engine\Abstract\Player &$player ): void { $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; + } } \ No newline at end of file