Islanders-Game / Islanders

A clone of the popular "Settlers of Catan", written in Typescript.
Other
4 stars 0 forks source link

House/City/Road placement is incorrectly calculated #1211

Closed andersfischernielsen closed 3 years ago

andersfischernielsen commented 3 years ago

Sometimes when placing a house or a city on the board, the resulting building will be placed elsewhere on the board. Undo fixes this, but it's not very elegant to have to place houses multiple times to get them to stick where you want. Roads also seem bugged.

andersfischernielsen commented 3 years ago

This has nothing to do with devicePixelRatio. It simply looks like the conversion from screen coordinates to map coordinates is buggy in getClosestPoint in Map.vue.

andersfischernielsen commented 3 years ago

After doing some digging in the placement code, it turns out that getMatrixCoordCorner in HexCoordinate.ts is buggy

andersfischernielsen commented 3 years ago

https://github.com/Colonists-Game/Colonists/blob/36423c9013ac11cc9c868fb3e3d62a98caa363f8/colonists-shared/lib/HexCoordinate.ts#L77-L114