mirror of
https://github.com/openlegends/asset-php.git
synced 2025-02-08 13:04:22 +00:00
rename ability
This commit is contained in:
parent
0b80763b46
commit
7446fde32d
@ -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
Normal file
54
src/Test/Card/Ability/Damage.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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(
|
||||||
|
@ -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(
|
||||||
|
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user