18 lines
687 B
PHP
18 lines
687 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use App\Game\Map\BarbarianGrowth;
|
||
|
|
|
||
|
|
it('grows every few hours at world speed', function () {
|
||
|
|
expect((new BarbarianGrowth(gameConfig()))->interval())->toBe(8 * 3600)
|
||
|
|
->and((new BarbarianGrowth(gameConfig(['world' => ['speed' => 100]])))->interval())->toBe(288);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('only grows buildings below the cap', function () {
|
||
|
|
$growth = new BarbarianGrowth(gameConfig());
|
||
|
|
$buildings = [building(1, 'headquarters', 10), building(2, 'farm', 3), building(3, 'storage', 10)];
|
||
|
|
|
||
|
|
expect($growth->pick($buildings, 0.0)->id)->toBe(2)
|
||
|
|
->and($growth->pick($buildings, 0.99)->id)->toBe(2)
|
||
|
|
->and($growth->pick([building(1, 'farm', 10)], 0.5))->toBeNull();
|
||
|
|
});
|