Browse Source

rename ability

main
openlegends 9 months ago
parent
commit
7446fde32d
  1. 51
      src/Test/Card/Ability/Attack.php
  2. 54
      src/Test/Card/Ability/Damage.php
  3. 2
      src/Test/Card/Goblin.php
  4. 2
      src/Test/Card/Mouse.php
  5. 2
      src/Test/Card/Rat.php

51
src/Test/Card/Ability/Attack.php

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

54
src/Test/Card/Ability/Damage.php

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

2
src/Test/Card/Goblin.php

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

2
src/Test/Card/Mouse.php

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

2
src/Test/Card/Rat.php

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

Loading…
Cancel
Save