Disallow player triple and more boost

This commit is contained in:
Ryan Cooper 2025-03-12 18:48:04 +01:00 committed by solcloud
parent 382d7c1ec7
commit c738e0d1f3
4 changed files with 27 additions and 0 deletions

View File

@ -12,6 +12,11 @@ final class DynamicFloor extends Floor
$this->pointReference = $player->getReferenceToPosition();
}
public function getPlayer(): Player
{
return $this->player;
}
#[\Override]
public function getY(): int
{

View File

@ -271,6 +271,11 @@ final class Player
return $this->headFloor;
}
public function getBoostFloor(): ?DynamicFloor
{
return ($this->activeFloor instanceof DynamicFloor) ? $this->activeFloor : null;
}
/**
* @return list<Point>
*/

View File

@ -159,6 +159,7 @@ final class World
foreach ($this->game->getAlivePlayers() as $player) {
$floor = $player->getHeadFloor();
if ($floor->intersect($point, $radius)) {
$player->getBoostFloor()?->getPlayer()->suicide();
return $floor;
}
}

View File

@ -153,4 +153,20 @@ class PlayerBoostTest extends BaseTestCase
$this->assertFalse($player1->isJumping());
}
public function testPunishTripleBoost(): void
{
$game = $this->createTestGameNoPause(20);
$p1 = $game->getPlayer(1);
$p2 = new Player(2, Color::GREEN, false);
$p3 = new Player(3, Color::ORANGE, false);
$game->addPlayer($p2);
$game->addPlayer($p3);
$p1->setPosition(new Point(500, 0, 500));
$p2->setPosition($p1->getPositionClone()->addY($p1->getHeadHeight() + 2));
$p3->setPosition($p2->getPositionClone()->addY($p1->getHeadHeight() + 2));
$game->start();
$this->assertFalse($p1->isAlive());
}
}