test: a barbarian in the rally tests steps aside when another player spawned on its field

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-29 10:05:55 +01:00
parent 68f901e3d9
commit 550f7625eb
1 changed files with 5 additions and 0 deletions

View File

@ -27,8 +27,13 @@ function rallied(Village $village, array $units = []): Village
return $village->fresh(); return $village->fresh();
} }
/** A barbarian village at the offset, or the next free field to the east when another player spawned there. */
function barbarianNear(Village $near, int $dx, int $dy): Village function barbarianNear(Village $near, int $dx, int $dy): Village
{ {
while (Village::where('world_id', $near->world_id)->where('x', $near->x + $dx)->where('y', $near->y + $dy)->exists()) {
$dx++;
}
return app(VillageFactory::class)->create($near->world, null, 'Barbarian village', $near->x + $dx, $near->y + $dy, ['headquarters' => 1, 'storage' => 1, 'farm' => 1]); return app(VillageFactory::class)->create($near->world, null, 'Barbarian village', $near->x + $dx, $near->y + $dy, ['headquarters' => 1, 'storage' => 1, 'farm' => 1]);
} }