-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathking.java
More file actions
60 lines (48 loc) · 2.09 KB
/
king.java
File metadata and controls
60 lines (48 loc) · 2.09 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
package chessUtkarsh;
public class king extends Simple{
private static final long serialVersionUID = 1L;
public static void Check(int playerTurn, int R2, int C2) {
switch(chessBoard[C2][R2]){
case 'P' : if(chessBoard[C2-1][R2-1]=='k' | chessBoard[C2-1][R2+1]=='k')
System.out.println("Wow white pawn you just checked black king");break;
case 'p' : if(chessBoard[C2-1][R2-1]=='K' | chessBoard[C2-1][R2+1]=='K')
System.out.println("Wow black pawn you just checked white king");break;
case 'N' : if(Math.abs(kC-C2)*Math.abs(kR-R2)==2)
System.out.println("Wow white Knight you just checked black king");break;
case 'n' : if(Math.abs(kC-C2)*Math.abs(kR-R2)==2)
System.out.println("Wow black Knight you just checked white king");break;
case 'R' : if(R2==kR | kC==C2){
if(noPieceRook(R2,C2,kR,kC))
System.out.println("Wow white Rook you just checked black king");
}break;
case 'r' : if(R2==kR | KC==C2){
if(noPieceRook(R2,C2,KR,KC))
System.out.println("Wow black Rook you just checked white king");
}break;
case 'B' : if(Math.abs(C2-kC)==Math.abs(R2-kR)){
if(noPieceBishop(R2, C2, kR, kC))
System.out.println("Wow white Bishop you just checked black king");
}break;
case 'b' : if(Math.abs(C2-KC)==Math.abs(R2-KR)){
if(noPieceBishop(R2, C2, KR, KC))
System.out.println("Wow black Bishop you just checked white king");
}break;
case 'Q' : if(Math.abs(kC-C2)==Math.abs(kR-R2)){
if(noPieceBishop(R2, C2 , kR, kC))
System.out.println("Wow white Queen you just checked black king");
}
else if(R2==kR | kC==C2){
if(noPieceRook( R2,C2, kR, kC ))
System.out.println("Wow white Queen you just checked black king");
}break;
case 'q' : if(Math.abs(KC-C2)==Math.abs(KR-R2)){
if(noPieceBishop(R2, C2 , KR, KC))
System.out.println("Wow black Queen you just checked white king");
}
else if(R2==KR | KC==C2){
if(noPieceRook( R2,C2, KR, KC ))
System.out.println("Wow black Queen you just checked white king");
}break;
}
}
}