src/edu/isep/jeudes6couleurs/game/grids/GridDiamond.java
/**
   * Permet d'afficher la grille en mode 2D
   */
Permet d'afficher la grille en mode 2D
Permet d ' afficher la grille en mode 2D
public GridPane show2D(Game game) {
    GridPane gameGrid = new GridPane();
    for (int i = 0; i < nbOfLines; i++) {
      ArrayList<Tile> line = grid.get(i);
      for (int j = 0; j < line.size(); j++) {
        Tile tile = line.get(j);
        int  pID  = tile.getPlayerID();
        Button button = new Button();
        button.getStyleClass().add("tile");
        button.getStyleClass().add(TileColor.getColorClassName(tile.getColor()));
        if (nbOfLines > 19) {
          button.getStyleClass().add("small");
        }
        if (pID != 0) {
          button.setText(Integer.toString(pID));
        }
        button.setOnAction(event -> {
          game.chooseColor(tile.getColor());
        });
        int columnIndex;
        if (i < nbOfLines/2) {
          columnIndex = new Double(j*2+(Math.floor((nbOfLines-i)))).intValue();
        } else {
          columnIndex = j*2+i+1;
        }
        gameGrid.add(button, columnIndex, i);
        Button blank = new Button();
        blank.getStyleClass().add("tile");
        blank.getStyleClass().add("white");
        if (nbOfLines > 19) {
          blank.getStyleClass().add("small");
        }
        gameGrid.add(blank, columnIndex+1, i);
      }
    }
    return gameGrid;
  }
public GridPane show2D ( Game game ) { GridPane gameGrid = new GridPane ( ) ; for ( int i = 0 ; i < nbOfLines ; i ++ ) { ArrayList < Tile > line = grid . get ( i ) ; for ( int j = 0 ; j < line . size ( ) ; j ++ ) { Tile tile = line . get ( j ) ; int pID = tile . getPlayerID ( ) ; Button button = new Button ( ) ; button . getStyleClass ( ) . add ( "tile" ) ; button . getStyleClass ( ) . add ( TileColor . getColorClassName ( tile . getColor ( ) ) ) ; if ( nbOfLines > 19 ) { button . getStyleClass ( ) . add ( "small" ) ; } if ( pID != 0 ) { button . setText ( Integer . toString ( pID ) ) ; } button . setOnAction ( event -> { game . chooseColor ( tile . getColor ( ) ) ; } ) ; int columnIndex ; if ( i < nbOfLines / 2 ) { columnIndex = new Double ( j * 2 + ( Math . floor ( ( nbOfLines - i ) ) ) ) . intValue ( ) ; } else { columnIndex = j * 2 + i + 1 ; } gameGrid . add ( button , columnIndex , i ) ; Button blank = new Button ( ) ; blank . getStyleClass ( ) . add ( "tile" ) ; blank . getStyleClass ( ) . add ( "white" ) ; if ( nbOfLines > 19 ) { blank . getStyleClass ( ) . add ( "small" ) ; } gameGrid . add ( blank , columnIndex + 1 , i ) ; } } return gameGrid ; }
Permet d'afficher la grille en mode 2D
Permet d ' afficher la grille en mode 2D