Improve transport ship spawn logic #2
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.
Currently, when sending a transport ship to a target territory, the game selects the spawn tile that is closest to the target in straight-line distance from the player's territory. This can result in transport ships taking longer water routes, causing troops to arrive later than necessary.
This PR refactors the transport ship spawning logic to select the source tile that allows the ship to reach the target in the shortest estimated travel time over water, using the pathfinder to estimate routes.
Key points:
Evaluates all eligible shore tiles controlled by the player.
Estimates the path length or travel time from each tile to the destination.
Chooses the tile that minimizes the expected arrival time of the transport ship.
This ensures transport ships are sent efficiently and troops arrive at the target faster, even if the chosen tile is not the geographically closest territory.
Checklist:
I have added screenshots for all UI updates (not applicable here)
I process any text displayed to the user through translateText() and I've added it to the en.json file (not applicable)
I have added relevant tests to the test directory (No but I have tested seems to work still working on it)
I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
Discord contact: exudiz