mirror of
https://github.com/openlegends/asset-php.git
synced 2025-02-08 13:04:22 +00:00
update api
This commit is contained in:
parent
cc1e9f642b
commit
31667e3ba3
@ -2,53 +2,18 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenLegends\Asset\Test\Card\Ability;
|
||||
namespace OpenLegends\Asset\Test\Action\Card;
|
||||
|
||||
class Damage extends \OpenLegends\Engine\Abstract\Card\Ability
|
||||
class Damage extends \OpenLegends\Engine\Abstract\Action\Card
|
||||
{
|
||||
public function apply(
|
||||
\OpenLegends\Engine\Abstract\Card | \OpenLegends\Engine\Abstract\Player $target
|
||||
): void
|
||||
public function __construct()
|
||||
{
|
||||
// Give damage
|
||||
$target->setHealth(
|
||||
$target->getHealth() - $source->getPower()
|
||||
$this->setName(
|
||||
_('Damage')
|
||||
);
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setDescription(
|
||||
_('This card make damage equal it power to another card or player')
|
||||
);
|
||||
}
|
||||
}
|
@ -6,6 +6,14 @@ namespace OpenLegends\Asset\Test\Card\Ability;
|
||||
|
||||
class Drain extends \OpenLegends\Engine\Abstract\Card\Ability
|
||||
{
|
||||
public function apply(): void
|
||||
{}
|
||||
public function __construct()
|
||||
{
|
||||
$this->setName(
|
||||
_('Drain')
|
||||
);
|
||||
|
||||
$this->setDescription(
|
||||
_('Drain player HP on damage')
|
||||
);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenLegends\Asset\Test\Card\Ability;
|
||||
|
||||
class Guard extends \OpenLegends\Engine\Abstract\Card\Ability
|
||||
{
|
||||
public function apply(): void
|
||||
{}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OpenLegends\Asset\Test\Card\Ability;
|
||||
|
||||
class Lethal extends \OpenLegends\Engine\Abstract\Card\Ability
|
||||
{
|
||||
public function apply(): void
|
||||
{}
|
||||
}
|
@ -8,18 +8,21 @@ class Multiple extends \OpenLegends\Engine\Abstract\Card\Ability
|
||||
{
|
||||
private array $_abilities = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setName(
|
||||
_('Multiple')
|
||||
);
|
||||
|
||||
$this->setDescription(
|
||||
_('This card has multiple abilities')
|
||||
);
|
||||
}
|
||||
|
||||
public function add(
|
||||
\OpenLegends\Engine\Abstract\Card\Ability $ability
|
||||
): void
|
||||
{
|
||||
$this->_abilities[] = $ability;
|
||||
}
|
||||
|
||||
public function apply(): void
|
||||
{
|
||||
foreach ($this->_abilities as $ability)
|
||||
{
|
||||
$ability->apply();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,36 +8,6 @@ class Goblin extends \OpenLegends\Engine\Abstract\Card
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$ability = new \OpenLegends\Asset\Test\Card\Ability\Multiple();
|
||||
|
||||
$ability->add(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Lethal()
|
||||
);
|
||||
|
||||
$ability->add(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Guard()
|
||||
);
|
||||
|
||||
$ability->add(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Damage()
|
||||
);
|
||||
|
||||
$this->setAbility(
|
||||
$ability
|
||||
);
|
||||
|
||||
$this->setAttribute(
|
||||
new \OpenLegends\Asset\Test\Card\Attribute\Neutral()
|
||||
);
|
||||
|
||||
$this->setType(
|
||||
new \OpenLegends\Asset\Test\Card\Type\Goblin()
|
||||
);
|
||||
|
||||
$this->setRarity(
|
||||
new \OpenLegends\Asset\Test\Card\Rarity\Common()
|
||||
);
|
||||
|
||||
$this->setTitle(
|
||||
_('Goblin')
|
||||
);
|
||||
@ -65,5 +35,31 @@ class Goblin extends \OpenLegends\Engine\Abstract\Card
|
||||
$this->setExtract(
|
||||
3
|
||||
);
|
||||
|
||||
$this->setAttribute(
|
||||
new \OpenLegends\Asset\Test\Card\Attribute\Neutral()
|
||||
);
|
||||
|
||||
$this->setType(
|
||||
new \OpenLegends\Asset\Test\Card\Type\Goblin()
|
||||
);
|
||||
|
||||
$this->setRarity(
|
||||
new \OpenLegends\Asset\Test\Card\Rarity\Common()
|
||||
);
|
||||
|
||||
$ability = new \OpenLegends\Asset\Test\Card\Ability\Multiple();
|
||||
|
||||
$ability->add(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Damage()
|
||||
);
|
||||
|
||||
$ability->add(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Drain()
|
||||
);
|
||||
|
||||
$this->setAbility(
|
||||
$ability
|
||||
);
|
||||
}
|
||||
}
|
@ -8,22 +8,6 @@ class Mouse extends \OpenLegends\Engine\Abstract\Card
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setAttribute(
|
||||
new \OpenLegends\Asset\Test\Card\Attribute\Neutral()
|
||||
);
|
||||
|
||||
$this->setType(
|
||||
new \OpenLegends\Asset\Test\Card\Type\Animal()
|
||||
);
|
||||
|
||||
$this->setRarity(
|
||||
new \OpenLegends\Asset\Test\Card\Rarity\Common()
|
||||
);
|
||||
|
||||
$this->setAbility(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Damage()
|
||||
);
|
||||
|
||||
$this->setTitle(
|
||||
_('Mouse')
|
||||
);
|
||||
@ -51,5 +35,21 @@ class Mouse extends \OpenLegends\Engine\Abstract\Card
|
||||
$this->setExtract(
|
||||
1
|
||||
);
|
||||
|
||||
$this->setAttribute(
|
||||
new \OpenLegends\Asset\Test\Card\Attribute\Neutral()
|
||||
);
|
||||
|
||||
$this->setType(
|
||||
new \OpenLegends\Asset\Test\Card\Type\Animal()
|
||||
);
|
||||
|
||||
$this->setRarity(
|
||||
new \OpenLegends\Asset\Test\Card\Rarity\Common()
|
||||
);
|
||||
|
||||
$this->setAbility(
|
||||
new \OpenLegends\Asset\Test\Card\Ability\Damage()
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user