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

creature.adjacentHexes returns counter-clockwise hexes when clockwise=true #2470

Closed
andretchen0 opened this issue Aug 4, 2023 · 0 comments
Closed
Assignees
Labels
abilities The issue is related to an unit ability or more coding This issue requires some programming input Deals with hotkeys, interaction & accessibility
Milestone

Comments

@andretchen0
Copy link
Contributor

andretchen0 commented Aug 4, 2023

I came across this 8-year-old TODO in the code:

https://github.com/FreezingMoon/AncientBeast/blame/ba65fa35bb4cf78b8c5807fd9e158d3511401d94/src/creature.ts#L1034C6-L1034C10

I happen to have been adding code that does that.

However, the function Creature.adjacentHexes takes a "clockwise" argument. When I compared my implementation, it didn't match the order of the original implementation's returned value.

It turns out that the old implementation was returning a counter-clockwise result – at least in terms of the game coordinate system and HexGrid coordinate system, where 0, 0 is top, left.

There's only one caller that passes clockwise=true. Is it necessary to keep this functionality? Should it be renamed counterClockwise?

Fwiw, if clockwise=true isn't passed then the default order for the Hex[] result is sorted by row, then by column, so neither counter-clockwise, not clockwise.


I think this should probably just be removed as an option. The only caller that passes a "clockwise" value (Impaler), doesn't rely on it exclusively, and to do so would be weird:

  • The caller searches all the returned hexes for the best candidate to attack, based on candidates' shock stat.
  • The only time the returned Hex[] order matters is when it break ties, in instances where the top candidates have the same shock stat.

... But that doesn't really make sense in a game where opposing players face opposing directions. Both a right-facing player and a left-facing player will break ties in the same direction: A left-facing character will attack a creature behind it before a creature in front of it.

@DreadKnight DreadKnight added coding This issue requires some programming abilities The issue is related to an unit ability or more labels Aug 8, 2023
@DreadKnight DreadKnight added this to the 0.5 - Chimera milestone Aug 8, 2023
@DreadKnight DreadKnight added the input Deals with hotkeys, interaction & accessibility label Aug 8, 2023
@DreadKnight DreadKnight added this to hexagon grid in interface tweaks Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abilities The issue is related to an unit ability or more coding This issue requires some programming input Deals with hotkeys, interaction & accessibility
Projects
interface tweaks
hexagon grid
Development

No branches or pull requests

2 participants