From b18a4e495722f67467373f61ebca4ae4a2186c6c Mon Sep 17 00:00:00 2001 From: "foulou.salle224-15" Date: Sat, 16 Nov 2024 17:28:09 +0100 Subject: [PATCH] =?UTF-8?q?placement=20des=20tuiles=20possibles=20mais=20p?= =?UTF-8?q?robl=C3=A8me=20d'=C3=A9cart=20entre=20les=20tuiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestV1/GameController.java | 7 +- TestV1/Main.java | 15 +- .../TestEnAttendantResolutionBug/Board.class | Bin 0 -> 946 bytes .../TestEnAttendantResolutionBug/Board.java | 12 +- .../GameController.class | Bin 0 -> 443 bytes .../GameController.java | 6 +- .../GameView$1.class | Bin 0 -> 630 bytes .../GameView$2.class | Bin 0 -> 695 bytes .../GameView.class | Bin 0 -> 3462 bytes .../GameView.java | 147 +++++++----------- .../TestEnAttendantResolutionBug/Main.class | Bin 0 -> 420 bytes TestV1/TestEnAttendantResolutionBug/Main.java | 8 +- .../Terrain.class | Bin 0 -> 1008 bytes .../TestEnAttendantResolutionBug/Terrain.java | 2 +- .../TestEnAttendantResolutionBug/Tile.class | Bin 0 -> 320 bytes TestV1/TestEnAttendantResolutionBug/Tile.java | 2 +- .../View/BoardView.java | 61 -------- .../View/GameController.java | 31 ---- .../View/GameView.java | 52 ------- .../controller/GameController.java | 20 --- .../model/Board.java | 26 ---- .../model/Game.java | 26 ---- .../model/Tile.java | 19 --- .../view/BoardView.java | 24 --- .../view/GameView.java | 28 ---- .../view/TileView.java | 21 --- 26 files changed, 72 insertions(+), 435 deletions(-) create mode 100644 TestV1/TestEnAttendantResolutionBug/Board.class create mode 100644 TestV1/TestEnAttendantResolutionBug/GameController.class create mode 100644 TestV1/TestEnAttendantResolutionBug/GameView$1.class create mode 100644 TestV1/TestEnAttendantResolutionBug/GameView$2.class create mode 100644 TestV1/TestEnAttendantResolutionBug/GameView.class create mode 100644 TestV1/TestEnAttendantResolutionBug/Main.class create mode 100644 TestV1/TestEnAttendantResolutionBug/Terrain.class create mode 100644 TestV1/TestEnAttendantResolutionBug/Tile.class delete mode 100644 TestV1/TestEnAttendantResolutionBug/View/BoardView.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/View/GameController.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/View/GameView.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/controller/GameController.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/model/Board.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/model/Game.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/model/Tile.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/view/BoardView.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/view/GameView.java delete mode 100644 TestV1/TestEnAttendantResolutionBug/view/TileView.java diff --git a/TestV1/GameController.java b/TestV1/GameController.java index 264dc07..0f4f206 100644 --- a/TestV1/GameController.java +++ b/TestV1/GameController.java @@ -1,12 +1,15 @@ public class GameController { private GameView view; + private Board board; + // Constructeur qui prend GameView comme argument public GameController(GameView view) { this.view = view; + this.board = view.getBoard(); // Associer le Board à partir de la vue } + // Méthode pour démarrer le jeu public void startGame() { - System.out.println("Bienvenue dans Dorfromantik simplifié !"); - view.showTile(); + view.setVisible(true); // Afficher la fenêtre } } diff --git a/TestV1/Main.java b/TestV1/Main.java index 86515a4..f222a87 100644 --- a/TestV1/Main.java +++ b/TestV1/Main.java @@ -1,15 +1,8 @@ public class Main { public static void main(String[] args) { - // Exemple : création d'une tuile avec deux terrains - Tile tile = new Tile(Terrain.MER, Terrain.FORET, 1); - - // Vue graphique - GameView view = new GameView(tile); - - // Contrôleur - GameController controller = new GameController(view); - - // Démarrer le jeu - controller.startGame(); + Board board = new Board(); + GameView view = new GameView(board); + GameController controller = new GameController(view); // Passe la vue au contrôleur + controller.startGame(); // Démarre le jeu } } diff --git a/TestV1/TestEnAttendantResolutionBug/Board.class b/TestV1/TestEnAttendantResolutionBug/Board.class new file mode 100644 index 0000000000000000000000000000000000000000..b1c7877e713b3a13eb4808aea410ca448dbfb314 GIT binary patch literal 946 zcmX^0Z`VEs1_nn4eJ%zj24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc20^f*(vr*^eUHTA4Bx~8E(Uf6W=;lf1|D_>ULFQM27X2cR;T>L zq7+63){@Me)M7>kejkK3-^2oIZU#XHA$A5~9tIHxQAP${6j??F?&SQulElosV(-*S zMg~z0h;Ag8S!+gtj1cExkYJExWMD2REn#G^z@iR|PD~+?QPMmNG7Pee49w}NC5#Me zSd7xd)X2^t&&a?Ml9`jr$iNw#nVy$eQd*SC$e<2U3JxXT!~z=#H?h1#KOjFduf*C1 zq{Z6KnvsFUIX@*86h4`GseYxoNvTC4iAf;igffc*@{2P|GV}BNlaoseGE-9+8HAzE zLYSl(#mK;(n34iAkdZ+WLmpz2W*8#_dwOaKM3n@FDouzoMg|V3qGCn{K@F&fVZN|t zWY9zx!{alq;QZ2}C!u7#IY!wlgql?Pg$)+|Izcm4Ry`Sg$ez0|OreGXnzy2LlTO zCj&nN7Xu@M3WF+Cw=x40*cNWBEeu@RI~fF+7}mfwvVjfeWng4bV^D``&}3i+8^;UQ zptF-fjF}-EVHYT`Ffa%*@GuB5FfwQ`XhOBALG9rKYum{n#l&!cL2d(@RiX@x3|b7@ f3`}63$ucm49l#3GgRWE(8XP(dj10QqfYAd0>Y2w9 literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/Board.java b/TestV1/TestEnAttendantResolutionBug/Board.java index 29d0800..de436b7 100644 --- a/TestV1/TestEnAttendantResolutionBug/Board.java +++ b/TestV1/TestEnAttendantResolutionBug/Board.java @@ -3,30 +3,24 @@ import java.util.HashMap; import java.util.Map; public class Board { - private Map tiles; + private final Map tiles; public Board() { - tiles = new HashMap<>(); + this.tiles = new HashMap<>(); } - // Vérifie si la position est déjà occupée public boolean isPositionOccupied(Point position) { return tiles.containsKey(position); } - // Ajoute une tuile à une position donnée public void addTile(Point position, Tile tile) { - if (!isPositionOccupied(position)) { - tiles.put(position, tile); - } + tiles.put(position, tile); } - // Récupère la tuile à une position donnée public Tile getTile(Point position) { return tiles.get(position); } - // Récupère toutes les tuiles public Map getTiles() { return tiles; } diff --git a/TestV1/TestEnAttendantResolutionBug/GameController.class b/TestV1/TestEnAttendantResolutionBug/GameController.class new file mode 100644 index 0000000000000000000000000000000000000000..a7ec8c170da1664147bdb6608819f7dcf5527bf2 GIT binary patch literal 443 zcmX^0Z`VEs1_nn41uh0A24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc23Dv1#G(`~26hH!P6loU9(D#^9tJ)Jentj9_r%;(=lr~qqWqkk z)FMU()+CTpMh12tupVoWdO;orAqHVa29~nS)N)1!E+3Glu*}qQYc2*+1~GO9aUKQ< z21!N+4wwWZ16OfsNmyoaW>QWnBLj;@lx7$s1Fr@`Cy3ADoS%})$iVNDnV0HUnwykb z6p{#5&skiOSX2TsjFEvWIKQ+gIn^x_WRNgO4B=cokmnf`8Mqmk7#J9s7=%EcVqjnp z0=X9~!pOkNAjQDQAkDzQV9CG?Rwt^poq$O8Zz(M?YP literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/GameController.java b/TestV1/TestEnAttendantResolutionBug/GameController.java index 45709d8..5fdb271 100644 --- a/TestV1/TestEnAttendantResolutionBug/GameController.java +++ b/TestV1/TestEnAttendantResolutionBug/GameController.java @@ -1,11 +1,13 @@ public class GameController { - private GameView view; + private final Board board; + private final GameView view; public GameController(GameView view) { + this.board = new Board(); this.view = view; } public void startGame() { - view.showBoard(); + view.setVisible(true); } } diff --git a/TestV1/TestEnAttendantResolutionBug/GameView$1.class b/TestV1/TestEnAttendantResolutionBug/GameView$1.class new file mode 100644 index 0000000000000000000000000000000000000000..a987ae0c5d2c713757217bafb9a469a0a0922748 GIT binary patch literal 630 zcmX^0Z`VEs1_nn4HBJU524;2!79Ivx1~x_pF89RT)UeFdauq{H2DXxn%wiP-Mg}e) zn6Nb$0|x^qI|COF12+Q?BZG8SVp*boVtI*vYFTPtiN0@sX>qD!N@77tY7rv?n@wh3 zW{Djm1G9!^7#9N{13x>101ty8gAgNwBsQI{AVU}#IMP!~0`fESN*Ec0G&FtSD#2pb zTnr)%qU;P}JPhIt5{wKSFt;%>2xKJYrR1c79pRjlnVikYAgqC|T{Dc4fmZ|JBM_g( zIX@+pk%8YQGcVPzG&d==C?qi{CzX*wz&EudBR?e|u_!S&wIsEun2~`e7vx8<@u?|{ z401>oAcX10GP+(wU;9y{2U=$Dl#U29#0}}%S z12=;t0~3Q30|SE+0~1(;OG|qz1Ebb<2KJ30)eO=M3=C`xj0_A6!VEGD3=FJ{3=9nd z42%r23~~&NV67TZtvp&=7#Ov;G4O6<5JqU`0vjvFz|A1ez``I8wpf8dk%57Mg+YWt Xi9rP{BEq1`z`(%8zz9~&z`y_i>BWUk literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/GameView$2.class b/TestV1/TestEnAttendantResolutionBug/GameView$2.class new file mode 100644 index 0000000000000000000000000000000000000000..0bc4cc079c706e31794d744820bcb0d47b3432cc GIT binary patch literal 695 zcmX^0Z`VEs1_nn4LoNm;24;2!79Ivx1~x_p_K?(~qQuNRMh3RB#GKO9VnzlY4b5mD zsIWCB0|x^qI|COF12+Q?BLkOvVs2_!W@@>L5hH_;N^p5*Npgm7Vu1=&JtG5Cv?nJ6 z69XR)13!ZRBLlOqYY-y?C)_-c^+G%h!VDse4D9(uDVceRIgAX<8k(N$3}TE7Qdx;* ziTXK-dFlFo`N5^h8E%=WIVrA1MfpV_Qzdv9BtfRKI(sk7r(9YLRnJ zVsUY5v48>t2ZJ&L0|TRg1Ss%9ECvn+RR%Q%Mh0~T28L}6%nXbS3=E+=7#R2M;o8i= zz6peQw=oE^_%CN*@dk6nw=oE^BDhl97zEi6T-j|5g6s&c!Zrp$4ls8k11ke3g9w8- zgD8UpgEE5}gD8VKgAs!%gD8U;gCm0rgD8V5LjXfCgD3+Ng9ZZw0~^>et_+$C3=Gl? zT;c2tq71%R2nH4gEd~Y#CI)Q=9R>yl76x4g1_phwh%SQx0|NsW10w?m0|Ntt00#i7 Cy@Kcf literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/GameView.class b/TestV1/TestEnAttendantResolutionBug/GameView.class new file mode 100644 index 0000000000000000000000000000000000000000..2b3d584a1446a38535d2eb3c8596cce99e223708 GIT binary patch literal 3462 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 g@PUDWfsKKQVH1Nf!$)vA!^B_=i7$ptAX Color.BLUE; + case CHAMP -> Color.YELLOW; + case FORET -> new Color(34, 139, 34); + case PRE -> Color.GREEN; + case MONTAGNE -> Color.GRAY; + }; } - private void handleMouseClick(int mouseX, int mouseY) { - // Calcul des coordonnées de la grille de manière à respecter la structure hexagonale - - // Calcul de la colonne et de la ligne en fonction de la taille des hexagones - int gridX = (int) (mouseX / (hexWidth * 0.75)); // Calcul de la colonne - - // Calcul de la ligne en fonction de la hauteur des hexagones - int gridY = (int) (mouseY / hexHeight); // Calcul de la ligne - - // Détecter si c'est une rangée paire ou impaire et appliquer un décalage - if (gridY % 2 != 0) { // Si la ligne est impaire - gridX += 1; // Décalage horizontal pour les rangées impaires - } - - // Calculer les coordonnées X et Y en pixels - int finalX = (int) (gridX * hexWidth * 0.75); // Calcul des coordonnées X - int finalY = gridY * hexHeight; // Calcul des coordonnées Y - - // Créer un objet Point avec les coordonnées finales - Point position = new Point(finalX, finalY); - - // Vérifier si la position est déjà occupée par une autre tuile - if (!board.isPositionOccupied(position)) { - // Créer une nouvelle tuile (ici, une tuile de forêt) - Tile newTile = new Tile(Terrain.FORET); - - // Ajouter la tuile sur le plateau - board.addTile(position, newTile); - - // Rafraîchir l'affichage - repaint(); - } - } -} \ No newline at end of file + private Point calculateHexCoordinates(Point clickPoint) { + int col = (int) Math.round((clickPoint.x - hexWidth / 2.0) / (1.5 * hexRadius)); + int row = (int) Math.round((clickPoint.y - hexHeight / 2.0 - (col % 2) * hexHeight / 4.0) / hexHeight); + return new Point(col, row); + } + + private int calculateScreenX(Point position) { + int col = position.x; + return (int) (col * 1.5 * hexRadius + hexWidth / 2.0); + } + + private int calculateScreenY(Point position) { + int col = position.x; + int row = position.y; + return (int) (row * hexHeight + (col % 2) * hexHeight / 2.0 + hexHeight / 2.0); + } +} diff --git a/TestV1/TestEnAttendantResolutionBug/Main.class b/TestV1/TestEnAttendantResolutionBug/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..1e41647260c037daafa28423a962a2109a37d7e9 GIT binary patch literal 420 zcmX^0Z`VEs1_nn4c`gPf24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc23Dv1#G(`~26m86Zbk+U_r%=Pu*}qQE(R_JUXV$Aj0{{FK44|m zAWZ^{416F(&iQ#IMfo{7sYP52{0u@MrNWF1yc#|rNstNFnqeRrQ62^{kaIYTOA?Dp zK$7eX5{wKizKNN6j0`N!`6;Q44E#Qsd8vM-xk;%-A&E&jsf-LPxnOxQjc6Z)KY~k& zGV{`{HNzMgxPtRbi;`2_GC_(tL5Asp)G;VBh%+!TfB+K%BPbvk7#SoP7#L(37#SED z7#LW!wlgqpWME)mWRPNDU|<6aGBR*7NHfSlmAW%9Gq5l)Fv#y_V2|9+!0EG_fh$sb zI|GmJZU+8Ho$U;Qe!ANjL=c9EF|aZ)FfcQ4Ft9KPGO#j8F|aepF>o+2GRQJ8FfcL5 F0Ra6qN(uk~ literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/Main.java b/TestV1/TestEnAttendantResolutionBug/Main.java index 86fb72a..7589352 100644 --- a/TestV1/TestEnAttendantResolutionBug/Main.java +++ b/TestV1/TestEnAttendantResolutionBug/Main.java @@ -1,15 +1,9 @@ public class Main { public static void main(String[] args) { - // Création d'un plateau Board board = new Board(); - - // Vue avec le plateau GameView view = new GameView(board); - - // Contrôleur GameController controller = new GameController(view); - // Démarrer le jeu controller.startGame(); } -} +} \ No newline at end of file diff --git a/TestV1/TestEnAttendantResolutionBug/Terrain.class b/TestV1/TestEnAttendantResolutionBug/Terrain.class new file mode 100644 index 0000000000000000000000000000000000000000..f0a67a9bf7a550669b780844aa365387713c5d2f GIT binary patch literal 1008 zcmX^0Z`VEs1_nn4Yjy@EMh5nf)S{xq%sfs8Mg|rh237_(Mh0eI*C0j)P9Lb0HAs$w zhk+9$$Lj3i=o+cuh=64XM zmZ+bTn3t~apOlrFTw=||Aj=@f&LGdjpunKW$iRnC;F?#O%gDf9mY7qT>Yv8QV5)(n z+c_t(xY!y=Ah@I`GcVm5*#?jSVDpuE7*rTk85!7YGV?M^>=+rukd1=s^wbRFU|{89 zU}R9{VBq9n;Nf84=U@;53Fz`L=rQPnJPUSAF(U(yh9<(hj0|iraTe$NlvG9rexJ;| zRKL>Pq|~C2#H5^5Mh00dHfq8HjFCaWH?<@qKP4csC^0v+B(H}#cuY>$)12@agnvsDkIKQ+gIn^x_WHk>o0qB8(*1?d0kwKP$ zfq~6I5|m6B7#t))NdipsFtCAXekd&jq6MTtG0nihz{n#w=swxV363rz`(%BU<5K7EXT;e$)Lbs%)kUy&jc3b5@OWa!60*hfe}-^3CI>k z28IR(1}0F9F))L*$}=!CFf%YPuxn|{Y-do~h+z*%A14z7g8%~#yE69aE>B>N@?fnZE`aWI%Om_ZFn zfg0qon}IP>NR4?rgZgF$W-v#C1wEifr$a)2@3{Gu$UD9{UouM literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/Terrain.java b/TestV1/TestEnAttendantResolutionBug/Terrain.java index 3cbbe46..02135c5 100644 --- a/TestV1/TestEnAttendantResolutionBug/Terrain.java +++ b/TestV1/TestEnAttendantResolutionBug/Terrain.java @@ -1,3 +1,3 @@ public enum Terrain { - MER, CHAMP, PRE, FORET, MONTAGNE, VIDE + MER, CHAMP, FORET, PRE, MONTAGNE } diff --git a/TestV1/TestEnAttendantResolutionBug/Tile.class b/TestV1/TestEnAttendantResolutionBug/Tile.class new file mode 100644 index 0000000000000000000000000000000000000000..8ca866be765c807b55fb4f600087ae858e0821b8 GIT binary patch literal 320 zcmX^0Z`VEs1_nn45iSNM24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3V1kj$J^Mh5nh)S{xq%sfU0PM;76)0&ZiM+45$ z3}a+qan4UkWn|#@$;?ajE6q(xEec6Y0_o;TPc4D!Vr1af(1hz^WZ(+UFD*(=bpzYN z39?KNq4h=GBV LfssK7Y?Uwomm@V_ literal 0 HcmV?d00001 diff --git a/TestV1/TestEnAttendantResolutionBug/Tile.java b/TestV1/TestEnAttendantResolutionBug/Tile.java index d476f15..21da20c 100644 --- a/TestV1/TestEnAttendantResolutionBug/Tile.java +++ b/TestV1/TestEnAttendantResolutionBug/Tile.java @@ -1,5 +1,5 @@ public class Tile { - private Terrain terrain; // Un seul terrain pour toute la tuile + private Terrain terrain; public Tile(Terrain terrain) { this.terrain = terrain; diff --git a/TestV1/TestEnAttendantResolutionBug/View/BoardView.java b/TestV1/TestEnAttendantResolutionBug/View/BoardView.java deleted file mode 100644 index 8757694..0000000 --- a/TestV1/TestEnAttendantResolutionBug/View/BoardView.java +++ /dev/null @@ -1,61 +0,0 @@ -package view; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import model.Board; -import model.Tile; -import controller.GameController; - -public class BoardView extends JPanel { - private GameController controller; - private int rows = 5; - private int cols = 5; - - public BoardView(Board board, GameController controller) { - this.controller = controller; - setLayout(new GridLayout(rows, cols, 5, 5)); - initializeBoard(); - } - - // Méthode pour assigner le contrôleur après création de l'instance - public void setController(GameController controller) { - this.controller = controller; - } - - private void initializeBoard() { - for (int i = 0; i < rows * cols; i++) { - JPanel tilePanel = new JPanel(); - tilePanel.setBackground(Color.LIGHT_GRAY); - tilePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); - - tilePanel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - handleTilePlacement(tilePanel); - } - }); - - add(tilePanel); - } - } - - private void handleTilePlacement(JPanel tilePanel) { - if (controller != null) { // Assure que le contrôleur est bien assigné - Tile tile = controller.getNextTile(); - if (tile != null) { - tilePanel.setBackground(Color.GREEN); - tilePanel.add(new JLabel(tile.getType())); - revalidate(); - repaint(); - controller.placeTile(tile); - } - } - } - - public void refreshBoard() { - revalidate(); - repaint(); - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/View/GameController.java b/TestV1/TestEnAttendantResolutionBug/View/GameController.java deleted file mode 100644 index 0b3fe7c..0000000 --- a/TestV1/TestEnAttendantResolutionBug/View/GameController.java +++ /dev/null @@ -1,31 +0,0 @@ -package controller; - -import model.Game; -import model.Tile; -import view.GameView; - -public class GameController { - private Game game; - private GameView gameView; - private Tile currentTile; - - public GameController(Game game, GameView gameView) { - this.game = game; - this.gameView = gameView; - this.currentTile = null; // Initialise sans tuile au début - } - - public void selectNextTile(Tile tile) { - this.currentTile = tile; - } - - public Tile getNextTile() { - return currentTile; // Retourne la tuile actuellement sélectionnée - } - - public void placeTile(Tile tile) { - game.placeTile(tile); - gameView.update(game); - currentTile = null; // Réinitialise après placement - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/View/GameView.java b/TestV1/TestEnAttendantResolutionBug/View/GameView.java deleted file mode 100644 index 99c91e4..0000000 --- a/TestV1/TestEnAttendantResolutionBug/View/GameView.java +++ /dev/null @@ -1,52 +0,0 @@ -package view; - -import model.Game; -import model.Tile; -import controller.GameController; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -public class GameView extends JFrame { - private JLabel scoreLabel; - private BoardView boardView; - private GameController controller; // Ajoute le contrôleur ici - - public GameView(Game game) { // Constructeur sans le contrôleur en paramètre - setTitle("Dorfromantik en Java"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setSize(500, 500); - setLayout(new BorderLayout()); - - scoreLabel = new JLabel("Score : " + game.getScore()); - boardView = new BoardView(game.getBoard(), null); // Initialise BoardView sans contrôleur - - JButton nextTileButton = new JButton("Sélectionner une tuile"); - nextTileButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (controller != null) { // Vérifie que le contrôleur est bien assigné - Tile tile = new Tile("forêt", new String[]{"terre", "terre", "eau", "terre", "eau", "terre"}); - controller.selectNextTile(tile); - } - } - }); - - add(scoreLabel, BorderLayout.NORTH); - add(boardView, BorderLayout.CENTER); - add(nextTileButton, BorderLayout.SOUTH); - } - - // Nouvelle méthode setController pour permettre d'assigner le contrôleur après création - public void setController(GameController controller) { - this.controller = controller; - boardView.setController(controller); // Passe le contrôleur à BoardView - } - - public void update(Game game) { - scoreLabel.setText("Score : " + game.getScore()); - boardView.refreshBoard(); - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/controller/GameController.java b/TestV1/TestEnAttendantResolutionBug/controller/GameController.java deleted file mode 100644 index 4b08d39..0000000 --- a/TestV1/TestEnAttendantResolutionBug/controller/GameController.java +++ /dev/null @@ -1,20 +0,0 @@ -package controller; - -import model.Game; -import model.Tile; -import view.GameView; - -public class GameController { - private Game game; - private GameView gameView; - - public GameController(Game game, GameView gameView) { - this.game = game; - this.gameView = gameView; - } - - public void placeTile(Tile tile) { - game.placeTile(tile); - gameView.update(game); - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/model/Board.java b/TestV1/TestEnAttendantResolutionBug/model/Board.java deleted file mode 100644 index b5e26f2..0000000 --- a/TestV1/TestEnAttendantResolutionBug/model/Board.java +++ /dev/null @@ -1,26 +0,0 @@ -package model; - -import java.util.ArrayList; -import java.util.List; - -public class Board { - private List tiles; - - public Board() { - tiles = new ArrayList<>(); - } - - public void addTile(Tile tile) { - tiles.add(tile); - } - - public List getTiles() { - return tiles; - } - - public boolean isPlacementValid(Tile tile) { - // Logique simplifiée pour vérifier si la tuile peut être placée - // Ici, tu pourrais vérifier les bords de la tuile et du plateau - return true; // Retourne true pour simplifier - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/model/Game.java b/TestV1/TestEnAttendantResolutionBug/model/Game.java deleted file mode 100644 index 5cf832a..0000000 --- a/TestV1/TestEnAttendantResolutionBug/model/Game.java +++ /dev/null @@ -1,26 +0,0 @@ -package model; - -public class Game { - private Board board; - private int score; - - public Game() { - board = new Board(); - score = 0; - } - - public Board getBoard() { - return board; - } - - public int getScore() { - return score; - } - - public void placeTile(Tile tile) { - if (board.isPlacementValid(tile)) { - board.addTile(tile); - score += 10; // Par exemple, chaque tuile ajoute 10 points - } - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/model/Tile.java b/TestV1/TestEnAttendantResolutionBug/model/Tile.java deleted file mode 100644 index f175519..0000000 --- a/TestV1/TestEnAttendantResolutionBug/model/Tile.java +++ /dev/null @@ -1,19 +0,0 @@ -package model; - -public class Tile { - private String type; // Par exemple : "forêt", "rivière", "champ", etc. - private String[] edges; // Les types des bords de la tuile (ex: "eau", "terre") - - public Tile(String type, String[] edges) { - this.type = type; - this.edges = edges; - } - - public String getType() { - return type; - } - - public String getEdge(int index) { - return edges[index]; - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/view/BoardView.java b/TestV1/TestEnAttendantResolutionBug/view/BoardView.java deleted file mode 100644 index e81065b..0000000 --- a/TestV1/TestEnAttendantResolutionBug/view/BoardView.java +++ /dev/null @@ -1,24 +0,0 @@ -package view; - -import javax.swing.*; -import model.Board; -import model.Tile; -import java.awt.*; - -public class BoardView extends JPanel { - private Board board; - - public BoardView(Board board) { - this.board = board; - setLayout(new GridLayout(5, 5, 5, 5)); // Exemple de grille 5x5 pour le plateau - } - - public void refreshBoard() { - removeAll(); - for (Tile tile : board.getTiles()) { - add(new TileView(tile.getType())); - } - revalidate(); - repaint(); - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/view/GameView.java b/TestV1/TestEnAttendantResolutionBug/view/GameView.java deleted file mode 100644 index 4028ecb..0000000 --- a/TestV1/TestEnAttendantResolutionBug/view/GameView.java +++ /dev/null @@ -1,28 +0,0 @@ -package view; - -import model.Game; -import javax.swing.*; -import java.awt.*; - -public class GameView extends JFrame { - private JLabel scoreLabel; - private BoardView boardView; - - public GameView(Game game) { - setTitle("Dorfromantik en Java"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setSize(400, 400); - setLayout(new BorderLayout()); - - scoreLabel = new JLabel("Score : " + game.getScore()); - boardView = new BoardView(game.getBoard()); - - add(scoreLabel, BorderLayout.NORTH); - add(boardView, BorderLayout.CENTER); - } - - public void update(Game game) { - scoreLabel.setText("Score : " + game.getScore()); - boardView.refreshBoard(); - } -} diff --git a/TestV1/TestEnAttendantResolutionBug/view/TileView.java b/TestV1/TestEnAttendantResolutionBug/view/TileView.java deleted file mode 100644 index b5bf724..0000000 --- a/TestV1/TestEnAttendantResolutionBug/view/TileView.java +++ /dev/null @@ -1,21 +0,0 @@ -package view; - -import javax.swing.*; -import java.awt.*; - -public class TileView extends JPanel { - private String type; - - public TileView(String type) { - this.type = type; - setPreferredSize(new Dimension(50, 50)); // Taille de la tuile - setBackground(Color.LIGHT_GRAY); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.BLACK); - g.drawString(type, 10, 25); // Affiche le type de la tuile au centre - } -}