Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HexGrid, Hex, pathfinding.ts refactor #2461

Merged
merged 10 commits into from
Aug 2, 2023
Merged

HexGrid, Hex, pathfinding.ts refactor #2461

merged 10 commits into from
Aug 2, 2023

Conversation

andretchen0
Copy link
Contributor

This is largely clean up refactoring of a few files connected to HexGrid done in the course of reading through the files.

Note

One possibly controversial thing I wanted to point out is that I deprecated a lot of "shortcut" methods in HexGrid.

Those methods appeared to have been written before allhexes was added to HexGrid. As a result of adding allhexes, the shortcut method calls can each be replaced with a single line. That means less code and less indirection in a module that's already pretty busy. So, a good thing in my estimation.

It also deprecates forEachHex. Using allhexes allows all functional JS array methods. There's not a compelling reason to keep both approaches, and allhexes is much more flexible.

To compare:

forEach

  • allhexes: hexGrid.allhexes.forEach(hex => doSomething(hex))
  • forEachHex: hexGrid.forEachHex(hex => doSomething(hex))

filter

  • allhexes: hexGrid.allhexes.filter(hex => isSomething(hex))
  • forEachHex: no equivalent

map

  • allhexes: hexGrid.allhexes.map(hex => transform(hex))
  • forEachHex: no equivalent

... etc.

@vercel
Copy link

vercel bot commented Jul 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ancientbeast ✅ Ready (Inspect) Visit Preview Jul 31, 2023 10:36pm

@ghost
Copy link

ghost commented Jul 31, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@andretchen0 andretchen0 marked this pull request as ready for review August 1, 2023 12:41
@DreadKnight DreadKnight merged commit ba65fa3 into FreezingMoon:master Aug 2, 2023
3 checks passed
@andretchen0 andretchen0 deleted the hex-refactor branch August 2, 2023 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants