<?phpnamespace Tests;final class SpecialsTest extends WorldTestCase{ public function testADoorOpensWhenUsedThenClosesItself(): void { $this->load('test'); $this->noMonsters(); // the door 'D' is in column 6, row 4; the player stands below it, looking north $this->placePlayer(6, 5, 90); $door = $this->world->level->sectorAt(...$this->cell(6, 4)); self::assertSame($door->floor, $door->ceil, 'closed'); $this->tics(1, ['use' => true]); $this->tics(80); self::assertGreaterThan(100.0, $door->ceil, 'open'); $this->tics(200); self::assertSame($door->floor, $door->ceil, 'closed again'); } public function testTheExitSwitchEndsTheLevel(): void { $this->load('test'); $this->noMonsters(); $this->placePlayer(11, 6, 0); $this->tics(1, ['use' => true]); self::assertSame('exit', $this->world->exit); } public function testTheLiftGoesDownWaitsAndComesBack(): void { $this->load('m1'); $this->noMonsters(); // the lift 'l' (columns 15-16, row 4) is used from the courtyard below it $this->placePlayer(15, 5, 90); $lift = $this->world->level->sectorAt(...$this->cell(15, 4)); self::assertSame(64.0, $lift->floor); $this->tics(1, ['use' => true]); $this->tics(40); self::assertSame(-8.0, $lift->floor, 'down'); $this->tics(200); self::assertSame(64.0, $lift->floor, 'back up'); } public function testTheRedDoorNeedsTheRedKey(): void { $this->load('m1'); $this->noMonsters(); // the red door 'R' (columns 19-20, row 17) from the computer room above it $this->placePlayer(19, 16, 270); $door = $this->world->level->sectorAt(...$this->cell(19, 17)); $this->tics(1, ['use' => true]); $this->tics(30); self::assertSame($door->floor, $door->ceil, 'still locked'); self::assertStringContainsString('RED', $this->world->message); $this->world->player->keys['red'] = true; $this->tics(1, ['use' => true]); $this->tics(60); self::assertGreaterThan(50.0, $door->ceil); } public function testFindingASecretCountsIt(): void { $this->load('m1'); $this->noMonsters(); $this->placePlayer(25, 13, 0); $this->tics(2); self::assertSame(1, $this->world->player->secrets); self::assertSame(1, $this->world->stats()['secrets'] === 100 ? 1 : 0); }}