-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTour.java
More file actions
79 lines (62 loc) · 2.12 KB
/
Tour.java
File metadata and controls
79 lines (62 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
public class Tour extends Piece{
public Tour(boolean pieceCouleur, String pieceUnicode, Case positionPiece, VerificationPiece newArbitre){
super (pieceCouleur, pieceUnicode, positionPiece, newArbitre);
}
public void calculDeplacementPossible() {
int position = this.emplacement.id;
int colonneD = (int) position/10;
int ligneD = position - colonneD*10;
int ligne = ligneD;
// Calcul vers le bas
int verif= 3;
while(ligne>1 && verif==3){
ligne--;
verif = this.arbitre.verification(colonneD*10+ligne, this.couleur);
if(verif==1){
this.addCase(colonneD*10+ligne);
}
else if(verif==2){
this.addCase(colonneD*10+ligne);
}
}
ligne = ligneD;
// Calcul vers le haut
verif= 3;
while(ligne<8 && verif==3){
ligne++;
verif= this.arbitre.verification(colonneD*10+ligne, this.couleur);
if(verif==3){
this.addCase(colonneD*10+ligne);
}
else if(verif==2){
this.addCase(colonneD*10+ligne);
}
}
int colonne = colonneD;
// Calcul vers la droite
verif= 3;
while(colonne<8 && verif==3){
colonne++;
verif= this.arbitre.verification(colonneD*10+ligne, this.couleur);
if(verif==1){
this.addCase(colonne*10+ligneD);
}
else if(verif==2){
this.addCase(colonne*10+ligneD);
}
}
colonne = colonneD;
// Calcul vers la gauche
verif= 3;
while(colonne>1 && verif==3){
colonne--;
verif= this.arbitre.verification(colonneD*10+ligne, this.couleur);
if(verif==1){
this.addCase(colonne*10+ligneD);
}
else if(verif==2){
this.addCase(colonne*10+ligneD);
}
}
}
}