mise a jour du compilateur
This commit is contained in:
@@ -1,127 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal EnableExtensions EnableDelayedExpansion
|
|
||||||
pushd "%~dp0"
|
|
||||||
|
|
||||||
:: === CONFIGURATION ===
|
|
||||||
set "OUT=out"
|
|
||||||
set "MAIN_CLASS=Main" :: Si Main est dans un package, ex: monpackage.Main
|
|
||||||
:: =====================
|
|
||||||
|
|
||||||
if "%~1"=="" goto :help
|
|
||||||
|
|
||||||
if /I "%~1"=="help" goto :help
|
|
||||||
if /I "%~1"=="clean" goto :clean
|
|
||||||
if /I "%~1"=="build" goto :build
|
|
||||||
if /I "%~1"=="run" goto :run
|
|
||||||
if /I "%~1"=="count" goto :count
|
|
||||||
if /I "%~1"=="watch" goto :watch
|
|
||||||
if /I "%~1"=="purge" goto :purge
|
|
||||||
if /I "%~1"=="rebuild" goto :rebuild
|
|
||||||
|
|
||||||
goto :help
|
|
||||||
|
|
||||||
:clean
|
|
||||||
if exist "%OUT%" (
|
|
||||||
echo Suppression du dossier "%OUT%"...
|
|
||||||
rmdir /S /Q "%OUT%"
|
|
||||||
) else (
|
|
||||||
echo Aucun dossier "%OUT%" a supprimer.
|
|
||||||
)
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:build
|
|
||||||
where javac >nul 2>nul || (echo([ERREUR] javac introuvable dans le PATH & goto :eof)
|
|
||||||
|
|
||||||
if not exist "%OUT%" mkdir "%OUT%"
|
|
||||||
|
|
||||||
echo(Creation de la liste des sources...
|
|
||||||
dir /s /b *.java > "%TEMP%\sources.txt"
|
|
||||||
|
|
||||||
for /f %%I in ('find /c /v "" ^< "%TEMP%\sources.txt"') do set COUNT=%%I
|
|
||||||
if "%COUNT%"=="0" (
|
|
||||||
echo([ERREUR] Aucun fichier .java trouve dans %cd%
|
|
||||||
del "%TEMP%\sources.txt" >nul 2>nul
|
|
||||||
goto :eof
|
|
||||||
)
|
|
||||||
|
|
||||||
echo(%COUNT% fichiers trouves. Compilation...
|
|
||||||
javac -d "%OUT%" @"%TEMP%\sources.txt"
|
|
||||||
set ERR=%ERRORLEVEL%
|
|
||||||
del "%TEMP%\sources.txt" >nul 2>nul
|
|
||||||
|
|
||||||
if %ERR% EQU 0 (
|
|
||||||
echo(Compilation reussie !
|
|
||||||
) else (
|
|
||||||
echo([ERREUR] Compilation (code %ERR%)
|
|
||||||
)
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:run
|
|
||||||
call :build
|
|
||||||
if %ERR% EQU 0 (
|
|
||||||
echo(
|
|
||||||
echo(Execution de %MAIN_CLASS% ...
|
|
||||||
java -cp "%OUT%" %MAIN_CLASS%
|
|
||||||
)
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
:count
|
|
||||||
for /f %%I in ('dir /s /b *.java ^| find /c /v ""') do set COUNT=%%I
|
|
||||||
echo %COUNT% fichiers Java trouves.
|
|
||||||
|
|
||||||
:: Compte le nombre de ligne des fichier java
|
|
||||||
set /a LIGNES=0
|
|
||||||
for /f "delims=" %%F in ('dir /s /b *.java') do (
|
|
||||||
for /f %%N in ('type "%%F" ^| find /v /c ""') do set /a LIGNES+=%%N
|
|
||||||
)
|
|
||||||
echo %LIGNES% lignes Java trouvees.
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
:watch
|
|
||||||
echo Mode surveillance active : recompilation a chaque changement detecte
|
|
||||||
echo Appuie sur Ctrl+C pour quitter.
|
|
||||||
set "LASTSTATE="
|
|
||||||
:loop
|
|
||||||
for /f %%A in ('dir /s /b /a-d *.java') do (
|
|
||||||
set "CURRENTSTATE=!CURRENTSTATE!%%~tA"
|
|
||||||
)
|
|
||||||
if "!CURRENTSTATE!" NEQ "!LASTSTATE!" (
|
|
||||||
set "LASTSTATE=!CURRENTSTATE!"
|
|
||||||
call :build
|
|
||||||
)
|
|
||||||
set "CURRENTSTATE="
|
|
||||||
timeout /t 2 >nul
|
|
||||||
goto loop
|
|
||||||
|
|
||||||
:purge
|
|
||||||
echo Suppression des .class hors de "%OUT%"...
|
|
||||||
for /f "delims=" %%C in ('dir /s /b *.class ^| findstr /vi /c:"\%OUT%\"') do del /q "%%C"
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:rebuild
|
|
||||||
call :clean
|
|
||||||
call :purge
|
|
||||||
call :build
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
|
|
||||||
:help
|
|
||||||
echo Usage: build.bat [option]
|
|
||||||
echo.
|
|
||||||
echo build - Compile le projet
|
|
||||||
echo clean - Supprime le dossier de sortie "%OUT%"
|
|
||||||
echo run - Compile puis lance %MAIN_CLASS%
|
|
||||||
echo count - Compte le nombre de fichiers Java
|
|
||||||
echo watch - Recompile automatiquement si un fichier change
|
|
||||||
echo help - Affiche cette aide
|
|
||||||
echo purge - Supprime les .class hors de "%OUT%"
|
|
||||||
echo rebuild - Nettoie, purge et recompile le projet
|
|
||||||
goto :eof
|
|
||||||
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ======================
|
||||||
|
# CONFIGURATION
|
||||||
|
# ======================
|
||||||
|
OUT="out"
|
||||||
|
MAIN_CLASS="Main" # Si Main est dans un package, ex: monpackage.Main
|
||||||
|
# ======================
|
||||||
|
|
||||||
|
# Se placer dans le dossier du script
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
cmd="${1:-help}"
|
||||||
|
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
if [ -d "$OUT" ]; then
|
||||||
|
echo "Suppression du dossier '$OUT'..."
|
||||||
|
rm -rf "$OUT"
|
||||||
|
else
|
||||||
|
echo "Aucun dossier '$OUT' à supprimer."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
build() {
|
||||||
|
if ! command -v javac >/dev/null 2>&1; then
|
||||||
|
echo "[ERREUR] javac introuvable dans le PATH"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$OUT"
|
||||||
|
|
||||||
|
echo "Création de la liste des sources..."
|
||||||
|
mapfile -t sources < <(find . -type f -name "*.java")
|
||||||
|
|
||||||
|
COUNT="${#sources[@]}"
|
||||||
|
if [ "$COUNT" -eq 0 ]; then
|
||||||
|
echo "[ERREUR] Aucun fichier .java trouvé dans $PWD"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$COUNT fichiers trouvés. Compilation..."
|
||||||
|
|
||||||
|
javac -d "$OUT" "${sources[@]}"
|
||||||
|
ERR=$?
|
||||||
|
|
||||||
|
if [ "$ERR" -eq 0 ]; then
|
||||||
|
echo "Compilation réussie !"
|
||||||
|
else
|
||||||
|
echo "[ERREUR] Compilation (code $ERR)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $ERR
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run() {
|
||||||
|
build
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo
|
||||||
|
echo "Exécution de $MAIN_CLASS ..."
|
||||||
|
java -cp "$OUT" "$MAIN_CLASS"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
count() {
|
||||||
|
COUNT=$(find . -type f -name "*.java" | wc -l)
|
||||||
|
echo "$COUNT fichiers Java trouvés."
|
||||||
|
|
||||||
|
LIGNES=0
|
||||||
|
while IFS= read -r file; do
|
||||||
|
NB=$(wc -l < "$file")
|
||||||
|
LIGNES=$((LIGNES + NB))
|
||||||
|
done < <(find . -type f -name "*.java")
|
||||||
|
|
||||||
|
echo "$LIGNES lignes Java trouvées."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
watch() {
|
||||||
|
echo "Mode surveillance activé : recompilation à chaque changement..."
|
||||||
|
echo "Ctrl+C pour quitter."
|
||||||
|
|
||||||
|
LASTSTATE=""
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
CURRENTSTATE=$(find . -type f -name "*.java" -exec stat -c "%n %Y" {} \;)
|
||||||
|
if [ "$CURRENTSTATE" != "$LASTSTATE" ]; then
|
||||||
|
LASTSTATE="$CURRENTSTATE"
|
||||||
|
build
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
purge() {
|
||||||
|
echo "Suppression des .class hors de '$OUT'..."
|
||||||
|
find . -type f -name "*.class" ! -path "./$OUT/*" -delete
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rebuild() {
|
||||||
|
clean
|
||||||
|
purge
|
||||||
|
build
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
help() {
|
||||||
|
echo "Usage: ./build.sh [option]"
|
||||||
|
echo
|
||||||
|
echo " build - Compile le projet"
|
||||||
|
echo " clean - Supprime le dossier de sortie '$OUT'"
|
||||||
|
echo " run - Compile puis lance $MAIN_CLASS"
|
||||||
|
echo " count - Compte les fichiers et les lignes Java"
|
||||||
|
echo " watch - Recompile automatiquement si un fichier change"
|
||||||
|
echo " purge - Supprime les .class hors de '$OUT'"
|
||||||
|
echo " rebuild - Nettoie, purge et recompile le projet"
|
||||||
|
echo " help - Affiche cette aide"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
clean) clean ;;
|
||||||
|
build) build ;;
|
||||||
|
run) run ;;
|
||||||
|
count) count ;;
|
||||||
|
watch) watch ;;
|
||||||
|
purge) purge ;;
|
||||||
|
rebuild) rebuild ;;
|
||||||
|
help|*) help ;;
|
||||||
|
esac
|
||||||
+13
-7
@@ -4,11 +4,9 @@ import controleur.ControleurReseau;
|
|||||||
import modele.Couleur;
|
import modele.Couleur;
|
||||||
import modele.ModeDeJeu;
|
import modele.ModeDeJeu;
|
||||||
import modele.Partie;
|
import modele.Partie;
|
||||||
import modele.joueur.Joueur;
|
import modele.joueur.*;
|
||||||
import modele.joueur.JoueurHumain;
|
import vue.*;
|
||||||
import vue.Vue;
|
|
||||||
import vue.VueConsole;
|
|
||||||
import vue.VueGraphiqueSwing;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -21,7 +19,7 @@ public class Main {
|
|||||||
|
|
||||||
int choixMode = 1; // à remplacer par Scanner plus tard
|
int choixMode = 1; // à remplacer par Scanner plus tard
|
||||||
int choixAffichage = 3; // 1: Console, 2: JavaFX, 3: Swing
|
int choixAffichage = 3; // 1: Console, 2: JavaFX, 3: Swing
|
||||||
String stylePlateau = "BOIS_CLAIR"; // Style du plateau, à remplacer par une entrée utilisateur
|
String stylePlateau = "RETRO_BOIS"; // Style du plateau, à remplacer par une entrée utilisateur
|
||||||
|
|
||||||
// === Choix du mode de jeu ===
|
// === Choix du mode de jeu ===
|
||||||
switch (choixMode) {
|
switch (choixMode) {
|
||||||
@@ -62,11 +60,19 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Réaffecter la vue si les joueurs sont humains
|
// Réaffecter la vue si les joueurs sont humains
|
||||||
if (joueurBlanc instanceof JoueurHumain jb) {
|
/*if (joueurBlanc instanceof JoueurHumain jb) {
|
||||||
jb.setVue(vue);
|
jb.setVue(vue);
|
||||||
}
|
}
|
||||||
if (joueurNoir instanceof JoueurHumain jn) {
|
if (joueurNoir instanceof JoueurHumain jn) {
|
||||||
jn.setVue(vue);
|
jn.setVue(vue);
|
||||||
|
}*/
|
||||||
|
if (joueurBlanc instanceof JoueurHumain) {
|
||||||
|
JoueurHumain jb= (JoueurHumain) joueurBlanc;
|
||||||
|
jb.setVue(vue);
|
||||||
|
}
|
||||||
|
if (joueurNoir instanceof JoueurHumain) {
|
||||||
|
JoueurHumain jn= (JoueurHumain) joueurNoir;
|
||||||
|
jn.setVue(vue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Lancement de la partie ===
|
// === Lancement de la partie ===
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+21
-15
@@ -32,42 +32,47 @@ public class CaseSwingUI extends JPanel implements MouseListener{
|
|||||||
|
|
||||||
public CaseSwingUI(String style, int ligne, int colonne, Case caseModele) {
|
public CaseSwingUI(String style, int ligne, int colonne, Case caseModele) {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "RETRO_BOIS" -> {
|
case "RETRO_BOIS" :
|
||||||
// Style Bois rétro :
|
// Style Bois rétro :
|
||||||
couleurCaseClaire = new Color(222, 184, 135); // Burlywood (bois clair rétro)
|
couleurCaseClaire = new Color(222, 184, 135); // Burlywood (bois clair rétro)
|
||||||
couleurCaseFoncee = new Color(139, 69, 19); // SaddleBrown (bois foncé rétro)
|
couleurCaseFoncee = new Color(139, 69, 19); // SaddleBrown (bois foncé rétro)
|
||||||
couleurCaseSelection = new Color(205, 133, 63); // Peru (orange/brun vieilli)
|
couleurCaseSelection = new Color(205, 133, 63); // Peru (orange/brun vieilli)
|
||||||
}
|
|
||||||
case "METAL_FUTURISTE" -> {
|
case "METAL_FUTURISTE" :
|
||||||
// Style métallique Futuriste
|
// Style métallique Futuriste
|
||||||
couleurCaseClaire = new Color(192, 192, 192); // Silver
|
couleurCaseClaire = new Color(192, 192, 192); // Silver
|
||||||
couleurCaseFoncee = new Color(105, 105, 105); // DimGray
|
couleurCaseFoncee = new Color(105, 105, 105); // DimGray
|
||||||
couleurCaseSelection = new Color(0, 255, 255); // Cyan flashy (effet néon)
|
couleurCaseSelection = new Color(0, 255, 255); // Cyan flashy (effet néon)
|
||||||
}
|
|
||||||
case "BOIS_CLAIR" -> {
|
case "BOIS_CLAIR" :
|
||||||
// Style Bois clair
|
// Style Bois clair
|
||||||
couleurCaseClaire = new Color(240, 218, 181); // Beige clair
|
couleurCaseClaire = new Color(240, 218, 181); // Beige clair
|
||||||
couleurCaseFoncee = new Color(181, 136, 99); // Marron clair
|
couleurCaseFoncee = new Color(181, 136, 99); // Marron clair
|
||||||
couleurCaseSelection = new Color(209, 83, 71); // Rouge-orangé
|
couleurCaseSelection = new Color(209, 83, 71); // Rouge-orangé
|
||||||
couleurCasePrecedente = new Color(255, 112, 99); // Rouge clair
|
couleurCasePrecedente = new Color(255, 112, 99); // Rouge clair
|
||||||
}
|
|
||||||
case "JAUNE_CHALEUREUX" -> {
|
case "JAUNE_CHALEUREUX" :
|
||||||
// Style Jaune Chaleureux
|
// Style Jaune Chaleureux
|
||||||
couleurCaseClaire = new Color(253, 231, 76); // Jaune vif
|
couleurCaseClaire = new Color(253, 231, 76); // Jaune vif
|
||||||
couleurCaseFoncee = new Color(227, 101, 91); // Rouge doux
|
couleurCaseFoncee = new Color(227, 101, 91); // Rouge doux
|
||||||
couleurCaseSelection = new Color(248, 161, 87); // Orange doux
|
couleurCaseSelection = new Color(248, 161, 87); // Orange doux
|
||||||
}
|
|
||||||
case "VINTAGE_PASTEL" -> {
|
case "VINTAGE_PASTEL" :
|
||||||
// Style vintage pastel
|
// Style vintage pastel
|
||||||
couleurCaseClaire = new Color(246, 229, 189); // Beige pastel
|
couleurCaseClaire = new Color(246, 229, 189); // Beige pastel
|
||||||
couleurCaseFoncee = new Color(249, 125, 125); // Rose brique clair
|
couleurCaseFoncee = new Color(249, 125, 125); // Rose brique clair
|
||||||
couleurCaseSelection = new Color(200, 90, 90); // Rouge passé
|
couleurCaseSelection = new Color(200, 90, 90); // Rouge passé
|
||||||
}
|
|
||||||
default -> {
|
default :
|
||||||
couleurCaseClaire = new Color(255, 255, 255); // Blanc
|
/*couleurCaseClaire = new Color(255, 255, 255); // Blanc
|
||||||
couleurCaseFoncee = new Color(200, 200, 200); // Gris
|
couleurCaseFoncee = new Color(200, 200, 200); // Gris
|
||||||
couleurCaseSelection = new Color(100, 100, 100); // Gris foncé
|
couleurCaseSelection = new Color(100, 100, 100); // Gris foncés*/
|
||||||
}
|
couleurCaseClaire = new Color(240, 218, 181); // Beige clair
|
||||||
|
couleurCaseFoncee = new Color(181, 136, 99); // Marron clair
|
||||||
|
couleurCaseSelection = new Color(209, 83, 71); // Rouge-orangé
|
||||||
|
couleurCasePrecedente = new Color(255, 112, 99); // Rouge clair
|
||||||
|
System.out.println(style);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +109,8 @@ public class CaseSwingUI extends JPanel implements MouseListener{
|
|||||||
while(parent != null && !(parent instanceof PlateauSwingUI)) {
|
while(parent != null && !(parent instanceof PlateauSwingUI)) {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
if (parent instanceof PlateauSwingUI plateau) {
|
if (parent instanceof PlateauSwingUI ) {
|
||||||
|
PlateauSwingUI plateau = (PlateauSwingUI) parent;
|
||||||
plateau.selectionnerCase(this);
|
plateau.selectionnerCase(this);
|
||||||
}
|
}
|
||||||
//System.out.println("Case cliquée : " + ligne + ", " + colonne);
|
//System.out.println("Case cliquée : " + ligne + ", " + colonne);
|
||||||
|
|||||||
@@ -115,27 +115,27 @@ public class VueGraphiqueSwing implements Vue {
|
|||||||
// Couleur selon auteur
|
// Couleur selon auteur
|
||||||
Color bg, fg, border;
|
Color bg, fg, border;
|
||||||
switch (auteur.toLowerCase()) {
|
switch (auteur.toLowerCase()) {
|
||||||
case "moi" -> {
|
case "moi" : {
|
||||||
bg = new Color(200, 255, 200); // vert clair
|
bg = new Color(200, 255, 200); // vert clair
|
||||||
fg = Color.BLACK;
|
fg = Color.BLACK;
|
||||||
border = Color.GREEN.darker();
|
border = Color.GREEN.darker();
|
||||||
}
|
}
|
||||||
case "serveurbleu" -> {
|
case "serveurbleu" : {
|
||||||
bg = new Color(220, 235, 255); // bleu clair
|
bg = new Color(220, 235, 255); // bleu clair
|
||||||
fg = Color.BLUE.darker();
|
fg = Color.BLUE.darker();
|
||||||
border = Color.BLUE;
|
border = Color.BLUE;
|
||||||
}
|
}
|
||||||
case "serveurrouge" -> {
|
case "serveurrouge" : {
|
||||||
bg = new Color(255, 220, 220); // rouge clair
|
bg = new Color(255, 220, 220); // rouge clair
|
||||||
fg = Color.RED.darker();
|
fg = Color.RED.darker();
|
||||||
border = Color.RED;
|
border = Color.RED;
|
||||||
}
|
}
|
||||||
case "serveurorange" -> {
|
case "serveurorange" : {
|
||||||
bg = new Color(255, 220, 220); // orange clair
|
bg = new Color(255, 220, 220); // orange clair
|
||||||
fg = Color.ORANGE.darker();
|
fg = Color.ORANGE.darker();
|
||||||
border = Color.ORANGE;
|
border = Color.ORANGE;
|
||||||
}
|
}
|
||||||
default -> { // adversaire
|
default : { // adversaire
|
||||||
bg = new Color(255, 220, 220); // rouge clair
|
bg = new Color(255, 220, 220); // rouge clair
|
||||||
fg = Color.RED.darker();
|
fg = Color.RED.darker();
|
||||||
border = Color.RED;
|
border = Color.RED;
|
||||||
|
|||||||
Reference in New Issue
Block a user