From 22a24e44934319f20f520d7f726dd74c97fec2c9 Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 6 May 2019 17:27:11 +0200 Subject: [PATCH] modifications classes roi et tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tour : ajout méthode déplacement possible Roi : ajout commentaire pour méthode enEchec() --- src/piecesEchiquier/Roi.java | 7 +++++-- src/piecesEchiquier/Tour.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/piecesEchiquier/Roi.java b/src/piecesEchiquier/Roi.java index 150c31f..6972209 100755 --- a/src/piecesEchiquier/Roi.java +++ b/src/piecesEchiquier/Roi.java @@ -9,13 +9,16 @@ public class Roi extends Piece { } /* - public void enEchec() { - Position positionCourante; + public void enEchec(Piece piece, Position position) { + boolean[][] mouvementsPossibles; + mouvementsPossibles=piece.getMouvementsPossibles(); + positionCourante = super.getEmplacement(); } */ + public boolean aBouge() { if(this.getIni() != this.getPosition()) diff --git a/src/piecesEchiquier/Tour.java b/src/piecesEchiquier/Tour.java index d48f872..afe1ec3 100755 --- a/src/piecesEchiquier/Tour.java +++ b/src/piecesEchiquier/Tour.java @@ -20,4 +20,20 @@ public class Tour extends Piece { } return verif; } + + public boolean[][] deplacementsPossibles() { + boolean[][] deplacementsPossibles = new boolean[8][8]; + Position position = this.getPosition(); + int x = position.getX(); + int y = position.getY(); + for(int i=x; i<8; i++) { + //if(echiquier.estVide(position)) + deplacementsPossibles[i][y]=true; + } + for(int j=0; j<8; j++) { + deplacementsPossibles[x][j]=true; + } + deplacementsPossibles[x][y]=false; + return deplacementsPossibles; + } }