openlegends
9 months ago
5 changed files with 57 additions and 54 deletions
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace OpenLegends\Asset\Test\Card\Ability; |
||||
|
||||
class Attack extends \OpenLegends\Engine\Abstract\Card\Ability |
||||
{ |
||||
public function player(): void |
||||
{} |
||||
|
||||
public function opponent(): void |
||||
{} |
||||
|
||||
public function card( |
||||
\OpenLegends\Engine\Abstract\Card $source, |
||||
\OpenLegends\Engine\Abstract\Card $target |
||||
): void |
||||
{ |
||||
$target->setHealth( |
||||
$target->getHealth() - $source->getPower() |
||||
); |
||||
|
||||
$source->setHealth( |
||||
$source->getHealth() - $target->getPower() |
||||
); |
||||
} |
||||
|
||||
public function silentize( |
||||
\OpenLegends\Engine\Abstract\Card $target, |
||||
\OpenLegends\Engine\Abstract\Card $origin |
||||
): void |
||||
{ |
||||
$target->setCost( |
||||
$origin->getCost() |
||||
); |
||||
|
||||
$target->setPower( |
||||
$origin->getPower() |
||||
); |
||||
|
||||
$target->setHealth( |
||||
$origin->getHealth() |
||||
); |
||||
|
||||
// @TODO remove abilities |
||||
} |
||||
|
||||
public function apply(): void |
||||
{} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace OpenLegends\Asset\Test\Card\Ability; |
||||
|
||||
class Damage extends \OpenLegends\Engine\Abstract\Card\Ability |
||||
{ |
||||
public function apply( |
||||
\OpenLegends\Engine\Abstract\Card | \OpenLegends\Engine\Abstract\Player $target |
||||
): void |
||||
{ |
||||
// Give damage |
||||
$target->setHealth( |
||||
$target->getHealth() - $source->getPower() |
||||
); |
||||
|
||||
// Target is card |
||||
if ($target instanceof \OpenLegends\Engine\Abstract\Card) |
||||
{ |
||||
// Take back damage |
||||
$source->setHealth( |
||||
$source->getHealth() - $target->getPower() |
||||
); |
||||
|
||||
// Check for source lethal ability |
||||
if ($source->getHealth() > 0) |
||||
{ |
||||
// Check for lethal ability |
||||
foreach ($target->getAbilities() as $ability) |
||||
{ |
||||
if ($target->getAbility() instanceof \OpenLegends\Asset\Test\Card\Ability\Lethal) |
||||
{ |
||||
$source->setHealth(0); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Check for target lethal ability |
||||
if ($target->getHealth() > 0) |
||||
{ |
||||
foreach ($source->getAbilities() as $ability) |
||||
{ |
||||
if ($ability instanceof \OpenLegends\Asset\Test\Card\Ability\Lethal) |
||||
{ |
||||
$target->setHealth(0); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue