Modifications de la V1
This commit is contained in:
@@ -4,7 +4,7 @@ SOURCEDIR = ./src/fr/monkhanny/dorfromantik/
|
|||||||
BUILDDIR = ./build/
|
BUILDDIR = ./build/
|
||||||
DOCDIR = ./doc/
|
DOCDIR = ./doc/
|
||||||
JARNAME = dorfromantik.jar
|
JARNAME = dorfromantik.jar
|
||||||
CLASSP = libs/*
|
CLASSP = ./libs/*:$(BUILDDIR)
|
||||||
MANIFESTPATH = Manifest.MF
|
MANIFESTPATH = Manifest.MF
|
||||||
SOURCEDIR = ./src/
|
SOURCEDIR = ./src/
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ compile:
|
|||||||
|
|
||||||
run:
|
run:
|
||||||
@echo "Running..."
|
@echo "Running..."
|
||||||
@java -jar $(JARNAME)
|
@java -cp $(CLASSP):$(JARNAME) fr.monkhanny.dorfromantik.Main
|
||||||
@echo "Done."
|
@echo "Done."
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
BIN
TestV1/ressources/images/Tutorial/Gif1.gif
Normal file
BIN
TestV1/ressources/images/Tutorial/Gif1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
BIN
TestV1/ressources/images/Tutorial/Gif2.gif
Normal file
BIN
TestV1/ressources/images/Tutorial/Gif2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 MiB |
BIN
TestV1/ressources/images/Tutorial/Gif3.gif
Normal file
BIN
TestV1/ressources/images/Tutorial/Gif3.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 888 KiB |
BIN
TestV1/ressources/images/Tutorial/Gif4.gif
Normal file
BIN
TestV1/ressources/images/Tutorial/Gif4.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
@@ -7,6 +7,8 @@ import fr.monkhanny.dorfromantik.utils.MusicPlayer;
|
|||||||
import fr.monkhanny.dorfromantik.enums.Musics;
|
import fr.monkhanny.dorfromantik.enums.Musics;
|
||||||
import fr.monkhanny.dorfromantik.listeners.SettingsWindowListener;
|
import fr.monkhanny.dorfromantik.listeners.SettingsWindowListener;
|
||||||
import fr.monkhanny.dorfromantik.gui.SettingsPanel;
|
import fr.monkhanny.dorfromantik.gui.SettingsPanel;
|
||||||
|
import fr.monkhanny.dorfromantik.controller.TutorialController;
|
||||||
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
@@ -26,12 +28,15 @@ public class Main {
|
|||||||
// Créer la fenêtre des paramètres
|
// Créer la fenêtre des paramètres
|
||||||
JFrame settingsFrame = new JFrame("Paramètres");
|
JFrame settingsFrame = new JFrame("Paramètres");
|
||||||
|
|
||||||
|
// Créer la fenêtre du tutoriel
|
||||||
|
JFrame howToPlayFrame = new JFrame("Comment jouer ?");
|
||||||
|
|
||||||
// Menu principal
|
// Menu principal
|
||||||
MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC);
|
MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC);
|
||||||
MusicPlayer.playMusic();
|
MusicPlayer.playMusic();
|
||||||
MainMenu mainMenu = new MainMenu();
|
MainMenu mainMenu = new MainMenu();
|
||||||
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
||||||
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame);
|
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame);
|
||||||
|
|
||||||
|
|
||||||
// Fenêtre des paramètres
|
// Fenêtre des paramètres
|
||||||
@@ -41,5 +46,11 @@ public class Main {
|
|||||||
settingsFrame.add(settingsPanel);
|
settingsFrame.add(settingsPanel);
|
||||||
settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
// Fenêtre du tutoriel
|
||||||
|
TutorialController tutorialController = new TutorialController();
|
||||||
|
howToPlayFrame.addWindowListener(windowListener);
|
||||||
|
howToPlayFrame.add(tutorialController.getTutorialPanel());
|
||||||
|
howToPlayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,9 @@ public class MainMenuButtonController implements ActionListener {
|
|||||||
private MainMenu mainMenu;
|
private MainMenu mainMenu;
|
||||||
|
|
||||||
private JFrame settingsFrame;
|
private JFrame settingsFrame;
|
||||||
|
private JFrame howToPlayFrame;
|
||||||
|
|
||||||
public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame) {
|
public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame, JFrame howToPlayFrame) {
|
||||||
this.mainMenu = mainMenu;
|
this.mainMenu = mainMenu;
|
||||||
// Ajouter les écouteurs d'événements sur les boutons
|
// Ajouter les écouteurs d'événements sur les boutons
|
||||||
ButtonPanel buttonPanel = mainMenu.getButtonPanel();
|
ButtonPanel buttonPanel = mainMenu.getButtonPanel();
|
||||||
@@ -34,6 +35,11 @@ public class MainMenuButtonController implements ActionListener {
|
|||||||
this.settingsFrame = settingsFrame;
|
this.settingsFrame = settingsFrame;
|
||||||
this.settingsFrame.setLocationRelativeTo(null);
|
this.settingsFrame.setLocationRelativeTo(null);
|
||||||
this.settingsFrame.setVisible(false);
|
this.settingsFrame.setVisible(false);
|
||||||
|
|
||||||
|
// Créer la fenêtre du tutoriel
|
||||||
|
this.howToPlayFrame = howToPlayFrame;
|
||||||
|
this.howToPlayFrame.setLocationRelativeTo(null);
|
||||||
|
this.howToPlayFrame.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,11 +78,23 @@ public class MainMenuButtonController implements ActionListener {
|
|||||||
// Logic to continue the game
|
// Logic to continue the game
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showHowToPlay() {
|
public void showHowToPlay() {
|
||||||
System.out.println("Afficher comment jouer...");
|
// Récupérer la taille et la position de la fenêtre du menu principal
|
||||||
// Logic to show how to play
|
Dimension mainMenuSize = this.mainMenu.getSize();
|
||||||
|
Point mainMenuLocation = this.mainMenu.getLocation();
|
||||||
|
|
||||||
|
// Ajuster la fenêtre des paramètres pour qu'elle ait la même taille et position
|
||||||
|
this.howToPlayFrame.setSize(mainMenuSize);
|
||||||
|
this.howToPlayFrame.setLocation(mainMenuLocation);
|
||||||
|
|
||||||
|
// Cacher la fenêtre du menu principal
|
||||||
|
this.mainMenu.setVisible(false);
|
||||||
|
|
||||||
|
// Afficher la fenêtre des paramètres
|
||||||
|
this.howToPlayFrame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void exitGame() {
|
private void exitGame() {
|
||||||
System.exit(0); // Fermer l'application
|
System.exit(0); // Fermer l'application
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.controller;
|
||||||
|
|
||||||
|
import fr.monkhanny.dorfromantik.gui.TutorialPanel;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.Step;
|
||||||
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TutorialController {
|
||||||
|
private TutorialPanel tutorialPanel;
|
||||||
|
|
||||||
|
public TutorialController() {
|
||||||
|
List<Step> steps = new ArrayList<>();
|
||||||
|
steps.add(new Step("Étape n°1", "Explication de la première étape ici.", Images.TUTORIAL_GIF1.getImagePath()));
|
||||||
|
steps.add(new Step("Étape n°2", "Explication de la deuxième étape ici.", Images.TUTORIAL_GIF2.getImagePath()));
|
||||||
|
steps.add(new Step("Étape n°3", "Explication de la troisième étape ici.", Images.TUTORIAL_GIF3.getImagePath()));
|
||||||
|
steps.add(new Step("Étape n°4", "Explication de la quatrième étape ici.", Images.TUTORIAL_GIF4.getImagePath()));
|
||||||
|
|
||||||
|
tutorialPanel = new TutorialPanel(steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getTutorialPanel() {
|
||||||
|
return tutorialPanel;
|
||||||
|
}
|
||||||
|
}
|
24
TestV1/src/fr/monkhanny/dorfromantik/enums/Biome.java
Normal file
24
TestV1/src/fr/monkhanny/dorfromantik/enums/Biome.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.enums;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
|
public enum Biome {
|
||||||
|
SEA, FIELD, PRE, FOREST, MOUNTAIN;
|
||||||
|
|
||||||
|
public Color[] getBiomeColors() {
|
||||||
|
switch (this) {
|
||||||
|
case SEA:
|
||||||
|
return new Color[] { new Color(25, 133, 208), new Color(53, 159, 235), new Color(0, 103, 178) };
|
||||||
|
case FIELD:
|
||||||
|
return new Color[] { new Color(232, 214, 28), new Color(247, 228, 28), new Color(210, 195, 0) };
|
||||||
|
case PRE:
|
||||||
|
return new Color[] { new Color(110, 190, 110), new Color(130, 210, 130), new Color(90, 170, 90) };
|
||||||
|
case FOREST:
|
||||||
|
return new Color[] { new Color(15, 110, 65), new Color(35, 130, 85), new Color(0, 90, 45) };
|
||||||
|
case MOUNTAIN:
|
||||||
|
return new Color[] { new Color(110, 110, 110), new Color(130, 130, 130), new Color(90, 90, 90) };
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown Biome : " + this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,7 @@ package fr.monkhanny.dorfromantik.enums;
|
|||||||
|
|
||||||
|
|
||||||
public enum Images {
|
public enum Images {
|
||||||
SETTINGS_ICON, EXIT_ICON;
|
SETTINGS_ICON, EXIT_ICON, TUTORIAL_GIF1, TUTORIAL_GIF2, TUTORIAL_GIF3, TUTORIAL_GIF4;
|
||||||
|
|
||||||
public String getImagePath() {
|
public String getImagePath() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
@@ -10,6 +10,14 @@ public enum Images {
|
|||||||
return "./ressources/images/Icone/SettingsIcon.png";
|
return "./ressources/images/Icone/SettingsIcon.png";
|
||||||
case EXIT_ICON:
|
case EXIT_ICON:
|
||||||
return "./ressources/images/Icone/ExitIcon.png";
|
return "./ressources/images/Icone/ExitIcon.png";
|
||||||
|
case TUTORIAL_GIF1:
|
||||||
|
return "./ressources/images/Tutorial/Gif1.gif";
|
||||||
|
case TUTORIAL_GIF2:
|
||||||
|
return "./ressources/images/Tutorial/Gif2.gif";
|
||||||
|
case TUTORIAL_GIF3:
|
||||||
|
return "./ressources/images/Tutorial/Gif3.gif";
|
||||||
|
case TUTORIAL_GIF4:
|
||||||
|
return "./ressources/images/Tutorial/Gif4.gif";
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unexpected value: " + this);
|
throw new IllegalArgumentException("Unexpected value: " + this);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.enums;
|
||||||
|
|
||||||
|
|
||||||
|
public enum TileOrientation {
|
||||||
|
NORTH, NORTH_EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, NORTH_WEST;
|
||||||
|
|
||||||
|
|
||||||
|
public TileOrientation oppositeOrientation() {
|
||||||
|
switch (this) {
|
||||||
|
case NORTH:
|
||||||
|
return SOUTH;
|
||||||
|
case NORTH_EAST:
|
||||||
|
return SOUTH_WEST;
|
||||||
|
case SOUTH_EAST:
|
||||||
|
return NORTH_WEST;
|
||||||
|
case SOUTH:
|
||||||
|
return NORTH;
|
||||||
|
case SOUTH_WEST:
|
||||||
|
return NORTH_EAST;
|
||||||
|
case NORTH_WEST:
|
||||||
|
return SOUTH_EAST;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown TileOrientation: " + this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
TestV1/src/fr/monkhanny/dorfromantik/gui/Step.java
Normal file
25
TestV1/src/fr/monkhanny/dorfromantik/gui/Step.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.gui;
|
||||||
|
|
||||||
|
public class Step {
|
||||||
|
private String title;
|
||||||
|
private String text;
|
||||||
|
private String imagePath;
|
||||||
|
|
||||||
|
public Step(String title, String text, String imagePath) {
|
||||||
|
this.title = title;
|
||||||
|
this.text = text;
|
||||||
|
this.imagePath = imagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImagePath() {
|
||||||
|
return imagePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
120
TestV1/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java
Normal file
120
TestV1/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.gui;
|
||||||
|
|
||||||
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.Step;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TutorialPanel extends JPanel {
|
||||||
|
|
||||||
|
private List<Step> steps;
|
||||||
|
private int currentStepIndex;
|
||||||
|
|
||||||
|
private Title title;
|
||||||
|
private JLabel stepText;
|
||||||
|
private JLabel stepImage;
|
||||||
|
private JButton nextButton;
|
||||||
|
private JButton prevButton;
|
||||||
|
|
||||||
|
public TutorialPanel(List<Step> steps) {
|
||||||
|
this.steps = steps;
|
||||||
|
this.currentStepIndex = 0;
|
||||||
|
|
||||||
|
// Utiliser BorderLayout pour la disposition principale
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
// Création du titre centré en haut
|
||||||
|
title = new Title("Comment jouer ?", 70f, Color.WHITE);
|
||||||
|
title.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
title.setOpaque(false);
|
||||||
|
add(title, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// Conteneur principal pour les étapes, centré
|
||||||
|
JPanel centerPanel = new JPanel();
|
||||||
|
centerPanel.setLayout(new GridBagLayout());
|
||||||
|
centerPanel.setOpaque(false); // Rendre le conteneur transparent
|
||||||
|
|
||||||
|
// Utiliser GridBagConstraints pour centrer le contenu verticalement
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.insets = new Insets(10, 0, 10, 0);
|
||||||
|
|
||||||
|
// Conteneur pour le texte et l'image
|
||||||
|
JPanel stepContainer = new JPanel();
|
||||||
|
stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS));
|
||||||
|
stepContainer.setOpaque(false); // Transparent
|
||||||
|
|
||||||
|
stepText = new JLabel();
|
||||||
|
stepText.setFont(new Font("Arial", Font.BOLD, 28));
|
||||||
|
stepText.setForeground(Color.WHITE);
|
||||||
|
stepText.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer le texte horizontalement
|
||||||
|
|
||||||
|
stepImage = new JLabel();
|
||||||
|
stepImage.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer l'image horizontalement
|
||||||
|
|
||||||
|
// Ajouter les composants au conteneur d'étapes
|
||||||
|
stepContainer.add(stepText);
|
||||||
|
stepContainer.add(Box.createVerticalStrut(10)); // Espace entre texte et image
|
||||||
|
stepContainer.add(stepImage);
|
||||||
|
|
||||||
|
// Ajouter le conteneur d'étapes au centre du panel
|
||||||
|
centerPanel.add(stepContainer, gbc);
|
||||||
|
add(centerPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// Panneau pour les boutons de navigation
|
||||||
|
JPanel buttonPanel = new JPanel();
|
||||||
|
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centrer les boutons
|
||||||
|
buttonPanel.setOpaque(false); // Transparent
|
||||||
|
|
||||||
|
prevButton = new JButton("Précédent");
|
||||||
|
nextButton = new JButton("Suivant");
|
||||||
|
prevButton.addActionListener(e -> showPreviousStep());
|
||||||
|
nextButton.addActionListener(e -> showNextStep());
|
||||||
|
buttonPanel.add(prevButton);
|
||||||
|
buttonPanel.add(nextButton);
|
||||||
|
|
||||||
|
// Ajouter le panneau des boutons en bas
|
||||||
|
add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
// Affichage initial de l'étape
|
||||||
|
updateStepDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g); // Appel à super pour s'assurer que le panneau est dessiné
|
||||||
|
|
||||||
|
// Dessin de l'image de fond pour couvrir tout le panneau
|
||||||
|
ImageIcon backgroundImage = new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg");
|
||||||
|
Image image = backgroundImage.getImage();
|
||||||
|
g.drawImage(image, 0, 0, getWidth(), getHeight(), this); // Dessiner l'image pour couvrir tout le panneau
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStepDisplay() {
|
||||||
|
Step currentStep = steps.get(currentStepIndex);
|
||||||
|
stepText.setText(currentStep.getText());
|
||||||
|
stepImage.setIcon(new ImageIcon(currentStep.getImagePath()));
|
||||||
|
stepImage.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
stepImage.setVerticalAlignment(JLabel.CENTER);
|
||||||
|
prevButton.setEnabled(currentStepIndex > 0);
|
||||||
|
nextButton.setEnabled(currentStepIndex < steps.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPreviousStep() {
|
||||||
|
if (currentStepIndex > 0) {
|
||||||
|
currentStepIndex--;
|
||||||
|
updateStepDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNextStep() {
|
||||||
|
if (currentStepIndex < steps.size() - 1) {
|
||||||
|
currentStepIndex++;
|
||||||
|
updateStepDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
TestV1/src/fr/monkhanny/dorfromantik/utils/Database.java
Normal file
52
TestV1/src/fr/monkhanny/dorfromantik/utils/Database.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.utils;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class Database {
|
||||||
|
// Chargement des variables d'environnement
|
||||||
|
private static final String URL = Environnement.getEnv("DATABASE_URL_IUT");
|
||||||
|
private static final String LOGIN = Environnement.getEnv("DATABASE_LOGIN_IUT");
|
||||||
|
private static final String PASSWORD = Environnement.getEnv("DATABASE_PASSWORD_IUT");
|
||||||
|
|
||||||
|
// Variable de passerelle entre le programme et la base de données
|
||||||
|
private Connection database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ouvre la connexion avec la base de données
|
||||||
|
*/
|
||||||
|
public Database() throws SQLException {
|
||||||
|
try {
|
||||||
|
// Chargement du driver MariaDB
|
||||||
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Connexion à la base de données
|
||||||
|
this.database = DriverManager.getConnection(URL, LOGIN, PASSWORD);
|
||||||
|
}catch (SQLException e) {
|
||||||
|
// Gestion de l'erreur de connexion
|
||||||
|
throw new SQLException("Échec de la connexion à la base de données: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
// Si le driver n'est pas trouvé
|
||||||
|
throw new SQLException("Driver MariaDB introuvable dans le classpath", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Connection getDatabase() {
|
||||||
|
return this.database;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
|
if (this.database != null && !this.database.isClosed()) {
|
||||||
|
this.database.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Erreur lors de la fermeture de la base de données : " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.utils;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Environnement {
|
||||||
|
private static final String ENV_FILE = ".env";
|
||||||
|
private static final Properties properties = new Properties();
|
||||||
|
|
||||||
|
static {
|
||||||
|
loadEnvironmentVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void loadEnvironmentVariables() {
|
||||||
|
try (InputStream input = new FileInputStream(ENV_FILE)) {
|
||||||
|
// Chargement des variables du fichier .env
|
||||||
|
properties.load(input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Erreur lors du chargement du fichier .env : " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Méthode pour récupérer une variable d'environnement, renvoie null si non trouvé
|
||||||
|
public static String getEnv(String key) {
|
||||||
|
return properties.getProperty(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Méthode pour vérifier si une variable d'environnement est présente
|
||||||
|
public static boolean hasEnv(String key) {
|
||||||
|
return properties.containsKey(key);
|
||||||
|
}
|
||||||
|
}
|
74
TestV1/src/fr/monkhanny/dorfromantik/utils/Hexagon.java
Normal file
74
TestV1/src/fr/monkhanny/dorfromantik/utils/Hexagon.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.utils;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Polygon;
|
||||||
|
|
||||||
|
|
||||||
|
public class Hexagon extends Polygon {
|
||||||
|
private static final int ANGLE_BETWEEN_VERTICES = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur d'un hexagone
|
||||||
|
*
|
||||||
|
* @param x Position x du centre de l'hexagone
|
||||||
|
* @param y Position y du centre de l'hexagone
|
||||||
|
* @param radius Rayon de l'hexagone
|
||||||
|
* @param startAngle Angle de départ de l'hexagone
|
||||||
|
*/
|
||||||
|
public Hexagon(int x, int y, int radius, double startAngle) {
|
||||||
|
if (radius <= 0) {
|
||||||
|
throw new IllegalArgumentException("Le rayon doit être supérieur à zéro.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
double angleRad = calculateAngle(i, startAngle);
|
||||||
|
this.addPoint(
|
||||||
|
(int) (x + radius * Math.cos(angleRad)),
|
||||||
|
(int) (y + radius * Math.sin(angleRad))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcule l'angle en radians pour un sommet donné
|
||||||
|
*
|
||||||
|
* @param vertexIndex Index du sommet (0 à 5)
|
||||||
|
* @param startAngle Angle de départ
|
||||||
|
* @return Angle en radians
|
||||||
|
*/
|
||||||
|
private double calculateAngle(int vertexIndex, double startAngle) {
|
||||||
|
return Math.toRadians(vertexIndex * ANGLE_BETWEEN_VERTICES + startAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur d'un hexagone
|
||||||
|
*
|
||||||
|
* @param center Centre de l'hexagone
|
||||||
|
* @param radius Rayon de l'hexagone
|
||||||
|
* @param startAngle Angle de départ de l'hexagone
|
||||||
|
*/
|
||||||
|
public Hexagon(Point center, int radius, double startAngle) {
|
||||||
|
this(center.x, center.y, radius, startAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur d'un hexagone
|
||||||
|
*
|
||||||
|
* @param x Position x du centre de l'hexagone
|
||||||
|
* @param y Position y du centre de l'hexagone
|
||||||
|
* @param radius Rayon de l'hexagone
|
||||||
|
*/
|
||||||
|
public Hexagon(int x, int y, int radius) {
|
||||||
|
this(x, y, radius, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur d'un hexagone
|
||||||
|
*
|
||||||
|
* @param center Centre de l'hexagone
|
||||||
|
* @param radius Rayon de l'hexagone
|
||||||
|
*/
|
||||||
|
public Hexagon(Point center, int radius) {
|
||||||
|
this(center.x, center.y, radius, 0);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user