diff --git a/tests/Feature/RallyTest.php b/tests/Feature/RallyTest.php index 067f833..9d59eb5 100644 --- a/tests/Feature/RallyTest.php +++ b/tests/Feature/RallyTest.php @@ -27,8 +27,13 @@ function rallied(Village $village, array $units = []): Village 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 { + 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]); }