Skip to content

Commit

Permalink
feat(grid): call copy() on the initial cursor hex in Grid.traverse()
Browse files Browse the repository at this point in the history
This guarantees copy() is always called whenever a hex is created using Grid
  • Loading branch information
flauwekeul committed Apr 22, 2021
1 parent 8df5488 commit 98c7054
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/grid/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Grid<T extends Hex> {
const result: T[] = []
const hasTraversedBefore = this.traverser !== infiniteTraverser
const previousHexes = [...this.traverser()]
let cursor: T = previousHexes[previousHexes.length - 1] || createHex(this.hexPrototype)
let cursor: T = previousHexes[previousHexes.length - 1] || createHex(this.hexPrototype).copy() // copy to enable users to make custom hexes

for (const traverser of traversers) {
for (const nextCursor of traverser(cursor)) {
Expand Down

0 comments on commit 98c7054

Please sign in to comment.