<?phpnamespace Tests;use App\Revisited\Land\Game;use App\Scene\RevisitedScene;use JumPHP\Testing\GameTestCase;/** The two hands played through the scene: F / a click strikes, a drag still looks, V / a right click brandishes. */final class RevisitedHandsSceneTest extends GameTestCase{ private function begin(): Game { $this->game->start(RevisitedScene::class, ['seed' => 7, 'new' => true, 'help' => false, 'hold' => 'torch,club']); $this->game->run(4); self::assertSame('play', $this->game->peek('mode')); /** @var Game $g */ $g = $this->game->peek('game'); self::assertSame(['club', 'torch'], [$g->inv->hand, $g->inv->handLeft]); return $g; } public function testAClickWithoutDraggingStrikesWithTheRightHand(): void { $g = $this->begin(); $mouse = $this->game->engine->input->getMouse(); $mouse->move(160, 100); $this->game->run(1); $mouse->down(1); $this->game->run(1); $mouse->up(1); $this->game->run(1); self::assertNotNull($g->swing, 'the click struck'); self::assertSame('right', $g->swing['side']); $this->game->run(4); self::assertGreaterThan(0.0, $g->swingPhase(), 'the blow is drawn'); $this->game->run(60); self::assertNull($g->swing, 'over after the recovery'); } public function testDraggingTheMouseStillLooksAroundWithoutStriking(): void { $g = $this->begin(); $mouse = $this->game->engine->input->getMouse(); $yaw = $g->yaw; $mouse->move(160, 100); $mouse->down(1); $this->game->run(1); for ($i = 1; $i <= 10; $i++) { $mouse->move(160 + $i * 4, 100); $this->game->run(1); } $mouse->up(1); $this->game->run(1); self::assertNotEqualsWithDelta($yaw, $g->yaw, 0.1, 'the drag turned the view'); self::assertNull($g->swing, 'a drag is not a blow'); } public function testTheAttackKeyStrikesAndTheLeftHandKeyBrandishesTheTorch(): void { $g = $this->begin(); $this->game->press('rv_attack'); self::assertNotNull($g->swing); $this->game->run(60); $this->game->press('rv_left'); self::assertGreaterThan(0.0, $g->brandishPhase(), 'V sweeps the torch'); $this->game->run(60); // a right click without a drag does the same $mouse = $this->game->engine->input->getMouse(); $mouse->move(160, 100); $mouse->down(3); $this->game->run(1); $mouse->up(3); $this->game->run(1); self::assertGreaterThan(0.0, $g->brandishPhase(), 'the right click sweeps it too'); $this->game->press('rv_swap'); self::assertSame(['torch', 'club'], [$g->inv->hand, $g->inv->handLeft], 'X swaps the hands'); }}