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

83 lines
2.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package fr.iut_fbleau.Avalam;
import javax.swing.*;
/**
* Point dentré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(() -> {
showModeSelection();
});
}
/**
* Affiche le menu de sélection du mode de jeu.
* Peut être appelé depuis d'autres fenêtres pour revenir au menu.
*/
public static void showModeSelection() {
String[] options = {
"joueur vs joueur",
"joueur vs botidiot",
"joueur vs bot alpha",
"joueur vs bot divin (NON IMPLEMENTE)",
"Arène"
};
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);
// Mode Arène
if (choice == 4) {
new ArenaWindow();
return;
}
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);
}
}