Anmelden
DE
games/doom-jumphp / tests / LevelsTest.php · commit 8e1cb9f
<?phpnamespace Tests;final class LevelsTest extends WorldTestCase{    public function testTheBlueKeyShelfLiftOfThePlantWorks(): void    {        $this->load('m2');        $this->noMonsters();        // the lift 'l' (column 3, rows 6-7) is used from the storage floor east of it        $this->placePlayer(4, 6, 180);        $lift = $this->world->level->sectorAt(...$this->cell(3, 6));        $this->tics(1, ['use' => true]);        $this->tics(30);        self::assertSame(0.0, $lift->floor);    }    public function testTheYardStairsLeadToTheYellowKey(): void    {        $this->load('m2');        $this->noMonsters();        // from the yard floor below the stairs (row 10), walk north up the steps to the key (26, 5)        $mo = $this->placePlayer(26, 10, 90);        $this->tics(54, ['forward' => 1]);        self::assertSame(56.0, $mo->floorz, 'on the platform');        self::assertTrue($this->world->player->keys['yellow']);    }    public function testTheWardensDeathOpensTheWayToTheExit(): void    {        $this->load('m3');        $warden = null;        foreach ($this->world->mobjs as $mo) {            if ($mo->type === 'warden') {                $warden = $mo;            } elseif ($mo->is(\App\Game\Info::COUNTKILL)) {                $this->world->remove($mo);            }        }        self::assertNotNull($warden);        $this->placePlayer(15, 6, 90);        $this->world->player->god = true;        $this->world->damage($warden, null, $this->world->player->mo, 10000);        $this->tics(35 * 4);        $gate = $this->world->level->sectorAt(...$this->cell(15, 4));        self::assertGreaterThan(64.0, $gate->ceil, 'the gate is open');        $this->tics(35 * 4, ['forward' => 1]);        self::assertSame('exit', $this->world->exit);    }    public function testEveryLevelCanBeStartedWithWhatThePreviousOneGave(): void    {        $w = $this->load('m1');        $w->player->ammo['shells'] = 12;        $w->player->weapons[3] = true;        $carry = $w->player->carry();        $next = new \App\Game\World(\App\Game\Campaign::level(dirname(__DIR__) . '/assets/maps/m2.json', 'm2'), 2, $carry, 1);        self::assertSame(12, $next->player->ammo['shells']);        self::assertTrue($next->player->weapons[3]);    }}