test: the map relations test places its barbarian on a free field, so a random spawn can't take it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-11-03 09:59:20 +01:00
parent b20de08ba1
commit 8f762120ec
1 changed files with 3 additions and 1 deletions

View File

@ -26,7 +26,9 @@ it('colours villages by what their owner is to the viewer', function () {
$ally = startVillage();
$foe = startVillage();
$stranger = startVillage();
$barbarian = app(VillageFactory::class)->create($me->world, null, 'Barbarian village', $me->x + 2, $me->y + 2, ['headquarters' => 1]);
// A free field near me: the other players settle at random and may take any given one.
$spot = collect(range(2, 10))->first(fn (int $d) => ! Village::where('world_id', $me->world_id)->where('x', $me->x + $d)->where('y', $me->y + 2)->exists());
$barbarian = app(VillageFactory::class)->create($me->world, null, 'Barbarian village', $me->x + $spot, $me->y + 2, ['headquarters' => 1]);
foreach ([[$me, 'AAA'], [$ally, 'BBB'], [$foe, 'CCC']] as [$v, $tag]) {
app(Tribes::class)->found(owner($v), $v->world_id, "Tribe $tag", $tag);
}