diff --git a/lib/src/game/board/SudokuGameboard.dart b/lib/src/game/board/SudokuGameboard.dart index 5d4274f..0fa2041 100644 --- a/lib/src/game/board/SudokuGameboard.dart +++ b/lib/src/game/board/SudokuGameboard.dart @@ -7,7 +7,7 @@ import 'SudokuChunk.dart'; class SudokuGameboard { final _chunkMap = {}; - SudokuGameboard.generator(var numbersToRemove) { + SudokuGameboard(var numbersToRemove) { var generator = SudokuGenerator(numbersToRemove); var unshuffledMap = {}; @@ -30,12 +30,10 @@ class SudokuGameboard { var pairsOfChunks = columnPairList(gameboardCol); var pairsOfSquares = columnPairList(chunkCol); - final chunkList = pairsOfChunks.map((pair) => - sudokuChunks[pair]).toList(); + final chunkList = pairsOfChunks.map((pair) => sudokuChunks[pair]).toList(); for(var chunk in chunkList) { - colValues.addAll( - pairsOfSquares.map((pair) => + colValues.addAll(pairsOfSquares.map((pair) => chunk.sudokuSquares[pair].value)); } return colValues; @@ -51,16 +49,15 @@ class SudokuGameboard { var pairsOfChunks = rowPairList(gameboardRow); var pairsOfSquares = rowPairList(chunkRow); - final chunkList = pairsOfChunks.map((pair) => - sudokuChunks[pair]).toList(); + final chunkList = pairsOfChunks.map((pair) => sudokuChunks[pair]).toList(); for(var chunk in chunkList) { - rowValues.addAll( - pairsOfSquares.map((pair) => + rowValues.addAll(pairsOfSquares.map((pair) => chunk.sudokuSquares[pair].value)); } return rowValues; } + /// Given a column index, 1 - 9, create a List of Pairs that compose the given column. List columnPairList(int index) { var pairs = []; @@ -89,8 +86,8 @@ class SudokuGameboard { return chunkData; } - ///Given a particular row/column index, 1 - 9, return the equivalent index - ///within the specific chunk. + /// Given a particular row/column index, 1 - 9, return the equivalent index of + /// where it's contained within the chunk. int getChunkIndex(int index) { var result = (index % 3) - 1; if(result == -1) { @@ -99,7 +96,7 @@ class SudokuGameboard { return result; } - ///Given a particular row/column index, 1 - 9, return the row/column index + ///Given a particular row/column index, 1 - 9, return the equivalent index of ///where it's contained within the game board. int getEquivalentBoardIndex(int index) { var result = ((index / 3) - 1).ceil(); diff --git a/lib/src/game/logic/GameManager.dart b/lib/src/game/logic/GameManager.dart index 92e1510..bd2c3f2 100644 --- a/lib/src/game/logic/GameManager.dart +++ b/lib/src/game/logic/GameManager.dart @@ -1,14 +1,16 @@ import 'package:collection/collection.dart'; -import 'package:sudoku/src/game/board/Pair.dart'; import 'package:sudoku/src/game/board/SudokuGameboard.dart'; ///The GameManager class handles the state of the Sudoku game. class GameManager { /// Gets the game board. SudokuGameboard get board => _board; - final _board = SudokuGameboard.generator(1); + final _board = SudokuGameboard(59); + /// Given a selection of 9 Integers that represents a Sudoku row, column, or + /// chunk, determine whether or not it's valid. The array must contain the + /// numbers 1 through 9 with no duplicates. bool validSelection(List selection) { if (selection.contains(null)) { return false; @@ -18,6 +20,7 @@ class GameManager { return ListEquality().equals(selection, expectedValue); } + /// Check whether or not the user has completed the Sudoku puzzle. bool checkForCompletion() { for(var a = 0; a < board.sudokuChunks.values.length; a++) { if(!validSelection(board.row(a).toList()) diff --git a/lib/src/game/logic/SudokuGenerator.dart b/lib/src/game/logic/SudokuGenerator.dart index 7162ec4..01d995a 100644 --- a/lib/src/game/logic/SudokuGenerator.dart +++ b/lib/src/game/logic/SudokuGenerator.dart @@ -23,8 +23,6 @@ class SudokuGenerator { _numbers[randRow][randCol] = null; numbersToRemove--; } - - print('numbers: $_numbers'); } /// The rotate method takes a row of Sudoku numbers and shifts them to be used diff --git a/lib/src/routes/route_paths.dart b/lib/src/routes/route_paths.dart index 8af5492..8d6664f 100644 --- a/lib/src/routes/route_paths.dart +++ b/lib/src/routes/route_paths.dart @@ -1,5 +1,6 @@ import 'package:angular_router/angular_router.dart'; +/// Initializes all route paths in the application. class RoutePaths { static final sudoku = RoutePath(path: 'sudoku'); } \ No newline at end of file diff --git a/lib/src/routes/routes.dart b/lib/src/routes/routes.dart index e385eae..ff1b859 100644 --- a/lib/src/routes/routes.dart +++ b/lib/src/routes/routes.dart @@ -1,7 +1,8 @@ import 'package:angular_router/angular_router.dart'; -import 'route_paths.dart'; import 'package:sudoku/src/components/sudoku_board_component.template.dart' as sudoku_board_template; +import 'route_paths.dart'; + class Routes { static final sudoku = RouteDefinition( routePath: RoutePaths.sudoku,