Fixes BattleEvents to accept correct game
This commit is contained in:
+2
-20
@@ -16,11 +16,7 @@ use LotGD\Core\{
|
||||
Models\FighterInterface
|
||||
};
|
||||
use LotGD\Core\Models\{
|
||||
Buff,
|
||||
BattleEvents\BuffMessageEvent,
|
||||
BattleEvents\CriticalHitEvent,
|
||||
BattleEvents\DamageEvent,
|
||||
BattleEvents\DeathEvent
|
||||
Buff, BattleEvents\BuffMessageEvent, BattleEvents\CriticalHitEvent, BattleEvents\DamageEvent, BattleEvents\DeathEvent, Scene
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -102,23 +98,9 @@ class Battle
|
||||
return $battle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ToDo Returns at some point battle actions
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @ToDo Do some action
|
||||
*/
|
||||
public function selectAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all battle events
|
||||
* @return \LotGD\Core\Collection
|
||||
* @return Collection
|
||||
*/
|
||||
public function getEvents(): Collection
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Exceptions\BattleEventException;
|
||||
use LotGD\Core\Game;
|
||||
|
||||
/**
|
||||
* A representation of something that happened in battle.
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Exceptions\BattleEventException;
|
||||
use LotGD\Core\Game;
|
||||
|
||||
/**
|
||||
* A battle event representing a message generated by a buff.
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Exceptions\BattleEventException;
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ class MinionDamageEvent extends BattleEvent
|
||||
*/
|
||||
public function decorate(Game $game): string
|
||||
{
|
||||
parent::decorate();
|
||||
parent::decorate($game);
|
||||
|
||||
return str_replace(
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace LotGD\Core\Models\BattleEvents;
|
||||
|
||||
use LotGD\Core\Exceptions\BattleEventException;
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Models\FighterInterface;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ class RegenerationBuffEvent extends BattleEvent
|
||||
*/
|
||||
public function decorate(Game $game): string
|
||||
{
|
||||
parent::decorate();
|
||||
parent::decorate($game);
|
||||
|
||||
if ($this->regeneration === 0) {
|
||||
return str_replace(
|
||||
|
||||
@@ -85,6 +85,10 @@ class BattleTest extends CoreModelTestCase
|
||||
if ($battle->isOver()) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($battle->getEvents() as $event) {
|
||||
$this->assertNotNull($event->decorate($this->getMockGame($character)));
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertTrue($battle->isOver());
|
||||
@@ -113,6 +117,10 @@ class BattleTest extends CoreModelTestCase
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($battle->getEvents() as $event) {
|
||||
$this->assertNotNull($event->decorate($this->getMockGame($character)));
|
||||
}
|
||||
|
||||
$battle = $battle->serialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user