-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDame
43 lines (34 loc) · 1.42 KB
/
Dame
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
package SchachFiguren;
import schach.ChessGame;
import schach.ColorFigure;
import schach.Figure;
public class Dame extends Figure {
ChessGame chessGame = new ChessGame();
public static String black = "♕";
public static String white = "♛";
public Dame(int posStart, int posEnd, ColorFigure colorFigure){
super(posStart,posEnd, colorFigure);
type = Type.Dame;
}
@Override
public boolean moveIsPossible(int posStart, int posEnd) {
if((Math.abs(posStart/10 - posEnd/10) == Math.abs(posStart%10 - posEnd%10)) || (posStart/10 == posEnd/10) || (posStart%10 == posEnd%10))
return true;
else
{
System.out.println("Move is not possible");
return false;
}
}
@Override
public void makeMove(int posStart, int posEnd) {
if(chessGame.askColor(posStart) == ColorFigure.Black){
ChessGame.field[posEnd%10-1][posEnd/10-1].value= Dame.black;
} else {ChessGame.field[posEnd%10-1][posEnd/10-1].value= Dame.white;}
ChessGame.field[posStart%10-1][posStart/10-1].value= " ";
ChessGame.field[posStart%10-1][posStart/10-1].type= Type.Null;
ChessGame.field[posEnd%10-1][posEnd/10-1].type = Type.Dame;
ChessGame.field[posStart%10-1][posStart/10-1].colorFigure = ColorFigure.Null;
ChessGame.field[posEnd%10-1][posEnd/10-1].colorFigure = chessGame.askColor(posStart);
}
}