// What to do when a valid move has been made. protected void processValidMove(Move m) { edu.wpi.sudoku.model.SudokuBoard board = Model.getBoard(); m.execute(board); Model.addMove(m); if (board.isComplete()) { // boardSolved(); new UpdateController() .sendFinish( lobby, PlayerManager.get().getPlayerById(lobby.getContext().getUser()).getScore()); } // Have we completed a Cell? If so, make the locked sound. Otherwise // go and make a small sound. Cell c = Cell.enclosingCell(m.getSquare()); CellNormal cn = new CellNormal(c); boolean full = true; // assume we are done. for (edu.wpi.sudoku.model.Square s : cn) { if (board.isEmpty(s)) { full = false; break; } } if (full) { OneSoundPlayer.playSound(this.getClass().getResource("/sounds/operations/lockingSound.WAV")); } else { OneSoundPlayer.playSound(this.getClass().getResource("/sounds/operations/snapSound.WAV")); } }
public void requestNewGame(Levels d) { alert("Computing..."); // grab a new game // Model.updateModel (Configuration.getGenerator().generate(d)); Model.updateModel((new ExtractBoard()).generate(d)); sgm = new SudokuGameManager(Model.getBoard()); refreshView(); clearAlert(); }
/** * Load board as defined within Scanner. * * <p>This restarts existing game, if one has already started. * * @param scanner */ void loadBoard(Scanner scanner) { if (Model.loadBoard(scanner)) { refreshView(); } }
protected void initializeModel(Levels d) { // initialize model as well to be a random game. Model.initialize(); sgm = new SudokuGameManager(Model.getBoard()); requestNewGame(d); }