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);
|
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(
|
public function __construct()
|
||||||
\OpenLegends\Engine\Abstract\Card | \OpenLegends\Engine\Abstract\Player $target
|
|
||||||
): void
|
|
||||||
{
|
{
|
||||||
// Give damage
|
$this->setName(
|
||||||
$target->setHealth(
|
_('Damage')
|
||||||
$target->getHealth() - $source->getPower()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Target is card
|
$this->setDescription(
|
||||||
if ($target instanceof \OpenLegends\Engine\Abstract\Card)
|
_('This card make damage equal it power to another card or player')
|
||||||
{
|
);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,14 @@ namespace OpenLegends\Asset\Test\Card\Ability;
|
|||||||
|
|
||||||
class Drain extends \OpenLegends\Engine\Abstract\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 = [];
|
private array $_abilities = [];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->setName(
|
||||||
|
_('Multiple')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setDescription(
|
||||||
|
_('This card has multiple abilities')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function add(
|
public function add(
|
||||||
\OpenLegends\Engine\Abstract\Card\Ability $ability
|
\OpenLegends\Engine\Abstract\Card\Ability $ability
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
$this->_abilities[] = $ability;
|
$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()
|
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(
|
$this->setTitle(
|
||||||
_('Goblin')
|
_('Goblin')
|
||||||
);
|
);
|
||||||
@ -65,5 +35,31 @@ class Goblin extends \OpenLegends\Engine\Abstract\Card
|
|||||||
$this->setExtract(
|
$this->setExtract(
|
||||||
3
|
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()
|
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(
|
$this->setTitle(
|
||||||
_('Mouse')
|
_('Mouse')
|
||||||
);
|
);
|
||||||
@ -51,5 +35,21 @@ class Mouse extends \OpenLegends\Engine\Abstract\Card
|
|||||||
$this->setExtract(
|
$this->setExtract(
|
||||||
1
|
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