Merge branch 'main' of
https://gitarero.ecam.fr/romain.murphy/OOP_2B1_Project.git into main
This commit is contained in:
commit
6bb57c1eb8
|
|
@ -40,7 +40,7 @@ public class JPanelChessBoard extends JPanel {
|
||||||
pieceSelectorMode = false;
|
pieceSelectorMode = false;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
spriteSheet = ImageIO.read(new File("newPieces.png"));
|
spriteSheet = ImageIO.read(new File("pieces/newPieces.png"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
package windowInterface;
|
package windowInterface;
|
||||||
import backend.SoundEffect;
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
|
@ -35,6 +35,7 @@ import javax.swing.JCheckBox;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
|
||||||
public class MyInterface extends JFrame {
|
public class MyInterface extends JFrame {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6840815447618468846L;
|
private static final long serialVersionUID = -6840815447618468846L;
|
||||||
|
|
@ -47,8 +48,9 @@ public class MyInterface extends JFrame {
|
||||||
private JLabel actionLabel;
|
private JLabel actionLabel;
|
||||||
private JCheckBox chckbxBlackAI;
|
private JCheckBox chckbxBlackAI;
|
||||||
private JCheckBox chckbxWhiteAI;
|
private JCheckBox chckbxWhiteAI;
|
||||||
private SoundEffect soundEffect = new SoundEffect();
|
private JLabel whiteTimerLabel;
|
||||||
|
private JLabel blackTimerLabel;
|
||||||
|
public TimerManager timerManager;
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
|
|
@ -142,6 +144,11 @@ public class MyInterface extends JFrame {
|
||||||
|
|
||||||
panelDraw = new JPanelChessBoard(this);
|
panelDraw = new JPanelChessBoard(this);
|
||||||
contentPane.add(panelDraw, BorderLayout.CENTER);
|
contentPane.add(panelDraw, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
whiteTimerLabel = new JLabel("White: X");
|
||||||
|
blackTimerLabel = new JLabel("Black: X");
|
||||||
|
panelTop.add(whiteTimerLabel);
|
||||||
|
panelTop.add(blackTimerLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStepBanner(String s) {
|
public void setStepBanner(String s) {
|
||||||
|
|
@ -169,9 +176,13 @@ public class MyInterface extends JFrame {
|
||||||
this.instantiateSimu();
|
this.instantiateSimu();
|
||||||
int introduction = introduction();
|
int introduction = introduction();
|
||||||
int depth = askDifficulty();
|
int depth = askDifficulty();
|
||||||
int time=askTime();
|
int time = askTime();
|
||||||
game.setAutoPlayerDepth(depth);
|
game.setAutoPlayerDepth(depth);
|
||||||
game.setDefaultSetup();
|
game.setDefaultSetup();
|
||||||
|
if (timerManager == null)
|
||||||
|
timerManager = new TimerManager(whiteTimerLabel, blackTimerLabel, () -> gameOverByTimeout(), time);
|
||||||
|
timerManager.reset();
|
||||||
|
timerManager.start(true); // white starts
|
||||||
}
|
}
|
||||||
public void clickButtonAdder() {
|
public void clickButtonAdder() {
|
||||||
panelDraw.toggleAdderMode();
|
panelDraw.toggleAdderMode();
|
||||||
|
|
@ -199,7 +210,6 @@ public class MyInterface extends JFrame {
|
||||||
} else {
|
} else {
|
||||||
game.toggleAI(isWhite);
|
game.toggleAI(isWhite);
|
||||||
}
|
}
|
||||||
soundEffect.aiSound();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clicLoadFileButton() {
|
public void clicLoadFileButton() {
|
||||||
|
|
@ -223,7 +233,12 @@ public class MyInterface extends JFrame {
|
||||||
|
|
||||||
panelDraw.setGame(game);
|
panelDraw.setGame(game);
|
||||||
int depth = askDifficulty();
|
int depth = askDifficulty();
|
||||||
|
int time = askTime();
|
||||||
game.setAutoPlayerDepth(depth);
|
game.setAutoPlayerDepth(depth);
|
||||||
|
if (timerManager == null)
|
||||||
|
timerManager = new TimerManager(whiteTimerLabel, blackTimerLabel, () -> gameOverByTimeout(), time);
|
||||||
|
timerManager.reset();
|
||||||
|
timerManager.start(game.getTurnColor());
|
||||||
game.start();
|
game.start();
|
||||||
// this.repaint();
|
// this.repaint();
|
||||||
// update(game.getTurnNumber(), game.getTurnColor());
|
// update(game.getTurnNumber(), game.getTurnColor());
|
||||||
|
|
@ -323,11 +338,11 @@ public class MyInterface extends JFrame {
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 0: return 1; // 1 min
|
case 0: return 60; // 1 min
|
||||||
case 1: return 2; // 2 min
|
case 1: return 120; // 2 min
|
||||||
case 2: return 3; // 5 min
|
case 2: return 300; // 5 min
|
||||||
case 3: return 4;// 10 min
|
case 3: return 600;// 10 min
|
||||||
default: return 4; // 10 min
|
default: return 600; // 10 min
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private int introduction() {
|
private int introduction() {
|
||||||
|
|
@ -363,4 +378,10 @@ public class MyInterface extends JFrame {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void gameOverByTimeout() {
|
||||||
|
// disable board input, show message
|
||||||
|
// JOptionPane.showMessageDialog(this, "Time's up! The game is over.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue