diff --git a/src/Test/Card/Action/Attack.php b/src/Test/Card/Action/Attack.php new file mode 100644 index 0000000..6e28324 --- /dev/null +++ b/src/Test/Card/Action/Attack.php @@ -0,0 +1,92 @@ +_card = $card; + } + + public function card( + \OpenLegends\Engine\Abstract\Card &$card, + ?int $power = null + ): void + { + $damage = $power ? $power : $this->_card->getPower(); + + if ($damage) + { + if ($card->getCover()) + { + $card->setCover( + false + ); + } + + else + { + $health = $card->getHealth() - $damage; + + if ($health < 0 && $this->_card->getBreakthrough()) + { + $this->_breakthrough = abs( + $health + ); + } + + if ($this->_card->getLethal()) + { + $card->setHealth( + 0 + ); + } + + else + { + $card->setHealth( + $health + ); + } + } + } + } + + public function player( + \OpenLegends\Engine\Abstract\Player &$player, + ?int $power = null + ): void + { + $damage = $power ? $power : $this->_card->getPower(); + + if ($damage) + { + if ($player->getCover()) + { + $player->setCover( + false + ); + } + + else + { + $player->setHealth( + $player->getHealth() - $damage + ); + } + } + } + + public function getBreakthrough(): int + { + return $this->_breakthrough; + } +} \ No newline at end of file