Files
BUT3ProjetJeuGroupe/fr/iut_fbleau/Avalam/Main.java

70 lines
2.1 KiB
Java
Raw Normal View History

2025-11-20 13:25:09 -05:00
package fr.iut_fbleau.Avalam;
2026-01-26 13:41:48 +01:00
import javax.swing.*;
/**
2026-01-26 13:41:48 +01:00
* Point dentrée : propose un menu de sélection de mode, puis lance la fenêtre Avalam.
*/
2025-11-20 13:25:09 -05:00
public class Main {
2026-01-26 13:41:48 +01:00
public static void main(String[] args) {
2026-01-26 13:41:48 +01:00
SwingUtilities.invokeLater(() -> {
2026-01-26 13:41:48 +01:00
String[] options = {
"joueur vs joueur",
"joueur vs botidiot",
"joueur vs bot alpha",
"joueur vs bot divin (NON IMPLEMENTE)"
2026-01-26 13:41:48 +01:00
};
2026-01-26 13:41:48 +01:00
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);
2026-01-26 13:41:48 +01:00
GameMode mode;
if (choice == 1) mode = GameMode.PVBOT;
else if (choice == 2) mode = GameMode.PVALPHA;
else if (choice == 3) mode = GameMode.PVGOD;
2026-01-26 13:41:48 +01:00
else mode = GameMode.PVP;
// Pour ALPHA et GOD : demander une profondeur
if (mode == GameMode.PVALPHA || mode == GameMode.PVGOD) {
String s = JOptionPane.showInputDialog(
2026-01-26 13:41:48 +01:00
null,
"Profondeur de recherche ?\n(Conseil 4)",
(mode == GameMode.PVGOD ? "Bot Divin (PVGOD)" : "Bot Alpha-Beta"),
JOptionPane.QUESTION_MESSAGE
2026-01-26 13:41:48 +01:00
);
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;
2026-01-26 13:41:48 +01:00
}
new AvalamWindow(mode);
});
2025-11-20 13:25:09 -05:00
}
}