From 7ec9b00a4474b0e70251412f2df66c2513f70525 Mon Sep 17 00:00:00 2001 From: Romain Murphy Date: Fri, 9 May 2025 14:59:19 +0200 Subject: [PATCH] timer reset --- OOP_2B1_Project/src/windowInterface/MyInterface.java | 4 ++-- OOP_2B1_Project/src/windowInterface/TimerManager.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OOP_2B1_Project/src/windowInterface/MyInterface.java b/OOP_2B1_Project/src/windowInterface/MyInterface.java index f7185c0..0ffcd00 100644 --- a/OOP_2B1_Project/src/windowInterface/MyInterface.java +++ b/OOP_2B1_Project/src/windowInterface/MyInterface.java @@ -180,7 +180,7 @@ public class MyInterface extends JFrame { game.setDefaultSetup(); if (timerManager == null) timerManager = new TimerManager(whiteTimerLabel, blackTimerLabel, () -> gameOverByTimeout(), time); - timerManager.reset(); + timerManager.reset(time); timerManager.start(true); // white starts } public void clickButtonAdder() { @@ -236,7 +236,7 @@ public class MyInterface extends JFrame { game.setAutoPlayerDepth(depth); if (timerManager == null) timerManager = new TimerManager(whiteTimerLabel, blackTimerLabel, () -> gameOverByTimeout(), time); - timerManager.reset(); + timerManager.reset(time); timerManager.start(game.getTurnColor()); game.start(); // this.repaint(); diff --git a/OOP_2B1_Project/src/windowInterface/TimerManager.java b/OOP_2B1_Project/src/windowInterface/TimerManager.java index bd2cab6..de66404 100644 --- a/OOP_2B1_Project/src/windowInterface/TimerManager.java +++ b/OOP_2B1_Project/src/windowInterface/TimerManager.java @@ -60,7 +60,9 @@ public class TimerManager { timer.stop(); } -public void reset() { +public void reset(int time) { + whiteSeconds = time; + blackSeconds = time; updateLabel(whiteLabel, whiteSeconds); updateLabel(blackLabel, blackSeconds); }