Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void start(Board zz)
- {
- boolean canPlay = true;
- Scanner s = new Scanner(System.in);
- Board b = new Board();
- // white even , black odd
- // stores all movements
- while(canPlay)
- {
- if(plyTurn%2==0) {
- System.out.print("White's move: " );
- }
- else if(plyTurn%2!=0) {
- System.out.print("Black's move: ");
- }
- String input = s.nextLine();
- System.out.println();
- currentMove = input;
- /*Resign*/
- if(input.equals("resign")) {
- if(plyTurn%2==0) { // white resigned
- System.out.println("Black wins");
- }
- else {
- System.out.println("White wins");
- }
- canPlay = false;
- break;
- }
- /*draw*/
- else if(input.equals("draw") && input.length()==4) {
- canPlay = false;
- break;
- }
- String from = input.substring(0, 2);
- String to = input.substring(3, 5);
- if(from.equals("f4"))
- {
- int a;
- a=0;
- }
- int c = (int) (from.charAt(0)) - 97; // e2 e4 //x prev
- int d = 8 - Integer.parseInt(from.charAt(1) + "");//y prev
- int w = (int) (to.charAt(0)) - 97; // e2 e4 // x new
- int v = 8 - Integer.parseInt(to.charAt(1) + ""); // y new
- /* whites move*/
- if (plyTurn%2==0) { // TODO draw
- if(zz.board[d][c]==null || zz.board[d][c].getcolor()!='w' ) { //empty spot move or not white
- System.out.println("Illegal move, try again");
- continue;
- }
- if(zz.move(from,to) ) {
- moveHistory.add(input);
- plyTurn++;
- zz.draw();
- }
- if(zz.inCheckmate('b') ) { // maybe should be before above if
- System.out.println("Checkmate");
- //Systen.out.println("Black wins");
- break;
- }
- if(zz.check('b')) {
- System.out.println("check");
- continue;
- }
- if(input.length()==11 && zz.move(from,to)) { //TODO special cases remeber enpassant
- plyTurn++;
- zz.draw();
- moveHistory.add(input);
- //Systen.out.println("****&&&&&&");
- continue;
- }
- // System.out.println("****&&&&&&" + zz.move(from,to));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement