game->start(TitleScene::class); $games = $this->game->peek('games'); $root = dirname(__DIR__); self::assertSame(count(GameLibrary::scan("$root/data", "$root/catalog")), count($games)); $this->game->shot('game-list'); } public function testRobinsonsRequiemShowsItsLanguageScreen(): void { if (!is_dir(dirname(__DIR__) . '/data/robinson')) { self::markTestSkipped('the data of Robinson\'s Requiem is not here (private files)'); } $this->game->start(PlayScene::class, ['game' => 'robinson']); $this->game->run(700); $machine = $this->game->peek('machine'); self::assertNull($machine->error); self::assertGreaterThan(100, $machine->cycles); $this->game->shot('robinson-flags'); } public function testTheSourceEditionPlaysLikeTheOriginalScripts(): void { $root = dirname(__DIR__); if (!is_dir("$root/data/robinson") || !is_file("$root/../../.alis-data/robinson/src/main.als")) { self::markTestSkipped('the data and the ALIS sources of Robinson\'s Requiem are not here (private files)'); } $this->game->start(PlayScene::class, ['game' => 'robinson']); $this->game->run(700); $original = md5(\App\Alis\SysVars::$frameBmp); $this->game->start(PlayScene::class, ['game' => 'robinson', 'edition' => 'source']); $this->game->run(700); $machine = $this->game->peek('machine'); self::assertNull($machine->error); self::assertNotSame([], \App\Alis\SysVars::$sourceCache, 'the scripts came from the sources'); self::assertSame($original, md5(\App\Alis\SysVars::$frameBmp)); $this->game->shot('robinson-source-edition'); } public function testTheHdEditionDrawsThroughTheGpuFilter(): void { $root = dirname(__DIR__); if (!is_dir("$root/data/robinson") || !is_file("$root/../../.alis-data/robinson/src/main.als")) { self::markTestSkipped('the data and the ALIS sources of Robinson\'s Requiem are not here (private files)'); } $this->game->start(PlayScene::class, ['game' => 'robinson', 'edition' => 'hd']); $this->game->run(700); self::assertNull($this->game->peek('machine')->error); $hd = $this->game->peek('hd'); self::assertNotNull($hd); // without OpenGL (a machine with no GPU at all) the game still runs, with the plain picture self::assertSame($hd->isAvailable(), $hd->isOn()); $this->game->shot('robinson-hd'); } public function testTheHdEditionWritesTheTextsWithARealFontAndDrawsThe3dAtTwiceTheResolution(): void { $root = dirname(__DIR__); if (!is_dir("$root/data/robinson") || !is_file("$root/../../.alis-data/robinson/src/main.als")) { self::markTestSkipped('the data and the ALIS sources of Robinson\'s Requiem are not here (private files)'); } // the flags (Spanish), the film skipped, then the menu: its START button writes its name in the game's font $this->game->start(PlayScene::class, ['game' => 'robinson', 'edition' => 'hd', 'clicks' => [[14, 100, 60], [26, 160, 100], [60, 165, 167], [66, 165, 167]]]); $scene = $this->game->scene(); $click = function (float $in) use ($scene): void { $p = new \ReflectionProperty($scene, 'clicks'); $at = $this->game->peek('time') + $in; $p->setValue($scene, [[$at, 165, 167]]); }; $text = ''; for ($s = 0; $s < 900 && $text === ''; $s += 5) { $this->game->run(300); $click(0.0); $this->game->run(12); $text = implode('', array_map(static fn (array $g) => chr($g['char']), \App\Alis\SysVars::$hdShown)); } // the text is typed letter by letter: until it stops growing $read = static fn () => implode('', array_map(static fn (array $g) => chr($g['char']), \App\Alis\SysVars::$hdShown)); for ($f = 0, $same = 0; $f < 90 && $same < 6; $f++) { $this->game->run(1); $now = $read(); $same = strlen($now) >= strlen($text) && strlen($now) > 0 && $now === $text ? $same + 1 : 0; $text = strlen($now) >= strlen($text) ? $now : $text; } self::assertGreaterThan(8, strlen($text), 'the menu writes its text with the font'); // the characters are not in the 8-bit picture: the host draws them (App\Hd\HdRenderer) self::assertNotNull(\App\Alis\SysVars::$hdShown[0]['ink'] ?? null); $this->game->shot('robinson-hd-text'); // START: the jungle; its 3D is drawn again at twice the resolution (fn/hd3d.php), shown over the picture $land = null; for ($s = 0; $s < 120 && $land === null; $s += 2) { if ($s % 10 === 0 && $s < 40) { $click(0.0); } $this->game->run(120); $land = \App\Alis\SysVars::$hdLand; } self::assertNotNull($land, 'the 3D has its HD picture'); self::assertSame(2 * $land['w'] * 2 * $land['h'], strlen($land['bmp']) - 54 - 1024); self::assertNull($this->game->peek('machine')->error); $this->game->run(60); $this->game->shot('robinson-hd-3d'); } public function testSkipIntroGoesStraightToTheGameButKeepsTheFlags(): void { $root = dirname(__DIR__); if (!is_dir("$root/data/robinson")) { self::markTestSkipped('the data of Robinson\'s Requiem is not here (private files)'); } $scene = $this->game->start(PlayScene::class, ['game' => 'robinson']); $skip = $this->game->peek('skip'); $mouse = $this->game->peek('engine', $this->game)->input->getMouse(); $press = function () use ($mouse): void { $mouse->move(270, 222); // the button, bottom right (view pixels) $mouse->down(1); $this->game->run(1); $mouse->up(1); $mouse->move(10, 10); $this->game->run(1); }; // the logo film: the button is offered, a click skips it, the flags stay (the language is the player's) for ($f = 0; $f < 600 && !$skip->offered(); $f += 10) { $this->game->run(10); } self::assertTrue($skip->offered(), 'the button during the logo film'); $this->game->shot('robinson-skip-button'); $press(); $this->game->run(240); self::assertSame('flags', $skip->phase()); self::assertFalse($skip->offered(), 'no button on the flags'); // a flag chosen, then the introduction's films: skipped to the options panel (new \ReflectionProperty($scene, 'clicks'))->setValue($scene, [[$this->game->peek('time') + 0.1, 100, 60]]); for ($f = 0; $f < 1200 && !$skip->offered() && $skip->phase() !== 'done'; $f += 10) { $this->game->run(10); } if ($skip->offered()) { $press(); } for ($f = 0; $f < 2400 && $skip->phase() !== 'done'; $f += 30) { $this->game->run(30); } self::assertSame('done', $skip->phase(), 'the introduction skipped (it lasts about 8 minutes)'); self::assertFalse($skip->offered(), 'no button once the game has started'); self::assertNull($this->game->peek('machine')->error); $this->game->run(300); $this->game->shot('robinson-after-skip'); } }