refactor: reuse position distance for attacks
This commit is contained in:
@@ -418,6 +418,25 @@ final class CombatEngineTest extends TestCase
|
||||
yield 'defeated enemy' => ['bravo', 0];
|
||||
}
|
||||
|
||||
public function testAttackDealsCalculatedOpenTerrainDamage(): void
|
||||
{
|
||||
$target = $this->unit('bravo-1', 'bravo', new Position(1, 0), defense: 3);
|
||||
$match = new MatchState(
|
||||
new Battlefield(8, 8),
|
||||
[
|
||||
$this->unit('alpha-1', 'alpha', new Position(0, 0), attack: 8),
|
||||
$target,
|
||||
],
|
||||
'alpha',
|
||||
);
|
||||
|
||||
$next = (new CombatEngine())->attack($match, 'alpha-1', 'bravo-1');
|
||||
|
||||
self::assertSame(10, $target->health);
|
||||
self::assertSame(5, $next->unit('bravo-1')->health);
|
||||
self::assertSame(['alpha-1 attacked bravo-1 for 5 damage'], $next->actionLog);
|
||||
}
|
||||
|
||||
public function testAttackAlwaysDealsAtLeastOneDamage(): void
|
||||
{
|
||||
$match = new MatchState(
|
||||
|
||||
Reference in New Issue
Block a user