Skip to content

Commit

Permalink
fix :: grid selection max count
Browse files Browse the repository at this point in the history
  • Loading branch information
jombidev committed Oct 16, 2024
1 parent bf27dca commit bd81dbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/com/teamapi/palette/service/ChatService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ class ChatService(

is ChatAnswer.GridAnswer -> {
val grid = pendingQuestion as PromptData.Grid
val gridPossibleMax = grid.question.xSize * grid.question.ySize
val maxSize = grid.question.maxCount
val exceeds = message.choice.filter { it >= maxSize }
val exceeds = message.choice.filter { it >= gridPossibleMax }
if (exceeds.isNotEmpty())
throw CustomException(ErrorCode.QNA_INVALID_GRID_CHOICES, exceeds.joinToString(", "), maxSize - 1)
throw CustomException(ErrorCode.QNA_INVALID_GRID_CHOICES, exceeds.joinToString(", "), gridPossibleMax - 1)

if (message.choice.size > maxSize)
throw CustomException(ErrorCode.QNA_INVALID_GRID_ABOVE_MAX, maxSize)
Expand Down

0 comments on commit bd81dbe

Please sign in to comment.