Maj BoardLoader + makefile
This commit is contained in:
17
Makefile
17
Makefile
@@ -2,6 +2,10 @@
|
|||||||
SRC_DIR = fr
|
SRC_DIR = fr
|
||||||
BIN_DIR = bin
|
BIN_DIR = bin
|
||||||
|
|
||||||
|
# === Répertoires des ressources ===
|
||||||
|
RES_SRC = fr/iut_fbleau/Res
|
||||||
|
RES_BIN = bin/fr/iut_fbleau/Res
|
||||||
|
|
||||||
# === Recherche automatique des fichiers .java dans tous les sous-dossiers ===
|
# === Recherche automatique des fichiers .java dans tous les sous-dossiers ===
|
||||||
SOURCES := $(shell find $(SRC_DIR) -name "*.java")
|
SOURCES := $(shell find $(SRC_DIR) -name "*.java")
|
||||||
|
|
||||||
@@ -19,11 +23,20 @@ JAVAFLAGS = -cp $(BIN_DIR)
|
|||||||
all: build
|
all: build
|
||||||
|
|
||||||
# === Compilation ===
|
# === Compilation ===
|
||||||
build:
|
build: compile resources
|
||||||
|
@echo "✔ Compilation terminée."
|
||||||
|
|
||||||
|
compile:
|
||||||
@echo "===> Compilation du projet Avalam..."
|
@echo "===> Compilation du projet Avalam..."
|
||||||
@mkdir -p $(BIN_DIR)
|
@mkdir -p $(BIN_DIR)
|
||||||
@$(JC) $(JCFLAGS) $(SOURCES)
|
@$(JC) $(JCFLAGS) $(SOURCES)
|
||||||
@echo "✔ Compilation terminée."
|
|
||||||
|
# === Copie des ressources (.txt) dans bin ===
|
||||||
|
resources:
|
||||||
|
@echo "===> Copie des ressources..."
|
||||||
|
@mkdir -p $(RES_BIN)
|
||||||
|
@cp $(RES_SRC)/* $(RES_BIN)/
|
||||||
|
@echo "✔ Ressources copiées."
|
||||||
|
|
||||||
# === Exécution ===
|
# === Exécution ===
|
||||||
run:
|
run:
|
||||||
|
|||||||
BIN
bin/fr/iut_fbleau/Avalam/AvalamBoard.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/AvalamBoard.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/AvalamPly.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/AvalamPly.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/AvalamWindow$1.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/AvalamWindow$1.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/AvalamWindow.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/AvalamWindow.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/Color.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/Color.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/Main.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/Main.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/Tower.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/Tower.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/logic/BoardLoader.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/logic/BoardLoader.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/BoardView.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/BoardView.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/HighlightLayer.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/HighlightLayer.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/InteractionController.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/InteractionController.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceButton$1.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceButton$1.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceButton.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceButton.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceLayer.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/PieceLayer.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/ScoreView.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/ScoreView.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/Avalam/ui/TurnView.class
Normal file
BIN
bin/fr/iut_fbleau/Avalam/ui/TurnView.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/AbstractBoard.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/AbstractBoard.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/AbstractGame.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/AbstractGame.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/AbstractGamePlayer.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/AbstractGamePlayer.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/AbstractPly.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/AbstractPly.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/IBoard.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/IBoard.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/Player.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/Player.class
Normal file
Binary file not shown.
BIN
bin/fr/iut_fbleau/GameAPI/Result.class
Normal file
BIN
bin/fr/iut_fbleau/GameAPI/Result.class
Normal file
Binary file not shown.
9
bin/fr/iut_fbleau/Res/Plateau.txt
Normal file
9
bin/fr/iut_fbleau/Res/Plateau.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
0,0,1,2,0,0,0,0,0
|
||||||
|
0,1,2,1,2,0,0,0,0
|
||||||
|
0,2,1,2,1,2,1,0,0
|
||||||
|
0,1,2,1,2,1,2,1,2
|
||||||
|
1,2,1,2,0,2,1,2,1
|
||||||
|
2,1,2,1,2,1,2,1,0
|
||||||
|
0,0,1,2,1,2,1,2,0
|
||||||
|
0,0,0,0,2,1,2,1,0
|
||||||
|
0,0,0,0,0,2,1,0,0
|
||||||
@@ -40,6 +40,8 @@ public class AvalamWindow extends JFrame {
|
|||||||
// Chargement du plateau initial depuis Plateau.txt
|
// Chargement du plateau initial depuis Plateau.txt
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
Tower[][] initialGrid = BoardLoader.loadFromFile("fr/iut_fbleau/Res/Plateau.txt");
|
Tower[][] initialGrid = BoardLoader.loadFromFile("fr/iut_fbleau/Res/Plateau.txt");
|
||||||
|
// debug TEMP !!!!!!!!!
|
||||||
|
System.out.println("DEBUG Plateau: Grid[0][0] = " + initialGrid[0][0]);
|
||||||
board = new AvalamBoard(initialGrid); // PLAYER1 commence
|
board = new AvalamBoard(initialGrid); // PLAYER1 commence
|
||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
@@ -97,10 +99,10 @@ public class AvalamWindow extends JFrame {
|
|||||||
String msg;
|
String msg;
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case WIN -> msg = "Le joueur jaune a gagné !";
|
case WIN : msg = "Le joueur jaune a gagné !";
|
||||||
case LOSS -> msg = "Le joueur rouge a gagné !";
|
case LOSS : msg = "Le joueur rouge a gagné !";
|
||||||
case DRAW -> msg = "Égalité !";
|
case DRAW : msg = "Égalité !";
|
||||||
default -> msg = "Fin de partie.";
|
default : msg = "Fin de partie.";
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(this, msg, "Partie terminée",
|
JOptionPane.showMessageDialog(this, msg, "Partie terminée",
|
||||||
|
|||||||
@@ -3,39 +3,55 @@ package fr.iut_fbleau.Avalam.logic;
|
|||||||
import fr.iut_fbleau.Avalam.Color;
|
import fr.iut_fbleau.Avalam.Color;
|
||||||
import fr.iut_fbleau.Avalam.Tower;
|
import fr.iut_fbleau.Avalam.Tower;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
/**
|
|
||||||
* Charge un plateau Avalam depuis un fichier texte.
|
|
||||||
* Format attendu : matrice 9×9 de 0,1,2 séparés par virgule.
|
|
||||||
*/
|
|
||||||
public class BoardLoader {
|
public class BoardLoader {
|
||||||
|
|
||||||
public static Tower[][] loadFromFile(String file) {
|
public static Tower[][] loadFromFile(String resourcePath) {
|
||||||
|
|
||||||
Tower[][] grid = new Tower[9][9];
|
Tower[][] grid = new Tower[9][9];
|
||||||
|
|
||||||
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
InputStream in = BoardLoader.class.getResourceAsStream("/" + resourcePath);
|
||||||
|
|
||||||
|
if (in == null) {
|
||||||
|
System.err.println("❌ Ressource introuvable : /" + resourcePath);
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
while ((line = br.readLine()) != null && row < 9) {
|
while ((line = reader.readLine()) != null && row < 9) {
|
||||||
|
|
||||||
String[] vals = line.split(",");
|
// 🔥 Accepte SOIT les espaces, SOIT les virgules
|
||||||
|
line = line.replace(",", " ");
|
||||||
|
String[] parts = line.trim().split("\\s+");
|
||||||
|
|
||||||
for (int col = 0; col < 9; col++) {
|
for (int col = 0; col < 9; col++) {
|
||||||
int v = Integer.parseInt(vals[col].trim());
|
int value = Integer.parseInt(parts[col]);
|
||||||
|
|
||||||
switch (v) {
|
switch (value) {
|
||||||
case 1 -> grid[row][col] = new Tower(Color.YELLOW);
|
case 1:
|
||||||
case 2 -> grid[row][col] = new Tower(Color.RED);
|
grid[row][col] = new Tower(Color.YELLOW);
|
||||||
default -> grid[row][col] = null;
|
break;
|
||||||
|
case 2:
|
||||||
|
grid[row][col] = new Tower(Color.RED);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
grid[row][col] = null;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user