Modifications + ajout du choix des modes (vues)

This commit is contained in:
2024-11-16 00:29:43 +01:00
parent f393c45714
commit 5950dc724a
5 changed files with 197 additions and 3 deletions

View File

@@ -0,0 +1,57 @@
package fr.monkhanny.dorfromantik.controller;
import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GameModeController implements ActionListener {
private GameModeSelectionPanel gameModeSelectionPanel;
// Constructeur sans le panneau
public GameModeController() {
// Initialisation sans le panneau
}
// Méthode pour associer le panneau
public void setGameModeSelectionPanel(GameModeSelectionPanel panel) {
this.gameModeSelectionPanel = panel;
}
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
switch (command) {
case "Mode 1":
startGame("Mode 1", null);
break;
case "Mode 2":
startGame("Mode 2", null);
break;
case "Mode 3":
startGame("Mode 3", null);
break;
case "Mode 4":
startGame("Mode 4", null);
break;
case "Démarrer":
String seed = gameModeSelectionPanel.getSeed();
if (!seed.isEmpty()) {
startGame("Custom Mode", seed);
}
break;
default:
System.out.println("Commande inconnue: " + command);
}
}
private void startGame(String mode, String seed) {
System.out.println("Démarrer le jeu en mode: " + mode);
if (seed != null) {
System.out.println("Seed personnalisée: " + seed);
}
// Implémenter la logique pour démarrer le jeu avec le mode sélectionné et la seed si applicable
}
}