feat: auto-pick an unused village_layout slot for import_village - #747
Merged
Conversation
When --x/--y are omitted, import_village now picks the first VILLAGE_LAYOUT slot with no existing PopulationCentre on it, instead of requiring coordinates to be hand-picked. Passing only one of --x/--y now raises a clear CommandError instead of silently doing something unintended. This lets ad-hoc imports outside the setup_world/import_villages pipeline (e.g. trying out a village file not in locations/data/) claim spare grid space without colliding with the pipeline's own slots - though it's not persistent across a setup_world rerun, which wipes and reimports only locations/data/'s contents. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C6BX7dFJWn2xMYn9qggdos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import_village(the singular, ad-hoc management command) required--x/--yto be passed explicitly. It now auto-picks the first unoccupiedvillage_layout.VILLAGE_LAYOUTslot when both are omitted, so an ad-hoc import (e.g. trying out a village file outsidelocations/data/, so outside thesetup_world/import_villagespipeline) can claim spare grid space without colliding with the pipeline's own slots or requiring hand-picked coordinates.--x/--ynow raises a clearCommandErrorinstead of silently doing something unintended.setup_worldrerun — that command still wipes and reimports onlylocations/data/'s contents, so this only helps within a session.Testing
locations/tests/test_import_village_command.py:_resolve_origin's three cases (both coords given, only one given, neither given) and_pick_unused_layout_slot's slot-selection logic (picks first free slot, skips occupied ones, raises when the grid is full, ignores off-grid centres). User-run test suite, all passing.🤖 Generated with Claude Code
https://claude.ai/code/session_01C6BX7dFJWn2xMYn9qggdos