2026-10-28 18:17:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Game\ConfigLint;
|
|
|
|
|
|
|
|
|
|
it('finds no locks in the default config', function () {
|
|
|
|
|
expect(ConfigLint::check(gameConfig()))->toBe([]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('finds no locks in the dev world', function () {
|
|
|
|
|
expect(ConfigLint::check(gameConfig(['world' => ['speed' => 100]])))->toBe([]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports a farm whose workers eat more than it makes', function () {
|
|
|
|
|
$config = gameConfig(['buildings' => ['farm' => ['workers' => ['base' => 40]]]]);
|
|
|
|
|
|
2026-10-28 21:26:25 +00:00
|
|
|
expect(ConfigLint::check($config))->toContain('[farm] level 1 feeds fewer people than it needs as workers.');
|
2026-10-28 18:17:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports a storage level that its predecessor cannot pay for', function () {
|
|
|
|
|
$config = gameConfig(['buildings' => ['storage' => ['cost' => ['wood' => 2000]]]]);
|
|
|
|
|
|
2026-10-28 21:26:25 +00:00
|
|
|
expect(ConfigLint::check($config))->toContain('[storage] level 2 costs more than level 1 holds.');
|
2026-10-28 18:17:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports requirement cycles and unknown requirements', function () {
|
|
|
|
|
$config = gameConfig(['buildings' => [
|
|
|
|
|
'wall' => ['requires' => ['rally_point' => 1]],
|
|
|
|
|
'rally_point' => ['requires' => ['wall' => 1, 'castle' => 1]],
|
|
|
|
|
]]);
|
|
|
|
|
|
|
|
|
|
expect(ConfigLint::check($config))
|
|
|
|
|
->toContain('[rally_point] requires unknown type [castle].')
|
|
|
|
|
->toContain('Requirement cycle through [wall].');
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-28 18:45:02 +00:00
|
|
|
it('reports start buildings that take more space than a village has', function () {
|
|
|
|
|
$config = gameConfig(['world' => ['village' => ['space' => 12]]]);
|
2026-10-28 18:17:34 +00:00
|
|
|
|
2026-10-28 18:45:02 +00:00
|
|
|
expect(ConfigLint::check($config))->toBe(['The start buildings take 17 building space, more than the village\'s 12.']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports a type that can never fit next to the start buildings', function () {
|
|
|
|
|
$config = gameConfig(['world' => ['village' => ['space' => 25]]]);
|
|
|
|
|
|
2026-10-28 20:39:48 +00:00
|
|
|
expect(ConfigLint::check($config))->toBe([
|
|
|
|
|
'[headquarters] does not fit next to the start buildings.',
|
|
|
|
|
'[academy] does not fit next to the start buildings.',
|
|
|
|
|
]);
|
2026-10-28 18:17:34 +00:00
|
|
|
});
|
2026-10-28 20:28:16 +00:00
|
|
|
|
|
|
|
|
it('reports a villager share that leaves no food surplus', function () {
|
|
|
|
|
expect(ConfigLint::check(gameConfig(['economy' => ['villager_share' => 1.0]])))
|
|
|
|
|
->toBe(['economy.villager_share must be between 0 and 1 (is 1), so farms leave a surplus.']);
|
|
|
|
|
});
|
2026-10-28 21:03:33 +00:00
|
|
|
|
|
|
|
|
it('reports a levy or desertion timer that never runs out', function () {
|
|
|
|
|
$config = gameConfig(['economy' => ['levy' => ['duration' => 0], 'starvation' => ['grace' => -1]]]);
|
|
|
|
|
|
|
|
|
|
expect(ConfigLint::check($config))->toBe([
|
|
|
|
|
'[economy.levy.duration] must be more than 0 seconds.',
|
|
|
|
|
'[economy.starvation.grace] cannot be negative.',
|
|
|
|
|
]);
|
|
|
|
|
});
|
2026-10-29 15:02:49 +00:00
|
|
|
|
|
|
|
|
it('reports garrisons that would starve their village or never regroup', function () {
|
|
|
|
|
$config = gameConfig(['world' => ['map' => ['barbarians' => ['garrison' => [
|
|
|
|
|
'max_food_share' => 0.9,
|
|
|
|
|
'regroup' => ['every_hours' => 0],
|
|
|
|
|
'profiles' => ['ghosts' => ['wraith' => 1.0]],
|
|
|
|
|
]]]]]);
|
|
|
|
|
|
|
|
|
|
expect(ConfigLint::check($config))
|
|
|
|
|
->toContain('Garrison profile [ghosts] fields [wraith], which is not a unit with a share above 0.')
|
|
|
|
|
->toContain('Barbarian garrisons must regroup: [regroup.every_hours] and [regroup.share] above 0.')
|
|
|
|
|
->toContain('[garrison.max_food_share] must stay below [economy.villager_share], or a garrison starves its village.');
|
|
|
|
|
});
|