-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
97 lines (86 loc) · 3.65 KB
/
Main.java
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Game game = new Game();
int turn = 0;
int islem = 0;
while (true) {
if (turn == 0)
System.out.println("Sira beyazda!");
else
System.out.println("Sira siyahda!");
if(islem == 0){
System.out.println("******************");
game.displayGame();
System.out.println("******************");
}
else{
System.out.println("******************");
game.displayGame();
System.out.println("******************");
}
int fromX;
int fromY;
int toX;
int toY;
String input = scan.nextLine();
if (input.equals("exit")){
System.out.println("Player 1 :"+game.getPlayer1().getPoint()+" points");
System.out.println("Player 2 :"+game.getPlayer2().getPoint()+" points");
System.exit(0);
}
else if (input.length() == 5) {
fromX = input.charAt(0) - 97;
fromY = input.charAt(1) - 49;
toX = input.charAt(3) - 97;
toY = input.charAt(4) - 49;
if (game.getBoard().getTaslar()[fromX][fromY].getColorNo() == turn) {
if ((game.getBoard().getTaslar()[toX][toY] != null)
&& (turn == game.getBoard().getTaslar()[toX][toY].getColorNo())) {
System.out.println("Kendi tasini yiyemezsin!");
continue;
}
else if (turn == 0) {
if (game.getBoard().getTaslar()[fromX][fromY].isPlayable(fromX, fromY, toX, toY,
game.getBoard().getTaslar())) {
game.addPoint(game.getPlayer1(), game.getBoard().moveTo(fromX, fromY, toX, toY));
game.getBoard().tabloyuSolaKaydir();
} else {
System.out.println("Hatali bir hamle, tekrar giriniz!");
continue;
}
}
else {
if (game.getBoard().getTaslar()[fromX][fromY].isPlayable(fromX, fromY, toX, toY,
game.getBoard().getTaslar())) {
game.addPoint(game.getPlayer2(), game.getBoard().moveTo(fromX, fromY, toX, toY));
game.getBoard().tabloyuSolaKaydir();
} else {
System.out.println("Hatali bir hamle, tekrar giriniz!");
continue;
}
}
} else {
System.out.println("Sira sizde degil!");
continue;
}
} else {
System.out.println("Hatali girdi!");
continue;
}
if (game.getPlayer1().getPoint() > 500){
System.out.println("Beyaz oyuncu oyunu kazandi.");
game.getBoard().displayBoard();
System.exit(0);
}
if (game.getPlayer2().getPoint() > 500){
System.out.println("Siyah oyuncu oyunu kazandi.");
game.getBoard().displayBoard();
System.exit(0);
}
turn = (turn + 1) % 2;
islem++;
}
}
}