2024-11-16 00:29:43 +01:00
|
|
|
package fr.monkhanny.dorfromantik.controller;
|
|
|
|
|
|
|
|
import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel;
|
2024-11-16 13:49:24 +01:00
|
|
|
import fr.monkhanny.dorfromantik.game.Board;
|
|
|
|
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
|
|
|
|
2024-11-16 00:29:43 +01:00
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
2024-11-16 13:49:24 +01:00
|
|
|
import javax.swing.JFrame;
|
2024-11-16 00:29:43 +01:00
|
|
|
|
|
|
|
public class GameModeController implements ActionListener {
|
|
|
|
|
|
|
|
private GameModeSelectionPanel gameModeSelectionPanel;
|
2024-11-16 13:49:24 +01:00
|
|
|
private JFrame gameFrame;
|
|
|
|
private MainMenu mainMenu;
|
2024-11-16 00:29:43 +01:00
|
|
|
|
|
|
|
// Constructeur sans le panneau
|
2024-11-16 13:49:24 +01:00
|
|
|
public GameModeController(JFrame gameFrame, MainMenu mainMenu) {
|
|
|
|
this.gameFrame = gameFrame;
|
|
|
|
this.mainMenu = mainMenu;
|
2024-11-16 00:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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":
|
2024-11-16 13:49:24 +01:00
|
|
|
startGame("Mode 1", 123456789L);
|
2024-11-16 00:29:43 +01:00
|
|
|
break;
|
|
|
|
case "Mode 2":
|
2024-11-16 13:49:24 +01:00
|
|
|
startGame("Mode 2", 987654321L);
|
2024-11-16 00:29:43 +01:00
|
|
|
break;
|
|
|
|
case "Mode 3":
|
2024-11-16 13:49:24 +01:00
|
|
|
startGame("Mode 3", 678912345L);
|
2024-11-16 00:29:43 +01:00
|
|
|
break;
|
|
|
|
case "Mode 4":
|
2024-11-16 13:49:24 +01:00
|
|
|
startGame("Mode 4", 103072005L);
|
2024-11-16 00:29:43 +01:00
|
|
|
break;
|
|
|
|
case "Démarrer":
|
2024-11-16 13:49:24 +01:00
|
|
|
long seed = gameModeSelectionPanel.getLongSeed();
|
|
|
|
startGame("Custom Mode", seed);
|
2024-11-16 00:29:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
System.out.println("Commande inconnue: " + command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-16 13:49:24 +01:00
|
|
|
private void startGame(String mode, long seed) {
|
|
|
|
Board board = new Board(this.gameFrame,seed);
|
|
|
|
this.gameFrame.setVisible(true);
|
|
|
|
this.gameFrame.add(board);
|
2024-11-16 00:29:43 +01:00
|
|
|
}
|
|
|
|
}
|