36 lines
1.6 KiB
PHP
36 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use App\Game\Travel\TravelTime;
|
||
|
|
|
||
|
|
it('measures distance in fields as the crow flies', function () {
|
||
|
|
expect(TravelTime::distance(500, 500, 503, 504))->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('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);
|
||
|
|
});
|