ajout du mode Arene où on choisi les bot qui s'affronte et le nombre de partie
This commit is contained in:
@@ -8,62 +8,75 @@ import javax.swing.*;
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
showModeSelection();
|
||||
});
|
||||
}
|
||||
|
||||
String[] options = {
|
||||
"joueur vs joueur",
|
||||
"joueur vs botidiot",
|
||||
"joueur vs bot alpha",
|
||||
"joueur vs bot divin (NON IMPLEMENTE)"
|
||||
};
|
||||
/**
|
||||
* 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(
|
||||
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,
|
||||
"Choisissez un mode de jeu :",
|
||||
"Avalam - Mode de jeu",
|
||||
JOptionPane.DEFAULT_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]
|
||||
"Profondeur de recherche ?\n(Conseil 4)",
|
||||
(mode == GameMode.PVGOD ? "Bot Divin (PVGOD)" : "Bot Alpha-Beta"),
|
||||
JOptionPane.QUESTION_MESSAGE
|
||||
);
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
new AvalamWindow(mode);
|
||||
});
|
||||
if (depth < 1) depth = 1;
|
||||
|
||||
new AvalamWindow(mode, depth);
|
||||
return;
|
||||
}
|
||||
|
||||
new AvalamWindow(mode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user