diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-08-06 15:36:05 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-06 15:36:05 +0200 |
| commit | 2656796d927391f6e85724da9e352415159c7140 (patch) | |
| tree | 2f715c82f72610d8578405128c939af4b997fe94 | |
| parent | 3f67804688c193047b06ec66269dc0d0c149c01a (diff) | |
| download | muhqs-game-2656796d927391f6e85724da9e352415159c7140.tar.gz muhqs-game-2656796d927391f6e85724da9e352415159c7140.zip | |
prevent choice index out of bounds errors
This can happen if the last x coordinate of a choice is clicked.
| -rw-r--r-- | go/ui/choice.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/go/ui/choice.go b/go/ui/choice.go index 1c1c72b6..f937646b 100644 --- a/go/ui/choice.go +++ b/go/ui/choice.go @@ -40,6 +40,7 @@ func (c *Choice) setText() { func (c *Choice) GetChoosen(x, y int) int { i := (y - c.Y) / (c.Height / len(c.choices)) + if i == len(c.choices) { i = i - 1 } return i } |
