toBe(5.0) ->and(TravelTime::distance(500, 500, 500, 500))->toBe(0.0); }); it('moves at the pace of the slowest unit', function () { $travel = new TravelTime(gameConfig()); expect($travel->seconds(['spear' => 10], 5.0, 'normal'))->toBe(18 * 5 * 60) ->and($travel->seconds(['spear' => 10, 'ram' => 1], 5.0, 'normal'))->toBe(30 * 5 * 60) ->and($travel->seconds(['spear' => 10, 'ram' => 0], 5.0, 'normal'))->toBe(18 * 5 * 60); }); it('speeds up with the travel mode, world speed and unit speed', function () { $travel = new TravelTime(gameConfig()); $fast = new TravelTime(gameConfig(['world' => ['speed' => 100], 'movement' => ['unit_speed' => 0.5]])); expect($travel->seconds(['spear' => 1], 5.0, 'fast'))->toBe(4320) ->and($travel->seconds(['spear' => 1], 5.0, 'sneaky'))->toBe(10800) ->and($fast->seconds(['spear' => 1], 5.0, 'normal'))->toBe(108); }); it('marches a spear 9 minutes a field on World 1, speed 4 with armies at half speed', function () { $w1 = new TravelTime(gameConfig(['world' => ['speed' => 4], 'movement' => ['unit_speed' => 0.5]])); expect($w1->seconds(['spear' => 1], 5.0, 'normal'))->toBe(9 * 5 * 60); }); it('is spotted once it comes within visibility plus detection', function () { $travel = new TravelTime(gameConfig()); $seconds = $travel->seconds(['spear' => 1], 34.0, 'normal'); // Normal visibility 15 plus 2 fields of detection: seen for the last half of 34 fields. expect($travel->warningSeconds($seconds, 34.0, 'normal', 2.0))->toBe(intdiv($seconds, 2)) ->and($travel->warningSeconds($seconds, 10.0, 'normal', 2.0))->toBe($seconds) ->and($travel->warningSeconds($seconds, 34.0, 'sneaky', 20.0))->toBe(0); });