Browse Source

update api

main
openlegends 3 months ago
parent
commit
3c2a908334
  1. 29
      src/Test/Card/Action/Attack.php
  2. 22
      src/Test/Card/Action/Heal.php

29
src/Test/Card/Action/Attack.php

@ -8,6 +8,8 @@ class Attack extends \OpenLegends\Engine\Abstract\Card\Action @@ -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 @@ -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 @@ -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 @@ -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 @@ -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;
}
}

22
src/Test/Card/Action/Heal.php

@ -8,6 +8,8 @@ class Heal extends \OpenLegends\Engine\Abstract\Card\Action @@ -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 @@ -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;
}
}
Loading…
Cancel
Save