70 lines
2.1 KiB
Java
70 lines
2.1 KiB
Java
package fr.iut_fbleau.Avalam;
|
||
|
||
import javax.swing.*;
|
||
|
||
/**
|
||
* Point d’entrée : propose un menu de sélection de mode, puis lance la fenêtre Avalam.
|
||
*/
|
||
public class Main {
|
||
|
||
public static void main(String[] args) {
|
||
|
||
SwingUtilities.invokeLater(() -> {
|
||
|
||
String[] options = {
|
||
"joueur vs joueur",
|
||
"joueur vs botidiot",
|
||
"joueur vs bot alpha",
|
||
"joueur vs bot divin (NON IMPLEMENTE)"
|
||
};
|
||
|
||
int choice = JOptionPane.showOptionDialog(
|
||
null,
|
||
"Choisissez un mode de jeu :",
|
||
"Avalam - Mode de jeu",
|
||
JOptionPane.DEFAULT_OPTION,
|
||
JOptionPane.QUESTION_MESSAGE,
|
||
null,
|
||
options,
|
||
options[0]
|
||
);
|
||
|
||
if (choice == -1) System.exit(0);
|
||
|
||
GameMode mode;
|
||
if (choice == 1) mode = GameMode.PVBOT;
|
||
else if (choice == 2) mode = GameMode.PVALPHA;
|
||
else if (choice == 3) mode = GameMode.PVGOD;
|
||
else mode = GameMode.PVP;
|
||
|
||
// Pour ALPHA et GOD : demander une profondeur
|
||
if (mode == GameMode.PVALPHA || mode == GameMode.PVGOD) {
|
||
|
||
String s = JOptionPane.showInputDialog(
|
||
null,
|
||
"Profondeur de recherche ?\n(Conseil 4)",
|
||
(mode == GameMode.PVGOD ? "Bot Divin (PVGOD)" : "Bot Alpha-Beta"),
|
||
JOptionPane.QUESTION_MESSAGE
|
||
);
|
||
|
||
int depth = 4; // défaut
|
||
if (s != null) {
|
||
try { depth = Integer.parseInt(s.trim()); }
|
||
catch (Exception ignored) { depth = 4; }
|
||
} else {
|
||
// Annulation : on revient en PVP
|
||
new AvalamWindow(GameMode.PVP);
|
||
return;
|
||
}
|
||
|
||
if (depth < 1) depth = 1;
|
||
|
||
new AvalamWindow(mode, depth);
|
||
return;
|
||
}
|
||
|
||
new AvalamWindow(mode);
|
||
});
|
||
}
|
||
}
|