mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:20:45 +00:00
Merge pull request #139 from BeGj/fix/click-outside-map-for-findWarshipsNearCell
handle findWarshipsNearCell (unhandled exception) when clicking outside the map
This commit is contained in:
@@ -82,6 +82,10 @@ export class UnitLayer implements Layer {
|
||||
* @returns Array of player's warships in range, sorted by distance (closest first)
|
||||
*/
|
||||
private findWarshipsNearCell(cell: { x: number; y: number }): UnitView[] {
|
||||
if (!this.game.isValidCoord(cell.x, cell.y)) {
|
||||
// The cell coordinate were invalid (user probably clicked outside the map), therefore no warships can be found
|
||||
return [];
|
||||
}
|
||||
const clickRef = this.game.ref(cell.x, cell.y);
|
||||
|
||||
// Make sure we have the current player
|
||||
|
||||
Reference in New Issue
Block a user