Skip to content

Conversation

@mepoohsta
Copy link
Contributor

Description:

Fixing https://discord.com/channels/1359946986937258015/1360078040222142564/1463898386854973642

Now, if not all tiles on the spawn circle can be owned, the algorithm tries to select another random spawn tile.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

nikolaj_mykola

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

The changes add validation to spawn tile selection by introducing overloaded function signatures in getSpawnTiles() that support strict validation. When enabled, the function rejects spawn selections if any tile falls outside land boundaries instead of filtering invalid tiles. The spawn execution logic uses this strict mode to ensure selected spawn locations are fully within land.

Changes

Cohort / File(s) Summary
Spawn tile validation function
src/core/execution/Util.ts
Added overloaded getSpawnTiles() signatures with new optional requireAllValid parameter. When true, returns null if any spawn tile is invalid; when false (default), filters and returns only valid tiles. Supports type-safe calling conventions for both modes.
Spawn selection safety check
src/core/execution/SpawnExecution.ts
Added guard condition in randomSpawnLand() that calls getSpawnTiles() with requireAllValid: true to validate the chosen spawn tile is fully within land boundaries. Continues tile selection loop if validation fails.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🌍 Spawn tiles dance with new grace,
Checking bounds with overload's embrace,
No more tiles lost to borderland's face,
Validation guards each sacred place,
Land-locked spawns now stay in place ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: improving random spawn selection to avoid spawning near water, which matches the changeset's addition of validation to ensure spawn tiles are fully within land.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix for spawn tile validation and the new behavior when tiles cannot be owned due to water proximity.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ryanbarlow97 ryanbarlow97 added the Bugfix Fixes a bug label Feb 3, 2026
@ryanbarlow97 ryanbarlow97 added this to the v30 milestone Feb 3, 2026
Comment on lines +116 to +120
if (!getSpawnTiles(this.mg, tile, true)) {
// if some of the spawn tile is outside of the land, we want to find another spawn tile
continue;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean we are doing the check twice? once here and again but without the requireAllValid?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we replace the getSpawnTiles with some "isValidSpawnLocation" and update utils to add a new function which basically is a clone of the original getSpawnTiles(), but uses isShore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix Fixes a bug

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants