Skip to content

Commit

Permalink
Fix relative coordinates #665
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Apr 3, 2020
1 parent 14b0c3c commit 87e71ef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Goban.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@ export default class Goban extends Component {
} else if (coordinatesType === 'relative') {
let relativeCoord = (x, size) => {
let halfSize = Math.ceil(size / 2)
if (size === 19 && x === 10) return 'X'

let ix = size - x + 1
if (ix < halfSize) return `${ix}*`

return x.toString()
}

return [
x => relativeCoord(x + 1, board.width),
y => relativeCoord(y + 1, board.height)
y => relativeCoord(board.height - y, board.height)
]
} else {
return [x => alpha[x], y => board.height - y] // Default
Expand Down

0 comments on commit 87e71ef

Please sign in to comment.