revert 6232e6f93e
revert Merge branch 'main' of https://grond.iut-fbleau.fr/stiti/SAE31_2024
This commit is contained in:
24
TestV1/TestEnAttendantResolutionBug/view/BoardView.java
Normal file
24
TestV1/TestEnAttendantResolutionBug/view/BoardView.java
Normal file
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
28
TestV1/TestEnAttendantResolutionBug/view/GameView.java
Normal file
28
TestV1/TestEnAttendantResolutionBug/view/GameView.java
Normal file
@@ -0,0 +1,28 @@
|
||||
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();
|
||||
}
|
||||
}
|
21
TestV1/TestEnAttendantResolutionBug/view/TileView.java
Normal file
21
TestV1/TestEnAttendantResolutionBug/view/TileView.java
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user