rename ability

This commit is contained in:
openlegends 2024-03-17 12:31:47 +02:00
parent 0b80763b46
commit 7446fde32d
5 changed files with 57 additions and 54 deletions

View File

@ -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
{}
}

View File

@ -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;
}
}
}
}
}
}

View File

@ -19,7 +19,7 @@ class Goblin extends \OpenLegends\Engine\Abstract\Card
); );
$ability->add( $ability->add(
new \OpenLegends\Asset\Test\Card\Ability\Attack() new \OpenLegends\Asset\Test\Card\Ability\Damage()
); );
$this->setAbility( $this->setAbility(

View File

@ -21,7 +21,7 @@ class Mouse extends \OpenLegends\Engine\Abstract\Card
); );
$this->setAbility( $this->setAbility(
new \OpenLegends\Asset\Test\Card\Ability\Attack() new \OpenLegends\Asset\Test\Card\Ability\Damage()
); );
$this->setTitle( $this->setTitle(

View File

@ -21,7 +21,7 @@ class Rat extends \OpenLegends\Engine\Abstract\Card
); );
$this->setAbility( $this->setAbility(
new \OpenLegends\Asset\Test\Card\Ability\Attack() new \OpenLegends\Asset\Test\Card\Ability\Damage()
); );
$this->setTitle( $this->setTitle(