-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpringer
More file actions
42 lines (33 loc) · 1.46 KB
/
Copy pathSpringer
File metadata and controls
42 lines (33 loc) · 1.46 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
package SchachFiguren;
import schach.ChessGame;
import schach.ColorFigure;
import schach.Figure;
public class Springer extends Figure {
ChessGame chessGame = new ChessGame();
public static String black = "♘";
public static String white = "♞";
public Springer(int posStart, int posEnd, ColorFigure colorFigure){
super(posStart,posEnd, colorFigure);
}
@Override
public boolean moveIsPossible(int posStart, int posEnd) {
if(((Math.abs(posStart/10 - posEnd/10) == 2) && (Math.abs(posStart%10 - posEnd%10)== 1) )|| ((Math.abs(posStart/10 - posEnd/10) == 1) && (Math.abs(posStart%10 - posEnd%10)== 2)))
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= Springer.black;
} else {ChessGame.field[posEnd%10-1][posEnd/10-1].value= Springer.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.Springer;
ChessGame.field[posStart%10-1][posStart/10-1].colorFigure = ColorFigure.Null;
ChessGame.field[posEnd%10-1][posEnd/10-1].colorFigure = chessGame.askColor(posStart);
}
}