|
Sudoku Showcase
|
The App is the central Controller and API of the application following Model-View-Controller architecture. More...
Public Member Functions | |
| def | __init__ (self, bool useUi=True, bool verbose=True) |
| int|None | selectedDigit (self) |
| Properties - State Management. More... | |
| None | selectedDigit (self, int|None digit) |
| Sets the property selectedDigit to a valid value or no value. More... | |
| tuple[int, int]|None | selectedCell (self) |
| (property) The selected cell defines the field/cell in the puzzle. More... | |
| None | selectedCell (self, tuple[int, int]|None pos) |
| Sets the property selectedCell to a tuple of coordinates or None. More... | |
| bool | inEraseMode (self) |
| (property) Defines if app is in eraseMode or not. More... | |
| bool | inNoteMode (self) |
| (property) Defines if app is in noteMode or not. More... | |
| bool | highlightRules (self) |
| (property) Defines if the ui visualizes the sudoku rules depending on the selected cell. More... | |
| bool | highlightDigits (self) |
| (property) Defines if the ui is visualizing the digits in the puzzle depending on the selected Digit. More... | |
| None | toggleEraseMode (self) |
| toggle property functions More... | |
| None | toggleNoteMode (self) |
| Toggle property noteMode. More... | |
| None | toggleHighlightRules (self) |
| Toggle property highlightRules. More... | |
| None | toggleHighlightDigits (self) |
| Toggle property highlighDigits. More... | |
| set[tuple[int, int]] | getErrorCells (self) |
| public property functions More... | |
| None | addErrorCell (self, int row, int col) |
| Adds a cell to errorCells. More... | |
| None | removeErrorCell (self, int row, int col) |
| Removes a Cell from errorCells. More... | |
| None | clearErrorCells (self) |
| Removes all cells from errorCells. More... | |
| None | selectDigit (self, int value) |
| Sets the selectedDigit to the value. More... | |
| None | selectCell (self, int row, int col) |
| Sets a cell as selected. More... | |
| None | deselectCell (self) |
| Deselects the cell. More... | |
| None | run (self) |
| Game Core Functions. More... | |
| None | startNewGame (self, str difficulty) |
| Starts a new Game and creates the ui, if needed. More... | |
| None | restartGame (self) |
| Restarts the current game. More... | |
| bool | hasGameEnded (self) |
| If the current game has ended. More... | |
| str | getPuzzle (self) |
| Game Core getter Functions. More... | |
| int | getGridSize (cls) |
| (classmethod) Returns the size of the grid (Puzzle) More... | |
| int | getBlockSize (cls) |
| (classmethod) Returns the size of a Block. More... | |
| str | getCurrentDifficulty (self) |
| Returns the difficulty of the current game. More... | |
| str | getDefaultDifficulty (self) |
| Returns the default difficulty of game. More... | |
| list[str] | getAllDifficultyNames (cls) |
| (classmethod) Returns the names of difficulty levels. More... | |
| int | getMistakesMade (self) |
| Returns the amount of mistakes made in the current game. More... | |
| int | getMaxMistakes (cls) |
| (classmethod) Returns the maximum amount of mistakes per game. More... | |
| int | getElapsedTime (self) |
| Returns the elapsed time in seconds of the current game. More... | |
| None | handleMove (self, int row, int col) |
| Game Move Functions. More... | |
| int|None | getFieldValue (self, int row, int col) |
| Setter / Getter Functions (Field, Digits) More... | |
| str | getFieldLabel (self, int row, int col) |
| Returns the Label for a Field at (row, col) More... | |
| list[int] | getFieldNotes (self, int row, int col) |
| Returns a list with all Notes from a Field. More... | |
| None | printField (self, int row, int col) |
| Prints the Field attributes. More... | |
| bool | isFieldFixed (self, int row, int col) |
| Returns if a field is fixed. More... | |
| list[int]|list | getSetDigits (self) |
| Returns all the Digits, which occur 9 times in the current game. More... | |
| None | setAutoNotes (self) |
| Set Notes for all Fields automatically. More... | |
| None | clearAllNotes (self) |
| Clear all notes in the puzzle. More... | |
Public Attributes | |
| selectedDigit | |
| selectedCell | |
The App is the central Controller and API of the application following Model-View-Controller architecture.
It coordinates all major components:
The App also controls overall game flow logic, such as erase modes and other UI-related behaviors, which are intentionally separated from the core game logic.
This design intentionally results in a larger class with many forwarding functions, in order to keep submodules and domain classes cleaner and better separated.
| def sudoku.app.App.__init__ | ( | self, | |
| bool | useUi = True, |
||
| bool | verbose = True |
||
| ) |
| None sudoku.app.App.addErrorCell | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Adds a cell to errorCells.
| row | int |
| col | int |
| None sudoku.app.App.clearAllNotes | ( | self | ) |
Clear all notes in the puzzle.
| None sudoku.app.App.clearErrorCells | ( | self | ) |
Removes all cells from errorCells.
| None sudoku.app.App.deselectCell | ( | self | ) |
Deselects the cell.
| list[str] sudoku.app.App.getAllDifficultyNames | ( | cls | ) |
(classmethod) Returns the names of difficulty levels.
| int sudoku.app.App.getBlockSize | ( | cls | ) |
(classmethod) Returns the size of a Block.
| str sudoku.app.App.getCurrentDifficulty | ( | self | ) |
Returns the difficulty of the current game.
| str sudoku.app.App.getDefaultDifficulty | ( | self | ) |
Returns the default difficulty of game.
| int sudoku.app.App.getElapsedTime | ( | self | ) |
Returns the elapsed time in seconds of the current game.
| set[tuple[int, int]] sudoku.app.App.getErrorCells | ( | self | ) |
public property functions
Returns the current errorcells.
| str sudoku.app.App.getFieldLabel | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Returns the Label for a Field at (row, col)
| row | int - the row of the field in question |
| col | int - the column of the field in question |
| list[int] sudoku.app.App.getFieldNotes | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Returns a list with all Notes from a Field.
NOTE: The list can be empty.
| row | int - the row of the field in question |
| col | int - the column of the field in question |
| int | None sudoku.app.App.getFieldValue | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Setter / Getter Functions (Field, Digits)
Returns the value for a Field at (row, col)
| row | int - the row of the field in question |
| col | int - the column of the field in question |
| int sudoku.app.App.getGridSize | ( | cls | ) |
(classmethod) Returns the size of the grid (Puzzle)
| int sudoku.app.App.getMaxMistakes | ( | cls | ) |
(classmethod) Returns the maximum amount of mistakes per game.
| int sudoku.app.App.getMistakesMade | ( | self | ) |
Returns the amount of mistakes made in the current game.
| str sudoku.app.App.getPuzzle | ( | self | ) |
Game Core getter Functions.
Returns the str-repr of the current puzzle.
| list[int] | list sudoku.app.App.getSetDigits | ( | self | ) |
Returns all the Digits, which occur 9 times in the current game.
NOTE: list can be empty!
| None sudoku.app.App.handleMove | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Game Move Functions.
Lets the game handle a move depending on modes and the selectedDigit. Additionally checks if game over or won.
| row | int |
| col | int |
| bool sudoku.app.App.hasGameEnded | ( | self | ) |
If the current game has ended.
| bool sudoku.app.App.highlightDigits | ( | self | ) |
(property) Defines if the ui is visualizing the digits in the puzzle depending on the selected Digit.
NOTE: This setting does not affect the gameplay itself.
| bool sudoku.app.App.highlightRules | ( | self | ) |
(property) Defines if the ui visualizes the sudoku rules depending on the selected cell.
NOTE: This setting does not affect the gameplay itself.
| bool sudoku.app.App.inEraseMode | ( | self | ) |
(property) Defines if app is in eraseMode or not.
In eraseMode, the selectedCell will be set to no value. To set the eraseMode, use self.toggleEraseMode()
| bool sudoku.app.App.inNoteMode | ( | self | ) |
(property) Defines if app is in noteMode or not.
In noteMode, the selectedDigit can be assigned as a note to the selectedCell To set the NoteMode, use self.toggleNoteMode()
| bool sudoku.app.App.isFieldFixed | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Returns if a field is fixed.
| None sudoku.app.App.printField | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Prints the Field attributes.
| row | int - the row of the field in question |
| col | int - the column of the field in question |
| None sudoku.app.App.removeErrorCell | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Removes a Cell from errorCells.
| row | int |
| col | int |
| None sudoku.app.App.restartGame | ( | self | ) |
Restarts the current game.
Usually called from Client.
| None sudoku.app.App.run | ( | self | ) |
Game Core Functions.
Starts to run the application. and creates a new game with default difficulty
| None sudoku.app.App.selectCell | ( | self, | |
| int | row, | ||
| int | col | ||
| ) |
Sets a cell as selected.
Requirement to show rules.
| row | int - the row of selected cell |
| col | int - the column of selected cell |
| None sudoku.app.App.selectDigit | ( | self, | |
| int | value | ||
| ) |
Sets the selectedDigit to the value.
NOTE: if digit is already selected, it will be deselected. (like toggling)
| value | int - the newly selected digit |
| tuple[int, int] | None sudoku.app.App.selectedCell | ( | self | ) |
(property) The selected cell defines the field/cell in the puzzle.
Required to visualize the sudoku rules in the ui. To set a value, use self.selectedCell = tuple(int(x), int(y))
| None sudoku.app.App.selectedCell | ( | self, | |
| tuple[int, int] | None | pos | ||
| ) |
Sets the property selectedCell to a tuple of coordinates or None.
| pos | tuple | None |
| int | None sudoku.app.App.selectedDigit | ( | self | ) |
Properties - State Management.
(property) The selected digit defines the value assigned to field/cell in the puzzle. Returns a digit [1 .. 9] if selected. To set the selectedDigit, use self.selectedDigit = value
| None sudoku.app.App.selectedDigit | ( | self, | |
| int | None | digit | ||
| ) |
Sets the property selectedDigit to a valid value or no value.
| digit | int | None |
| None sudoku.app.App.setAutoNotes | ( | self | ) |
Set Notes for all Fields automatically.
| None sudoku.app.App.startNewGame | ( | self, | |
| str | difficulty | ||
| ) |
Starts a new Game and creates the ui, if needed.
All game-related settings will be reset.
| difficulty | str |
| None sudoku.app.App.toggleEraseMode | ( | self | ) |
toggle property functions
Toggle property eraseMode.
| None sudoku.app.App.toggleHighlightDigits | ( | self | ) |
Toggle property highlighDigits.
| None sudoku.app.App.toggleHighlightRules | ( | self | ) |
Toggle property highlightRules.
| None sudoku.app.App.toggleNoteMode | ( | self | ) |
Toggle property noteMode.
| sudoku.app.App.selectedCell |
| sudoku.app.App.selectedDigit |