Method additions
parent
46d5f6ec4a
commit
e5ea5fb2ba
|
|
@ -1,33 +1,32 @@
|
|||
package GUI;
|
||||
|
||||
import domain.*;
|
||||
import GUI.HitoriDialogManager;
|
||||
import javafx.application.Platform;
|
||||
import java.util.*;
|
||||
|
||||
public class GameUIController {
|
||||
private final HitoriGameMoves gameMoves;
|
||||
private final GameSolver gameSolver;
|
||||
private final domain.HitoriGameTimer gameTimer;
|
||||
private final HitoriGameTimer gameTimer;
|
||||
private final HitoriGameScores gameScores;
|
||||
private final GUI.HitoriDialogManager dialogManager;
|
||||
private final GUI.HitoriBoardPanel boardPanel;
|
||||
private final GUI.HitoriControlPanel controlPanel;
|
||||
private final GUI.HitoriScorePanel scorePanel;
|
||||
private final HitoriDialogManager dialogManager;
|
||||
private final HitoriBoardPanel boardPanel;
|
||||
private final HitoriControlPanel controlPanel;
|
||||
private final HitoriScorePanel scorePanel;
|
||||
private Timer guiTimer;
|
||||
private boolean isPaused;
|
||||
|
||||
public GameUIController(int[][] initialBoard, HitoriDialogManager dialogManager) {
|
||||
this.gameMoves = new HitoriGameMoves(initialBoard);
|
||||
this.gameSolver = new GameSolver(initialBoard);
|
||||
this.gameTimer = new domain.HitoriGameTimer();
|
||||
this.gameTimer = new HitoriGameTimer();
|
||||
this.gameScores = new HitoriGameScores();
|
||||
this.dialogManager = dialogManager;
|
||||
this.isPaused = false;
|
||||
|
||||
this.boardPanel = new GUI.HitoriBoardPanel(gameMoves, gameSolver, this);
|
||||
this.controlPanel = new GUI.HitoriControlPanel(this);
|
||||
this.scorePanel = new GUI.HitoriScorePanel(this);
|
||||
this.boardPanel = new HitoriBoardPanel(gameMoves, gameSolver, this);
|
||||
this.controlPanel = new HitoriControlPanel(this);
|
||||
this.scorePanel = new HitoriScorePanel(this);
|
||||
|
||||
startTimer();
|
||||
loadHighScores();
|
||||
|
|
@ -36,15 +35,19 @@ public class GameUIController {
|
|||
public void handleLeftClick(int row, int col) {
|
||||
gameMoves.markCellAsBlack(row, col);
|
||||
updateUI();
|
||||
|
||||
|
||||
checkWin();
|
||||
}
|
||||
|
||||
public void handleRightClick(int row, int col) {
|
||||
gameMoves.markCellAsWhite(row, col);
|
||||
updateUI();
|
||||
checkWin();
|
||||
}
|
||||
|
||||
|
||||
private void checkWin() {
|
||||
if (gameSolver.isSolved()) {
|
||||
handleWin();
|
||||
}
|
||||
}
|
||||
|
||||
public void togglePause() {
|
||||
|
|
@ -81,7 +84,7 @@ public class GameUIController {
|
|||
|
||||
public void newGame() {
|
||||
stopTimer();
|
||||
// Notify main application to show board selection
|
||||
// Main application will handle board selection
|
||||
}
|
||||
|
||||
public void checkSolution() {
|
||||
|
|
@ -108,7 +111,8 @@ public class GameUIController {
|
|||
}
|
||||
|
||||
public void saveGame() {
|
||||
// Implementation for saving game state
|
||||
HitoriGameMain gameState = new HitoriGameMain(gameMoves.getBoard());
|
||||
gameState.saveGameState();
|
||||
dialogManager.showAlert("Game Saved", "Your game has been saved successfully.");
|
||||
}
|
||||
|
||||
|
|
@ -171,6 +175,7 @@ public class GameUIController {
|
|||
private void updateUI() {
|
||||
boardPanel.updateBoard();
|
||||
updateMistakeLabel();
|
||||
checkWin();
|
||||
}
|
||||
|
||||
private void updateTimerLabel() {
|
||||
|
|
@ -218,4 +223,4 @@ public class GameUIController {
|
|||
public HitoriScorePanel getScorePanel() {
|
||||
return scorePanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,5 +90,4 @@ public class HitoriBoardPanel extends GridPane {
|
|||
button.setStyle("-fx-background-color: lightgray; -fx-text-fill: black;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package GUI;
|
||||
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package GUI;
|
||||
|
||||
import GUI.GameUIController;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
package Main;
|
||||
|
||||
|
||||
import domain.HitoriGameMain;
|
||||
import domain.HitoriBoardLoader;
|
||||
import GUI.GameUIController;
|
||||
import GUI.HitoriDialogManager;
|
||||
import domain.HitoriBoardLoader;
|
||||
import domain.HitoriGameMain;
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
import GUI.GameUIController;
|
||||
|
||||
public class MainMethod extends Application {
|
||||
private HitoriBoardLoader boardLoader;
|
||||
|
|
@ -93,4 +92,4 @@ public class MainMethod extends Application {
|
|||
controller.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import org.junit.jupiter.api.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class HitoriGameBaseTest {
|
||||
class GameBaseTest {
|
||||
private domain.GameBase game;
|
||||
private static final int[][] TEST_BOARD = {
|
||||
{1, 2, 1, 3},
|
||||
|
|
|
|||
Loading…
Reference in New Issue