Skip to content

Commit

Permalink
change text upon winning
Browse files Browse the repository at this point in the history
  • Loading branch information
235857 authored and 235857 committed May 25, 2022
1 parent 811543c commit e2ead72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/java/tictactoe/arena/components/BigBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ public void updateLogic(int boardID, int won) {
int w = bigLogic.checkForWin();
if (w != 0) {
setPlayerWon(w);
GameInfo.showFinal();
}
}
//TODO: check if game is finished
public void setPlayerWon(int won) {
switch (won) {
case 1 -> {
System.out.println("-------- X WON WHOLE GAME --------");
GameInfo.showFinal("X Won");
GameInfo.stopTimer();
}
case 2 -> {
System.out.println("-------- O WON WHOLE GAME --------");
GameInfo.showFinal("O Won");
GameInfo.stopTimer();
}
case 3 -> {
System.out.println("-------- DRAW OMG WHAT A MATCH --------");
GameInfo.showFinal("Draw");
GameInfo.stopTimer();
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/tictactoe/arena/controllers/GameInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ public class GameInfo extends GridPane {
private char STARTING_PLAYER = 'x';

private static Label labelGameTime;
private static Label labelWhoseTurn;
private static ImageView oSymbol;
private static ImageView xSymbol;

public GameInfo(Scene scene) {
labelGameTime = (Label) scene.lookup("#labelGameTime");
oSymbol = (ImageView) scene.lookup("#oSymbol");
xSymbol = (ImageView) scene.lookup("#xSymbol");
labelWhoseTurn = (Label)scene.lookup("#moveLabel");
reset();
startTimer();
}
Expand Down Expand Up @@ -67,12 +69,12 @@ private void startTimer() {
timeline.play();
}

private void stopTimer() {
public static void stopTimer() {
timeline.stop();
}

public static void showFinal() {
//
public static void showFinal(String text) {
labelWhoseTurn.setText(text);
}

private String secondsToString(int pTime) {
Expand Down

0 comments on commit e2ead72

Please sign in to comment.