Skip to content

Commit

Permalink
refactor: add isInBounds({x:number, y:number})
Browse files Browse the repository at this point in the history
  • Loading branch information
andretchen0 committed Aug 4, 2023
1 parent a6e3f89 commit 62b3adf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utility/hexgrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as arrayUtils from './arrayUtils';
import Game from '../game';
import { DEBUG } from '../debug';
import { HEX_WIDTH_PX } from './const';
import { Point } from './pointfacade';

interface GridDefinition {
numRows: number;
Expand Down Expand Up @@ -241,6 +242,12 @@ export class HexGrid {
}
}

isInBounds({ x, y }: Point) {
return (
y < this.game.grid.hexes.length && y >= 0 && x < this.game.grid.hexes[y].length && x >= 0
);
}

querySelf(o) {
const game = this.game;
const defaultOpt = {
Expand Down

0 comments on commit 62b3adf

Please sign in to comment.