Add menu option to remove incorrect letters - crossword.koplugin - Unnamed repository; edit this file 'description' to name the repository. (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules (DIR) README (DIR) LICENSE --- (DIR) commit 651d9cf6df2523425a80c66e40b7fcf293dc1e5d (DIR) parent e2519abf8557999332157da7478049bcfa51dc9d (HTM) Author: Scarlett <social@scarlettmcallister.com> Date: Sun, 7 May 2023 11:25:41 -0300 Add menu option to remove incorrect letters Diffstat: M gameview.lua | 35 ++++++++++--------------------- M puzzle.lua | 11 +++++++++-- 2 files changed, 20 insertions(+), 26 deletions(-) --- (DIR) diff --git a/gameview.lua b/gameview.lua @@ -247,23 +247,6 @@ function GameView:showGameMenu() end, }, { - text = _("Check Word"), - enabled = false, - callback = function() - - end, - }, - { - text = _("Check Puzzle"), - callback = function() - self.puzzle:checkPuzzle() - UIManager:close(game_dialag) - self:refreshGameView() - end, - }, - }, - { - { text = _("Reveal Square"), callback = function() self.puzzle:revealSquare( @@ -273,18 +256,22 @@ function GameView:showGameMenu() self:refreshGameView() end, }, - { - text = _("Reveal Word"), - enabled = false, + }, + { + { + text = _("Check Puzzle"), callback = function() - + UIManager:close(game_dialag) + self.puzzle:checkPuzzle() + self:refreshGameView() end, }, { - text = _("Reveal Puzzle"), - enabled = false, + text = _("Remove Incorrect"), callback = function() - + self.puzzle:removeIncorrectGuesses() + UIManager:close(game_dialog) + self:refreshGameView() end, }, }, (DIR) diff --git a/puzzle.lua b/puzzle.lua @@ -365,8 +365,7 @@ function Puzzle:checkPuzzle() for char_pos, grid_index in ipairs(solve.grid_indices) do if self.guesses[grid_index] and not grid_elm_results[grid_index] then local letter_guess = self.guesses[grid_index].letter - logger.dbg(letter_guess) - -- Only check the guess if it is not nil or an empty string + -- Only check the guess if it is not nil or an empty string if letter_guess ~= "" and letter_guess ~= nil then local letter_solve = string.sub(solve.word, char_pos, char_pos) local guess_status = (letter_guess == letter_solve) and @@ -422,4 +421,12 @@ function Puzzle:checkSquare(row, col) end end +function Puzzle:removeIncorrectGuesses() + for grid_elem, guess in pairs(self.guesses) do + if guess.status == Guess.STATUS.CHECKED_INCORRECT then + self.guesses[grid_elem] = nil + end + end +end + return Puzzle