Skip to content

Commit

Permalink
Rename GamePlayerInfoPanelThread -> GamePlayerInfoPanelTimerThread
Browse files Browse the repository at this point in the history
This more accurately reflects what the thread does. It's only purpose is
to tick down the time remaining counter for strokes.
  • Loading branch information
StenAL committed Mar 27, 2024
1 parent 392c17d commit 64eef1a
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 144 deletions.
4 changes: 2 additions & 2 deletions client/src/main/java/agolf/game/GamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ protected void requestNewGame() {

protected void method342() {
this.gameCanvas.restartGame();
this.gamePlayerInfoPanel.stop();
this.gamePlayerInfoPanel.stopTimer();
this.gameContainer.gameApplet.setGameState(0);
this.gameContainer.connection.writeData("game\tback");
this.gameContainer.gameApplet.removePlayerList();
Expand Down Expand Up @@ -511,7 +511,7 @@ protected boolean canStroke(boolean stopInfoPanel) {
}

if (stopInfoPanel) {// ???????????????????????????????????
this.gamePlayerInfoPanel.stop();
this.gamePlayerInfoPanel.stopTimer();
} else {
this.gameCanvas.stop();
}
Expand Down
18 changes: 9 additions & 9 deletions client/src/main/java/agolf/game/GamePlayerInfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GamePlayerInfoPanel extends Panel implements ItemListener, MouseListener {
private Choicer aChoicer399;
private Image image;
private Graphics graphics;
private GamePlayerInfoPanelThread panelThread;
private GamePlayerInfoPanelTimerThread timerThread;
private int currentTimeForShot;


Expand Down Expand Up @@ -182,7 +182,7 @@ public void update(Graphics g) {
if (this.playerCount > 1 && this.playerID == player) {
if (this.playerID == this.currentPlayerId) {
playerInfo = "GamePlayerInfo_OwnTurn";
if (this.panelThread != null && this.currentTimeForShot > 0 && (this.strokeTimeout > 0 || this.strokeTimeout == 0 && this.currentTimeForShot <= 30)) {
if (this.timerThread != null && this.currentTimeForShot > 0 && (this.strokeTimeout > 0 || this.strokeTimeout == 0 && this.currentTimeForShot <= 30)) {
var11 = " (" + this.gameContainer.textManager.getTime((long) this.currentTimeForShot) + ")";
}
} else {
Expand Down Expand Up @@ -380,9 +380,9 @@ protected boolean canShoot(int playerNumber) {
int timeout = this.strokeTimeout > 0 ? this.strokeTimeout : 180;

if (this.playerCount > 1 && playerNumber == this.currentPlayerId && timeout > 0) {
this.stop();
this.stopTimer();
this.currentTimeForShot = timeout;
this.panelThread = new GamePlayerInfoPanelThread(this);
this.timerThread = new GamePlayerInfoPanelTimerThread(this);
}

this.repaint();
Expand Down Expand Up @@ -520,10 +520,10 @@ protected int method377() {
return this.playerCount > 1 ? -1 : this.trackStrokes[0][this.anInt386].get();
}

protected void stop() {
if (this.panelThread != null) {
this.panelThread.stopRunning();
this.panelThread = null;
protected void stopTimer() {
if (this.timerThread != null) {
this.timerThread.stopRunning();
this.timerThread = null;
}

}
Expand Down Expand Up @@ -570,7 +570,7 @@ protected boolean run() {
this.repaint();
if (this.currentTimeForShot <= 0) {
this.gameContainer.gamePanel.canStroke(false);
this.panelThread = null;
this.stopTimer();
return false;
} else {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import com.aapeli.tools.Tools;

class GamePlayerInfoPanelThread implements Runnable {
class GamePlayerInfoPanelTimerThread implements Runnable {

private final GamePlayerInfoPanel gamePlayerInfoPanel;
private boolean running;


protected GamePlayerInfoPanelThread(GamePlayerInfoPanel var1) {
this.gamePlayerInfoPanel = var1;
protected GamePlayerInfoPanelTimerThread(GamePlayerInfoPanel gamePlayerInfoPanel) {
this.gamePlayerInfoPanel = gamePlayerInfoPanel;
this.running = true;
Thread var2 = new Thread(this);
var2.setDaemon(true);
var2.start();
Thread thread = new Thread(this);
thread.setDaemon(true);
thread.start();
}

public void run() {
Expand Down
Loading

0 comments on commit 64eef1a

Please sign in to comment.